-
Notifications
You must be signed in to change notification settings - Fork 0
/
th.py
38 lines (22 loc) · 773 Bytes
/
th.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from decimal import Decimal
from NS2NewTraceParser import NS2NewTraceParser
mio = NS2NewTraceParser('WiMax.tr')
sent_pkts = mio.get_sent_pkts_times_at('1','1','MAC')
recv_pkts = mio.get_recv_pkts_times_at('0','1','MAC')
start_time = Decimal(sent_pkts[0][1])
last_sent_pkt_id = sent_pkts[-1][0]
print len(sent_pkts), len(recv_pkts)
for recv_pkt in recv_pkts:
if recv_pkt[0] == last_sent_pkt_id:
stop_time = recv_pkt[1]
stop_time = Decimal(stop_time)
delta = stop_time - start_time
print start_time, stop_time, delta
data_size = Decimal(mio.get_recv_flow_total_size_at('0','1',20))
print data_size
th_bps = data_size / delta
conv = Decimal(8) / Decimal(1000)
th_kbps = th_bps*conv
print th_kbps
pippo = (data_size / Decimal(9)) * conv
print pippo