Finally I add ErrorModel to wpan_demo2.tcl, and but the result I get
is quite different from the that of the paper "A Comprehensive
Performance Study of IEEE 802.15.4" which is written by the author of
wpan module.
Here is my result:
pps is 15.1
throughput is 1.6 KBps
packet delivery ratio is 98.7 %
pps is 4.8
throughput is 0.6 KBps
packet delivery ratio is 98.0 %
pps is 2.6
throughput is 0.4 KBps
packet delivery ratio is 97.0 %
pps is 1.4
throughput is 0.3 KBps
packet delivery ratio is 96.7 %
The paper says that as pps goes bigger, the packet delivery ratio
should go down.
I guess it's quite possible that I have made some mistakes, but I
cannot find out myself.
The attachments are my scripts:
run: just type ./run to run the simulation and you'll see the result
wpan_demo2.tcl: I made some changes to the original wpan_demo2.tcl
calc_wpan2.py: it's used by ./run to caculate pps and packet delivery ratio
Best regards,
Bruce Who
2006-04-03
import sys
import re
cols = [r"(?P<cmd>\w)",
r"(?P<time>(\d|\.)+)",
r"_(?P<nodeaddr>\d)_",
r"\w+",
r"(?P<why>[^\s]+)", # ---
r"\d+",
r"(?P<pkttype>\w+)",
r"(?P<pktsize>\d+)",
r"\[\w+ (?P<dstaddr>\w+) (?P<srcaddr>\w+) \w+\]",
r".*"
]
row_str = r'\s+'.join(cols)
pat = re.compile(row_str)
class NodeStatistic:
def __init__(self):
self.txTcpPktCount_ = 0
self.txTcpPktBytes_ = 0
self.txAckPktCount_ = 0
self.txAckPktBytes_ = 0
self.txBcnPktCount_ = 0
self.txBcnPktBytes_ = 0
self.txPktCount_ = 0
self.txPktBytes_ = 0
self.rxPktCount_ = 0
self.rxPktBytes_ = 0
self.dpPktCount_ = 0
self.dpPktBytes_ = 0
self.dpTcpPktCount_ = 0
self.dpTcpPktBytes_ = 0
self.errTcpPktCount_ = 0
self.ackPktCount_ = 0
self.ackPktBytes_ = 0
def main():
if len(sys.argv) == 2:
tracefilename = sys.argv[1]
f = open(tracefilename, 'rb')
result = {'s': 0, 'r': 0, 'D': 0, 'f': 0, 'dropped': 0, 'ack': 0}
dictNodeStatistic = {}
for x in f:
m = pat.match(x)
if m:
cmd = m.group('cmd').lower()
time = m.group('time')
nodeaddr = m.group('nodeaddr')
why = m.group('why').lower()
pkttype = m.group('pkttype').lower()
pktsize = int(m.group('pktsize'))
dstaddr = m.group('dstaddr')
srcaddr = m.group('srcaddr')
if not dictNodeStatistic.has_key(nodeaddr):
dictNodeStatistic[nodeaddr] = NodeStatistic()
ns = dictNodeStatistic[nodeaddr]
if cmd == 's':
if pkttype == 'exp':
ns.txTcpPktCount_ += 1
ns.txTcpPktBytes_ += pktsize
elif pkttype == 'ack':
ns.txAckPktCount_ += 1
ns.txAckPktBytes_ += pktsize
elif pkttype == 'bcn':
ns.txBcnPktCount_ += 1
ns.txBcnPktBytes_ += pktsize
ns.txPktCount_ += 1
ns.txPktBytes_ += pktsize
elif cmd == 'r':
ns.rxPktCount_ += 1
ns.rxPktBytes_ += pktsize # + 7 (???)
elif cmd == 'd':
ns.dpPktCount_ += 1
ns.dpPktBytes_ += pktsize
if pkttype == 'exp':
ns.dpTcpPktCount_ += 1
ns.dpTcpPktBytes_ += pktsize
if why == 'err':
ns.errTcpPktCount_ += 1
f.close()
totalTcpPktCount = 0
totalTcpPktBytes = 0
totalPktCount = 0
totalPktBytes = 0
droppedPktBytes = 0
droppedPktCount = 0
droppedTcpPktBytes = 0
droppedTcpPktCount = 0
errTcpPktCount = 0
for i, ns in dictNodeStatistic.iteritems():
totalTcpPktCount += ns.txTcpPktCount_
totalTcpPktBytes += ns.txTcpPktBytes_
totalPktCount += ns.txPktCount_
totalPktBytes += ns.txPktBytes_
droppedPktBytes += ns.dpPktBytes_
droppedPktCount += ns.dpPktCount_
droppedTcpPktBytes += ns.dpTcpPktBytes_
droppedTcpPktCount += ns.dpTcpPktCount_
errTcpPktCount += ns.errTcpPktCount_
throughput = float(totalPktBytes) / 93 /1024
pps = float(totalTcpPktCount) / 93
print 'pps is', round(pps, 1)
print 'throughput is', round(throughput, 1), 'KBps'
print 'packet delivery ratio is',\
round(1 - float(droppedPktCount) / totalPktCount, 3) * 100, '%'
if __name__=="__main__":main()