day 2
TRANSCRIPT
04/08/2023
1
DAY 2 SESSION 1
Xavier’s Institute of Engineering, Mumbai
2
Session 1 Plan
04/08/2023
Wired Trace Format Analysis of wired trace Uni-cast Routing Simulation Network Dynamics Multicast Node Structure Multicast Routing Simulation Local Area Network
3
Wired file format
04/08/2023
Event
Time From-
Node
To-Node
Pkt-Type
Pkt-Size
Flags
Fid Src-addr
Dest-
addr
Seq-num
Pkt-id
- 1.06 0 2 tcp 1040
-------
1 0.0 3.0 2 124
r 1.07 1 2 cbr 1000
-------
2 1.0 3.1 120 122
+ 1.07 2 3 cbr 1000
-------
2 1.0 3.1 120 122
d 1.07 2 3 cbr 1000
-------
2 1.0 3.1 120 122
4
Analysis of Trace File (1)
Analysis 1 SimpleAWK.awk
awk –f SimpleAWK.awk out.tr > Temp Bytespersecond.awk
awk –f Bytespersecond.awk Temp > bps.tr xgraph File_th simple.gnu
gnuplot –persist simple.gnu Analysis 2
cwnd.awk awk –f cwnd.awk cwnd_rtt.tr > cwnd
cwnd.gnu gnuplot –persist cwnd.gnu
04/08/2023
5
Analysis of Trace File (2)
04/08/2023
Analysis 3 Third_script_analysis.awk
awk –f Third_script_analysis.awk out.tr
6
Unicast Routing Simulation (1)
04/08/2023
#Create Simulator Objectset ns [new Simulator]
#Define different colors for data flows (for NAM)$ns color 1 Blue$ns color 2 Red
#Open the Trace fileset file1 [open out.tr w]$ns trace-all $file1
#Open the NAM trace fileset file2 [open out.nam w]$ns namtrace-all $file2
7
Unicast Routing Simulation (2)
04/08/2023
#Define a 'finish' procedureproc finish {} { global ns file1 file2 $ns flush-trace close $file1 close $file2 exec nam out.nam & exit 0}
# Uni-cast Routing as DV$ns rtproto DV
8
Unicast Routing Simulation (3)
04/08/2023
#Create six nodesset n0 [$ns node]set n1 [$ns node]set n2 [$ns node]set n3 [$ns node]set n4 [$ns node]set n5 [$ns node]
#Create links between the nodes$ns duplex-link $n0 $n1 0.3Mb 10ms DropTail$ns duplex-link $n1 $n2 0.3Mb 10ms DropTail$ns duplex-link $n2 $n3 0.3Mb 10ms DropTail$ns duplex-link $n1 $n4 0.3Mb 10ms DropTail$ns duplex-link $n3 $n5 0.5Mb 10ms DropTail$ns duplex-link $n4 $n5 0.5Mb 10ms DropTail
9
Unicast Routing Simulation (4)
04/08/2023
#Give node position (for NAM)$ns duplex-link-op $n0 $n1 orient right$ns duplex-link-op $n1 $n2 orient right$ns duplex-link-op $n2 $n3 orient up$ns duplex-link-op $n1 $n4 orient up-left$ns duplex-link-op $n3 $n5 orient left-up$ns duplex-link-op $n4 $n5 orient right-up
#Setup a TCP connectionset tcp [new Agent/TCP/Newreno]$ns attach-agent $n0 $tcpset sink [new Agent/TCPSink/DelAck]$ns attach-agent $n5 $sink$ns connect $tcp $sink$tcp set fid_ 1
10
Unicast Routing Simulation (5)
04/08/2023
#Setup a FTP over TCP connectionset ftp [new Application/FTP]$ftp attach-agent $tcp$ftp set type_ FTP
#Network Dynamics$ns rtmodel-at 1.0 down $n1 $n4$ns rtmodel-at 4.5 up $n1 $n4
#Scheduling Events$ns at 0.1 "$ftp start“$ns at 6.0 "finish"
#Running a simulation$ns run
Unicast1_dv.tcl
11
More About Uni-cast Routing (1)
04/08/2023
Static route strategy$ns rtproto Static
Session Routing$ns rtproto Session
Distance Vector Routing$ns rtproto DV
Link State$ns rtproto LS
12
More About Uni-cast Routing (2)
04/08/2023
Manual Routing$ns rtproto Manualset n1 [$ns node]set n2 [$ns node]$ns duplex-link $n1 $n2 10Mb 100ms
DropTail$n1 add-route-to-adj-node -default $n2$n2 add-route-to-adj-node -default $n1
13
Network Dynamics
04/08/2023
Deterministic and Exponential $ns rtmodel Deterministic { start_time
up_interval down_interval finish_time} By Default,
start_time: 0.5sec from beginning of the simulation up_interval: 10sec down_interval: 1sec finish_time: end of the simulation
Node Failure $ns rtmodel-at 1.0 down $n1
Multicast Node Structure
04/08/2023
14
Agent
Agent
Mult
icast
C
lass
ifier
Agent
Link Link
Node Entry
entry_
switch_
classifier_
dmux_
Replicators
agents_
15
Multicast Routing Simulation (1)
04/08/2023
# Create simulator Object set ns [new Simulator]
# Command to specify multicasting$ns multicast
# Open the trace fileset f [open out.tr w]$ns trace-all $f
# Open the nam file$ns namtrace-all [open out.nam w]
# Define the color$ns color 1 red# the nam colors for the prune packets$ns color 30 purple# the nam colors for the graft packets$ns color 31 green
16
Multicast Routing Simulation (2)
04/08/2023
# allocate a multicast address set group [Node allocaddr]
# nod is the number of nodes set nod 6
# create multicast capable nodes for {set i 1} {$i <= $nod} {incr i}
{
set n($i) [$ns node] }
17
Multicast Routing Simulation (3)
04/08/2023
# Create links between the nodes$ns duplex-link $n(1) $n(2) 0.3Mb 10ms DropTail $ns duplex-link $n(2) $n(3) 0.3Mb 10ms DropTail$ns duplex-link $n(2) $n(4) 0.5Mb 10ms DropTail$ns duplex-link $n(2) $n(5) 0.3Mb 10ms DropTail$ns duplex-link $n(3) $n(4) 0.3Mb 10ms DropTail$ns duplex-link $n(4) $n(5) 0.5Mb 10ms DropTail$ns duplex-link $n(4) $n(6) 0.5Mb 10ms DropTail$ns duplex-link $n(5) $n(6) 0.5Mb 10ms DropTail
# Configure multicast protocolset mproto DM
# All nodes will contain multicast protocol agentsset mrthandle [$ns mrtproto $mproto]
18
Multicast Routing Simulation (4)
04/08/2023
# Create and attach UDP agent and attach it to node set udp1 [new Agent/UDP] set udp2 [new Agent/UDP] $ns attach-agent $n(1) $udp1$ns attach-agent $n(2) $udp2
# Create CBR Agentset src1 [new Application/Traffic/CBR]$src1 attach-agent $udp1$udp1 set dst_addr_ $group$udp1 set dst_port_ 0$src1 set random_ falseset src2 [new Application/Traffic/CBR]$src2 attach-agent $udp2$udp2 set dst_addr_ $group$udp2 set dst_port_ 1$src2 set random_ false
19
Multicast Routing Simulation (5)
04/08/2023
# Create receiver agentsset rcvr [new Agent/LossMonitor]
# Joining and leaving the group$ns at 0.6 "$n(3) join-group $rcvr $group"$ns at 1.3 "$n(4) join-group $rcvr $group"$ns at 1.6 "$n(5) join-group $rcvr $group"$ns at 1.9 "$n(4) leave-group $rcvr $group"$ns at 2.3 "$n(6) join-group $rcvr $group"$ns at 3.5 "$n(3) leave-group $rcvr $group“
# Schedule the event$ns at 0.4 "$src1 start"$ns at 2.0 "$src2 start"
20
Multicast Routing Simulation (6)
04/08/2023
# Call the finish procedure$ns at 4.0 "finish"
# Definition of finish procedure proc finish {} { global ns $ns flush-trace exec nam out.nam & exit 0}
# Run the simulation$ns run Multicast1_pimd
m.tcl
21
LAN Simulation (1)
04/08/2023
# Create Simulator Objectset ns [new Simulator]
#Define different colors for data flows (for NAM)$ns color 1 Blue$ns color 2 Red
#Open the Trace filesset file1 [open out.tr w]set winfile [open WinFile w]$ns trace-all $file1
#Open the NAM trace fileset file2 [open out.nam w]$ns namtrace-all $file2
22
LAN Simulation (2)
04/08/2023
#Define a 'finish' procedureproc finish {} { global ns file1 file2 $ns flush-trace close $file1 close $file2 exec nam out.nam & exit 0}
#Create six nodesset n0 [$ns node]set n1 [$ns node]set n2 [$ns node]set n3 [$ns node]set n4 [$ns node]set n5 [$ns node]
23
LAN Simulation (3)
04/08/2023
# Node color and shape$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
# Define LANset lan [$ns newLan "$n3 $n4 $n5" 0.5Mb 40ms LL
Queue/DropTail MAC/Csma/Cd Channel]
24
LAN Simulation (4)
04/08/2023
#Set Queue Size of link (n2-n3) to 10$ns queue-limit $n2 $n3 10
#Setup a TCP connectionset tcp [new Agent/TCP/Newreno]$ns attach-agent $n0 $tcpset sink [new Agent/TCPSink/DelAck]$ns attach-agent $n4 $sink$ns connect $tcp $sink$tcp set fid_ 1$tcp set window_ 8000$tcp set packetSize_ 552
#Setup a FTP over TCP connectionset ftp [new Application/FTP]$ftp attach-agent $tcp$ftp set type_ FTP
25
LAN Simulation (5)
04/08/2023
#Setup a UDP connectionset udp [new Agent/UDP]$ns attach-agent $n1 $udpset null [new Agent/Null]$ns attach-agent $n5 $null$ns connect $udp $null$udp set fid_ 2
#Setup a CBR over UDP connectionset 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
26
LAN Simulation (6)
04/08/2023
# Scheduling the event$ns at 0.1 "$cbr start"$ns at 1.0 "$ftp start"$ns at 124.0 "$ftp stop"$ns at 124.5 "$cbr stop"
# Call finish procedure$ns at 125.0 "finish“
# Run simulation$ns run
LAN.tcl
30
DAY 2SESSION 2Xavier’s Institute of Engineering , Mumbai
04/08/2023
31
Session 2 Plan
04/08/2023
Mobile / Wireless Node Structure Wireless Simulation Script Radio Propagation Model Wireless Trace Formats Analysis of Wireless Scenario Assignment and Practice
32
Mobile/Wireless Node Structure
04/08/2023
Classifier:Forwarding
Agent: Protocol Entity
Node Entry
Node
ARP
Radio Propagation Model
MobileNode
LL
MAC
PHY
LL
CHANNEL
LL
MAC
LL:Link layer objectIFQ:Interface queueMAC:Mac object
PHY PHY:Net interface
Routing
33
Wireless Simulation Script (1)
04/08/2023
set val(chan) Channel/WirelessChannel ;# channel typeset val(prop) Propagation/TwoRayGround ;# radio-propagation modelset val(netif) Phy/WirelessPhy ;# network interface typeset val(mac) Mac/802_11 ;# MAC typeset val(ifq) Queue/DropTail/PriQueue ;# interface queue typeset val(ll) LL ;# link layer typeset val(ant) Antenna/OmniAntenna ;# antenna modelset val(ifqlen) 50 ;# max packet in ifqset val(nn) 3 ;# number of mobilenodesset val(rp) AODV ;# routing protocolset val(x) 500 ;# X dimension of topographyset val(y) 400 ;# Y dimension of topographyset val(stop) 110 ;# time of simulation end
34
Wireless Simulation Script (2)
04/08/2023
#Create a ns simulatorset ns [new Simulator]
#Setup topography objectset topo [new Topography]$topo load_flatgrid $val(x) $val(y)create-god $val(nn)
#Open the NS trace fileset tracefile [open wireless.tr w]$ns trace-all $tracefile
#Open the NAM trace fileset namfile [open wireless.nam w]$ns namtrace-all $namfile$ns namtrace-all-wireless $namfile $val(x) $val(y)set chan [new $val(chan)] ;#Create wireless channel
35
Wireless Simulation Script (3)
04/08/2023
# Mobile Node Parameter Setup$ns node-config -adhocRouting $val(rp) \ -llType $val(ll) \ -macType $val(mac) \ -ifqType $val(ifq) \ -ifqLen $val(ifqlen) \ -antType $val(ant) \ -propType $val(prop) \ -phyType $val(netif) \ -channel $chan \ -topoInstance $topo \ -agentTrace OFF \ -routerTrace OFF\ -macTrace ON \ -movementTrace ON
36
Wireless Simulation Script (4)
04/08/2023
#Create 3 nodes
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
}
# Provide location of mobile nodes
$node_(0) set X_ 5.0
$node_(0) set Y_ 5.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 490.0
$node_(1) set Y_ 285.0
$node_(1) set Z_ 0.0
$node_(2) set X_ 150.0$node_(2) set Y_ 240.0$node_(2) set Z_ 0.0
37
Wireless Simulation Script (5)
04/08/2023
# Generation of movements$ns at 10.0 "$node_(0) setdest 250.0 250.0
3.0"$ns at 15.0 "$node_(1) setdest 45.0 285.0
5.0"$ns at 110.0 "$node_(0) setdest 480.0 300.0
5.0"
38
Wireless Simulation Script (6)
04/08/2023
# Set a TCP connection between node_(0) and node_(1)set udp [new Agent/UDP]set sink [new Agent/Null]$ns attach-agent $node_(0) $udp$ns attach-agent $node_(1) $sink$ns connect $udp $sinkset cbr [new Application/Traffic/CBR]$cbr attach-agent $udp$cbr set interval_ 1$cbr set maxpkts_ 100$ns at 10.0 "$cbr start"
39
Wireless Simulation Script (7)
04/08/2023
# Define node initial position in namfor {set i 0} {$i < $val(nn)} { incr i } {# 30 defines the node size for nam$ns initial_node_pos $node_($i) 30}
# Telling nodes when the simulation endsfor {set i 0} {$i < $val(nn) } { incr i } { $ns at $val(stop) "$node_($i) reset";}
40
Wireless Simulation Script (8)
04/08/2023
# Ending nam and the simulation $ns at $val(stop) "$ns nam-end-wireless $val(stop)"$ns at $val(stop) "stop"$ns at 110.01 "puts \"end simulation\" ; $ns halt“
# Stop Procedureproc stop {} { global ns tracefd namtrace $ns flush-trace close $tracefd close $namtrace}
# Run simulation $ns run
wireless1.tcl
41
Common Simulation Parameter
04/08/2023
#Simulation parameters setupAntenna/OmniAntenna set Gt_ 1 ;#Transmit antenna gainAntenna/OmniAntenna set Gr_ 1 ;#Receive antenna gainPhy/WirelessPhy set L_ 1.0 ;#System Loss FactorPhy/WirelessPhy set freq_ 2.472e9 ;#channelPhy/WirelessPhy set bandwidth_ 11Mb ;#Data RatePhy/WirelessPhy set Pt_ 0.031622777 ;#Transmit PowerPhy/WirelessPhy set CPThresh_ 10.0 ;#Collision ThresholdPhy/WirelessPhy set CSThresh_ 5.011872e-12 ;#Carrier Sense PowerPhy/WirelessPhy set RXThresh_ 5.82587e-09 ;#Receive Power
ThresholdMac/802_11 set dataRate_ 11Mb ;#Rate for Data FramesMac/802_11 set basicRate_ 1Mb ;#Rate for Control Frames
42
Radio Propagation Model (1)
04/08/2023
Free Space Model $ns_ node-config -propType
Propagation/FreeSpace set prop [new Propagation/FreeSpace]
$ns_ node-config -propInstance $prop Two Ray Ground
$ns_ node-config -propType Propagation/TwoRayGround
set prop [new Propagation/TwoRayGround]$ns_ node-config -propInstance $prop
43
Radio Propagation Model (2)
04/08/2023
Shadowing model # first set values of shadowing model
Propagation/Shadowing set pathlossExp_ 2.0 ;# path loss exponentPropagation/Shadowing set std_db_ 4.0 ;# shadowing deviation (dB)Propagation/Shadowing set dist0_ 1.0 ;# reference distance (m)Propagation/Shadowing set seed_ 0 ;# seed for RNG$ns_ node-config -propType Propagation/Shadowing
# Another Methodset prop [new Propagation/Shadowing]$prop set pathlossExp_ 2.0$prop set std_db_ 4.0$prop set dist0_ 1.0$prop seed <seed-type> 0 ;# user can specify seeding method$ns_ node-config -propInstance $prop
44
Wireless Trace Format
04/08/2023
Wireless Trace File Format New trace format
$ns use-newtrace
04/08/2023
45
Analysis using AWK Script
Packet_dealy.awk awk –f Packet_dealy.awk wireless1.awk
Analysis using grep grep pattern infile > outfile
04/08/2023
46
Assignment
Task 1: Measure and compare the end-to-end delay
and packet delivery ratio of Day 1 task2 topologies.
Task 2: Run “wireless1.tcl” ten times with different
time interval and generate ten different files. Apply “Packet_delay.awk” to ten files and note down the value came in separate files. Draw the graph by using this values.