Research breakthrough possible @S-Logix pro@slogix.in

Office Address

Social List

How to calculate routing overhead for wired network using awk script in NS2?

Description

Routing Overhead is the number of routing packets required for network communication. Routing Overhead is calculated using awk script which processes the trace file and produces the result.

Sample Code

# Filename: test13.tcl

$ns rtproto LS

# —————-ESTABLISHING COMMUNICATION ————-#

#————–TCP CONNECTION BETWEEN NODES—————#

$ns at 0.0 "Tranmission"
proc Tranmission {} {
global C ROU R ns

set now [$ns now]
set time 10.0
set x 3
set y 4

set tcp1 [$ns create-connection TCP $C($x) TCPSink $R($y) 1]
$ns at $now "$ns trace-annotate \"Time: $now Pkt Transfer between Client($x) Receiver($y)..\""
$tcp1 set class_ 1
$tcp1 set maxcwnd_ 16
$tcp1 set packetsize_ 4000
$tcp1 set fid_ 1
set ftp1 [$tcp1 attach-app FTP]
$ftp1 set interval_ .005
$ns at $now "$ftp1 start"
$ns at [expr $now+$time] "$ftp1 stop"

}

###################################################################

#filename: RoutingOverhead.awk

#——— Formula ————:

Routing Overhead = RoutingPacketsCount

#——— AWK script Format——–#

The script has the following format:
BEGIN {}
{
content
}
END {}
Begin part comprises of initialization of variable.
Commands in the content part scan every row of trace file only once.
Ex:
if (pattern) {
action;
}

If the pattern is matched with the line in the trace in the trace file specified action will be performed.

In the END part final calculation is performed on the data obtained from the content part.

#——— Steps ————:
1. set pattern and action for routing packets

Screenshots

Routing process

file: output.tr
Routing Overhead = 264 packets


calculate routing overhead for wired network using awk script in NS2