Experiment 5: Create a LAN of 6 nodes in NS-2.35 Data Communication & Network Lab by Ravinder Nath Rajotiya - February 16, 2020April 6, 20200 Share on Facebook Share Send email Mail Print Print Table of Contents Toggle Experiment 5:Objective: To Create a LAN of 6 nodes in NS-2.35, attach the traffic and simulate using NAMOutcome:Introduction:AWK Script Experiment 5: Objective: To Create a LAN of 6 nodes in NS-2.35, attach the traffic and simulate using NAM Outcome: Students will be able to: Understand the algorithm Write the TcL Script Write the scenario simulate using NAM and analyse Write AWK to analyse the collecetd .tr database file Introduction: In Bus Network Topology a single cable is used to connect all devices on the net. This cable is often referred to as the network Backbone. When communication occurs between nodes the device sending the message broadcasts to all nodes on the network, but only the desired recipient digests the message. Advantages of this type of Physical Topology include ease of installation and minimization of the required cabling. Further, failure of a node attached to the network has no effect on other nodes attached to the network. Also messages from one node can be seen near simultaneously by all other nodes on the network. Disadvantages of this configuration include performance limits on the number of network nodes, and complete network communication stoppage if the cable fails Specification: LAN containing 6 node Use full-duplex link with 2 MB, 100ms and droptail Attach CBR traffic Store the complete network statistics in LAN-1.tr file TcL Script #Lan simulation set ns [new Simulator] #define color for data flows $ns color 1 Blue $ns color 2 Red #open tracefiles set tracefile1 [open out.tr w] set winfile [open winfile w] $ns trace-all $tracefile1 #open nam file set namfile [open out.nam w] $ns namtrace-all $namfile #define the finish procedure proc finish {} { global ns tracefile1 namfile $ns flush-trace close $tracefile1 close $namfile exec nam out.nam & exit 0 } #create six nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] $n1 color Red $n1 shape box #create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns simplex-link $n2 $n3 0.3Mb 100ms DropTail $ns simplex-link $n3 $n2 0.3Mb 100ms DropTail set lan [$ns newLan “$n3 $n4 $n5” 0.5Mb 40ms LL Queue/DropTail MAC/Csma/Cd Channel] #Give node position $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns simplex-link-op $n2 $n3 orient right $ns simplex-link-op $n3 $n2 orient left #set queue size of link(n2-n3) to 20 $ns queue-limit $n2 $n3 20 #setup TCP connection set tcp [new Agent/TCP/Newreno] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink/DelAck] $ns attach-agent $n4 $sink $ns connect $tcp $sink $tcp set fid_ 1 $tcp set packet_size_ 552 #set ftp over tcp connection set ftp [new Application/FTP] $ftp attach-agent $tcp #setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n5 $null $ns connect $udp $null $udp set fid_ 2 #setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 0.01Mb $cbr set random_ false #scheduling the events $ns at 0.1 “$cbr start” $ns at 1.0 “$ftp start” $ns at 124.0 “$ftp stop” $ns at 125.5 “$cbr stop” proc plotWindow {tcpSource file} { global ns set time 0.1 set now [$ns now] set cwnd [$tcpSource set cwnd_] puts $file “$now $cwnd” $ns at [expr $now+$time] “plotWindow $tcpSource $file” } $ns at 0.1 “plotWindow $tcp $winfile” $ns at 125.0 “finish” $ns run Figure 5.1: AWK Script Now To analyse the trace file for network performance we write the awk script. The script reads the .tr file and computes the data received, data lost, total transmission size. BEGIN { pktDropped=0; byteDropped=0; byteSent=0; bytesReceived=0; Total=0; } { if ($1==”+”) { byteSent += $6; } if($1==”r”) { bytesReceived += $6; } if($1==”d”) { pktDropped += 1; byteDropped += $6; } Total=bytesReceived + byteDropped; } END { printf(“\n Total bytes sent= %d\nno. of bytes received=%d\n no. of packets dropped=%d \n no. of bytes dropped=%d \n “,Total, bytesReceived, pktDropped, byteDropped); } The awk script is run as: $ awk –f lan-1.awk lan-1.tr Figure 5.2 AWK output Share on Facebook Share Send email Mail Print Print