- ›
- Forums ›
- Get Help to do your B.E., and M.E., M.Tech., & M.S., Project in Ns2 ›
- number of packets received is more than the packets sent
refer the following answer provided in the following link.
http://www.projectguideline.com/modules.php?name=Forums&file=viewtopic&p=452#452
@CharlesPandian wrote:
Try to eanable the new trace format of ns2 before simulation.
While doing trace analysis, filter sent or recieved packet from suitable layer (MAC / Routing / AGT). This will avoid false counts.
Still, there are chances for getting high received count due to duplicates. We can isolate duplicates them using the unique packet ID.
You have to count from AGT to AGT like this:
#PERL CODE PORTION
while () {
if (/AGT/ && /^s/){
$agtsent++;
} elsif (/AGT/ && /^r/) {
$agtrcv++;
}
}
hi,
i think the reason behind this is because AODV send a broadcast route request message (RREQ) i.e. 1 RREQ sent, and you get RREP (route reply) from all its neighbouring nodes.
so if you want to count the number of successfully received msg, you should specify the packet size (payload) of interest.
i found this AWK script which might be useful:
BEGIN {
recvdSize = 0
startTime = 1e6
stopTime = 0
}
{
# Trace line format: normal
if ($2 != “-t”) {
event = $1
time = $2
node_id = $3
flow_id = 0
pkt_id = $7 ;#seq no
pkt_size = $9
flow_t = $8
level = $4
dreason = $6
}
# Trace line format: new ($ns_ use-newtrace)
if ($2 == “-t”) {
event = $1
time = $3
node_id = $5
flow_id = $39
pkt_id = $41
pkt_size = $37
flow_t = $35
level = $19
}
# Store packets send time & count #packets sent
if (level == “AGT” && flow_id == flow &&
sendTime[pkt_id]==0 && (event == “+” || event == “s”) && pkt_size >= pkt) {
if (time < startTime) {
startTime = time
}
sendTime[pkt_id] = time
this_flow = flow_t
sendNum ++
}
# Update total received packets’ size and store packets arrival time
if (level == “AGT” && flow_id == flow && event == “r” && pkt_size >= pkt) {
if (time > stopTime) {
stopTime = time
}
# Rip off the header
hdr_size = pkt_size % pkt
pkt_size -= hdr_size
# Store received packet’s size
recvdSize += pkt_size
# Store packet’s reception time
recvTime[pkt_id] = time
}
}
END {
for (i in recvTime) {
if (sendTime == 0) {
printf(“nErrorn”,i)
}
delay += recvTime – sendTime
recvdNum ++
}
printf(” %15s: %gn”, “sendPkts”, sendNum)
printf(” %15s: %gn”, “receivedPkts”, recvdNum)
}
Discuss Through WhatsApp