forked from signetlabdei/ns3-mmwave-hbf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKTstats.py
executable file
·89 lines (78 loc) · 2.72 KB
/
PKTstats.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/python
import sys
import matplotlib.pyplot as plt
import numpy as np
import collections as cl
if len(sys.argv)>1:
if (sys.argv[1].find('-t=')==0):
outputFileTag=sys.argv[1][ sys.argv[1].find('-t=')+3: ]
if len(sys.argv)>2:
if (sys.argv[2].find('-l=')==0):
firstFileName=3
listOfLabels=sys.argv[2][ sys.argv[2].find('-l=')+3: ].split(',')
print(listOfLabels)
else:
firstFileName=2
listOfLabels=sys.argv[firstFileName:]
else:
firstFileName=1
outputFileTag=""
listOfLabels=sys.argv[firstFileName:]
filenames = sys.argv[firstFileName:]
else:
filenames = ['RxPacketTrace.txt']
outputFileTag=""
resultsDic={}
ResDicStruct=cl.namedtuple('ResDicStruct',[
'dRecPktsDl',
'dRecPktsUl'
])
for filename in filenames:
f=open(filename)
dRecPktsDl={}
dRecPktsUl={}
for ln in f:
if ln.find('The number of DL received bytes for UE ')>=0:
rnti=int(ln[ln.find('UE')+3:ln.find(':',ln.find('UE')+3)])
pkts=int(ln[ln.find(':')+2:])
if dRecPktsDl.has_key(rnti):
dRecPktsDl[rnti]+=pkts#should never reach this point
else:
dRecPktsDl[rnti]=pkts
if ln.find('The number of UL received bytes for UE ')>=0:
rnti=int(ln[ln.find('UE')+3:ln.find(':',ln.find('UE')+3)])
pkts=int(ln[ln.find(':')+2:])
if dRecPktsUl.has_key(rnti):
dRecPktsUl[rnti]+=pkts#should never reach this point
else:
dRecPktsUl[rnti]=pkts
resultsDic[filename]=ResDicStruct( dRecPktsDl,
dRecPktsUl)
allMarkers=['o',
'*',
's',
'x',
'd',
'+',
'^',
'v',
'<',
'>',
'p',
'.']
## PER SIMULATION BAR PLOTS
plt.figure(1)
plt.bar(listOfLabels,[np.sum(resultsDic[x].dRecPktsDl.values()) for x in filenames],)
plt.figure(2)
plt.bar(listOfLabels,[np.sum(resultsDic[x].dRecPktsUl.values()) for x in filenames],)
# plt.figure(5)
# plt.bar([x+barWidth*markCtr for x in resultsDic[file].dAvgBlerUL.keys()],resultsDic[file].dAvgBlerUL.values(), width=barWidth)
plt.figure(1)
plt.ylabel('Received Data (bits)')
plt.gca().set_xticklabels(listOfLabels)
plt.savefig('PKTS_DL_plot%s.eps' %(outputFileTag), format='eps')
plt.figure(2)
plt.ylabel('Received Data (bits)')
plt.gca().set_xticklabels(listOfLabels)
plt.savefig('PKTS_UL_plot%s.eps' %(outputFileTag), format='eps')
# plt.show()