32
32
"PACKETS" : np .uint64 ,
33
33
"BYTES" : np .uint64 ,
34
34
"FLOWS" : np .uint64 ,
35
+ "ACTIVE_TIME" : np .uint64 ,
36
+ "CACHE_TIME" : np .uint64 ,
35
37
}
36
38
37
39
STATS_CSV_COLUMN_TYPES = {
@@ -120,26 +122,43 @@ class FlowEndEvent(Event):
120
122
time = 0
121
123
flow_rate : float
122
124
flows : int
123
-
124
- def __init__ (self , data_rate , packet_rate , end_time , flow_rate , flows ):
125
+ active_time : np .uint64
126
+ cache_time : np .uint64
127
+
128
+ def __init__ (
129
+ self ,
130
+ data_rate ,
131
+ packet_rate ,
132
+ end_time ,
133
+ flow_rate ,
134
+ flows ,
135
+ active_time ,
136
+ cache_time ,
137
+ ):
125
138
self .data_rate = - data_rate
126
139
self .packet_rate = - packet_rate
127
140
self .time = end_time
128
141
self .flow_rate = - flow_rate
129
142
self .flows = - int (flows )
143
+ self .active_time = active_time
144
+ self .cache_time = cache_time
130
145
131
146
132
147
class OnePacketFlow (Event ):
133
148
bytes : np .uint64
134
149
packets : np .uint64
135
150
time = 0
136
151
flows : np .uint64
152
+ active_time : np .uint64
153
+ cache_time : np .uint64
137
154
138
- def __init__ (self , bytes , packets , time , flows ):
155
+ def __init__ (self , bytes , packets , time , flows , active_time , cache_time ):
139
156
self .bytes = bytes
140
157
self .packets = packets
141
158
self .time = time
142
159
self .flows = flows
160
+ self .active_time = active_time
161
+ self .cache_time = cache_time
143
162
144
163
145
164
class ExportEvent (Event ):
@@ -244,6 +263,10 @@ def create_event_queue(
244
263
temp_end = tempfile .NamedTemporaryFile (
245
264
mode = "w" , prefix = "end_time" , suffix = ".csv" , dir = out_dir , delete = False
246
265
)
266
+ temp_export = tempfile .NamedTemporaryFile (
267
+ mode = "w" , prefix = "export_time" , suffix = ".csv" , dir = out_dir , delete = False
268
+ )
269
+ tmp_export .append (temp_export )
247
270
tmp_start_time .append (temp_start )
248
271
tmp_end_time .append (temp_end )
249
272
tmp_one_pack .append (temp_one )
@@ -255,10 +278,23 @@ def create_event_queue(
255
278
else :
256
279
end = max (end , math .ceil (chunk ["END_TIME" ].max () / 1000 ))
257
280
281
+ # Export Events
282
+ if "EXPORT_TIME" not in chunk .columns :
283
+ # accurate expected EXPORT_TIME
284
+ chunk ["EXPORT_TIME" ] = chunk ["END_TIME" ] // 1000 + inactive_timeout + 1
285
+ # approximate SEQ_NUMBER
286
+ chunk ["SEQ_NUMBER" ] = chunk ["EXPORT_TIME" ] % 32
287
+ # random MSG_LENGTH
288
+ chunk ["MSG_LENGTH" ] = random .randint (100 , 2048 )
289
+ chunk ["ACTIVE_TIME" ] = chunk ["END_TIME" ] - chunk ["START_TIME" ] + 1
290
+ chunk ["CACHE_TIME" ] = (
291
+ chunk ["EXPORT_TIME" ] * 1000 - chunk ["START_TIME" ] + 1
292
+ ).clip (lower = 0 )
293
+
258
294
# One-packet flows
259
295
(
260
296
chunk [chunk ["PACKETS" ] == 1 ]
261
- .groupby ("START_TIME" , as_index = False )
297
+ .groupby ([ "START_TIME" , "ACTIVE_TIME" , "CACHE_TIME" ] , as_index = False )
262
298
.agg (** agg_dict )
263
299
.sort_values ("START_TIME" )
264
300
.to_csv (
@@ -267,19 +303,6 @@ def create_event_queue(
267
303
)
268
304
)
269
305
270
- # Export Events
271
- if "EXPORT_TIME" not in chunk .columns :
272
- # accurate expected EXPORT_TIME
273
- chunk ["EXPORT_TIME" ] = chunk ["END_TIME" ] // 1000 + inactive_timeout + 1
274
- # approximate SEQ_NUMBER
275
- chunk ["SEQ_NUMBER" ] = chunk ["EXPORT_TIME" ] % 32
276
- # random MSG_LENGTH
277
- chunk ["MSG_LENGTH" ] = random .randint (100 , 2048 )
278
-
279
- temp_export = tempfile .NamedTemporaryFile (
280
- mode = "w" , prefix = "export_time" , suffix = ".csv" , dir = out_dir , delete = False
281
- )
282
- tmp_export .append (temp_export )
283
306
(
284
307
chunk .groupby (["EXPORT_TIME" , "SEQ_NUMBER" ], as_index = False )
285
308
.agg (
@@ -296,7 +319,9 @@ def create_event_queue(
296
319
# Multi-packet flows
297
320
(
298
321
chunk [chunk ["PACKETS" ] > 1 ]
299
- .groupby (["START_TIME" , "END_TIME" ], as_index = False )
322
+ .groupby (
323
+ ["START_TIME" , "END_TIME" , "ACTIVE_TIME" , "CACHE_TIME" ], as_index = False
324
+ )
300
325
.agg (** agg_dict )
301
326
.sort_values ("START_TIME" )
302
327
.to_csv (
@@ -307,7 +332,9 @@ def create_event_queue(
307
332
308
333
(
309
334
chunk [chunk ["PACKETS" ] > 1 ]
310
- .groupby (["START_TIME" , "END_TIME" ], as_index = False )
335
+ .groupby (
336
+ ["START_TIME" , "END_TIME" , "ACTIVE_TIME" , "CACHE_TIME" ], as_index = False
337
+ )
311
338
.agg (** agg_dict )
312
339
.sort_values ("END_TIME" )
313
340
.to_csv (
@@ -403,6 +430,8 @@ def read_one_packet_events(path: str) -> Iterator[OnePacketFlow]:
403
430
packets = row ["PACKETS" ],
404
431
time = row ["START_TIME" ],
405
432
flows = row ["FLOWS" ],
433
+ active_time = row ["ACTIVE_TIME" ],
434
+ cache_time = row ["CACHE_TIME" ],
406
435
)
407
436
408
437
@@ -433,4 +462,6 @@ def read_end_events(path: str) -> Iterator[FlowEndEvent]:
433
462
end_time = row ["END_TIME" ],
434
463
flow_rate = flow_rate ,
435
464
flows = row ["FLOWS" ],
465
+ active_time = row ["ACTIVE_TIME" ],
466
+ cache_time = row ["CACHE_TIME" ],
436
467
)
0 commit comments