分类: LINUX
2012-11-22 18:21:16
$ cat out.tr | grep "DSR" | wc -lThe result is 3301 dsr packets for a 1000 seconds, 50 nodes 10 connections, 4pkt/sec, 512B size, 670X670 area, mobility speed is at most 20m/s and the average pause time is 600 seconds.
$cat out.tr |grep "^s.*DSR" | wc -lshows only 514 DSR packets are sending.
BEGIN {pktno = 0; byte = 0;} $1~/s/ && /DSR/ { pktno ++ byte+=$8 }
BEGIN {pktno = 0; byte = 0;} $1~/s/ && /DSR/ { pktno ++ byte+=$8 } $1~/f/ && /DSR/ { pktno ++ byte+=$8 } END { print ( pktno, byte) }This shows: "806 packets 43696 bytes". Because, the concern is the time spent to send routing signaling, this is more accurate way to measure routing overhead.
BEGIN {dsrpktno = 0; dsrbyte = 0; cbrpktno = 0; cbrbyte = 0; } $1~/s/ && /DSR/ && /MAC/ { dsrpktno ++ ; dsrbyte+=$8 ;} $1~/s/ && /cbr/ && /MAC/ { cbrpktno ++ ; cbrbyte+=$8; } END { print ( dsrpktno, dsrbyte , cbrpktno, cbrbyte) }
Another definition is "Normalized Routing Overhead".
Normalized routing load is the number of routing packets transmitted per data packet sent to the destination. Also each forwarded packet is counted as one transmission. This metric is also highly correlated with the number of route changes occurred in the simulation.
The Perl script to calculate this is ( thanks to Umut Akyol )
#!/usr/bin/perl
$src = out7;
my $rte_overhead = 0;
my $num_rte_pkt = 0;
my $num_data_pkt = 0;
open(INPUTFILE,$src) || die "Cannot open file\n";
$line = ;
while ($line ne "") {
@input = split(/ /,$line);
if ($input[0] =~ m/s/ && $input[3] =~ m/RTR/ && $input[7] =~ m/AODV/) {
#print "A routing packet was sent\n";
$num_rte_pkt = $num_rte_pkt + 1;
}
if ($input[0] =~ m/f/ && $input[3] =~ m/RTR/ && $input[7] =~ m/AODV/) {
#print "A routing packet was forwarded\n";
$num_rte_pkt = $num_rte_pkt + 1;
}
if ($input[0] =~ m/s/ && $input[3] =~ m/RTR/ && $input[7] =~ m/cbr/) {
#print "A data packet was sent\n";
$num_data_pkt = $num_data_pkt + 1;
}
if ($input[0] =~ m/f/ && $input[3] =~ m/RTR/ && $input[7] =~ m/cbr/) {
#print "A data packet was forwarded\n";
$num_data_pkt = $num_data_pkt + 1;
}
$line = ;
}
close(INPUTFILE);
if ($num_data_pkt == 0) {
print "No data sent!\n";
} else {
print "Routing overhead is ", $num_rte_pkt/$num_data_pkt, "\n";
}
Note that to calculate DATA packets we can both in layer 2 ("MAC") or layer 3 (RTR) from trace file. But if there are some cut-through or fast forward happened in the layer 2, the packet does not go to layer 3. Using RTR will yield wrong statistics.
The following AWK code to get all sending and receiving in Agent level is
BEGIN {counter1 = 0; counter2 = 0;}
$1~/s/ && /AGT/ { counter1 ++ }
$1~/r/ && /AGT/ { counter2 ++ }
END { print ( counter1, counter2) }
Then execute$awk -f awkcode1 out.trit shows 2236 2213. Thus, most packets are received.