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

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to use Loss Monitor in NS2?

Description

Loss Monitor is attached with receiver node in TCL script. Loss Monitor objects trace out the lost packets, and received packets and stores the corresponding details. Packet Loss is measured by accessing the loss monitor object. Received bytes are obtained using inbuilt variable bytes

Sample Code

#Filename: sample13.tcl

#**************** Multiple node Creation and communication model using UDP (User Datagram Protocol) and LOSS MONITIOR ***************************

#******************************Defining Communication Between node0 and all nodes ****************************
puts $r "TIME\t\tNODEID\t\tRECEIVED_BYTES"

proc calling { } {

global node_ ns r lm

set now [$ns now]

set time 3.0
for {set i 1} {$i < 10} {incr i} {
set udp [new Agent/UDP]
$ns attach-agent $node_(0) $udp

set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 512
$cbr set interval_ 0.07
$cbr attach-agent $udp

set lm($i) [new Agent/LossMonitor]
$ns attach-agent $node_($i) $lm($i)

$ns connect $udp $lm($i)
$ns at $now "$cbr start"
$ns at [expr $now + $time] "$cbr stop"

}
}
proc data { } {

global node_ ns lm r

set now [$ns now]

for {set i 1} {$i < 10} {incr i} {

set rd [$lm($i) set bytes_]
puts $r "$now received_bytes of node $i = $rd"

}
}

Screenshots

How to Loss Monitor
Loss Monitor in NS2