0% found this document useful (0 votes)
26 views12 pages

229 WMN Activity 2

Uploaded by

Kok Lol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views12 pages

229 WMN Activity 2

Uploaded by

Kok Lol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Name : Parth Wattamwar

Class : WMN
PRN : 202101040251

Activity 2

Self Evaluation:
1.Exercise 1

#
set val(chan) Channel/WirelessChannel ;#Channel Type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 3 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 500
set val(y) 500
#set val(scene)
"/home/barun/Desktop/ns2/ns-2.34/indep-utils/cmu-scen-gen/setdest/ant/scene-3n-2" set
val(stop) 70.0 ;# simulation time
# Initialize Global Variables set
ns_ [new Simulator]
$ns_ use-newtrace
set tracefd [open wireless2.tr w]
$ns_ trace-all $tracefd

# set up topography object


set topo [new Topography]
$topo load_flatgrid $val(x) $val(y) #
Create God
set god_ [create-god $val(nn)]
# New API to config node:
# 1. Create channel (or multiple-channels);
# 2. Specify channel in node-config (instead of channelType); # 3.
Create nodes for simulations.
# Create channel #1 and #2 set
chan_1_ [new $val(chan)] set
chan_2_ [new $val(chan)]
# Create node(0) "attached" to channel #1
# configure node, please note the change below.
$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) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON \
-channel $chan_1_ set
node_(0) [$ns_ node]
# node_(1) can also be created with the same configuration, or with a different #
channel specified.
# Uncomment below two lines will create node_(1) with a different channel. # $ns_
node-config \
# -channel $chan_2_
set node_(1) [$ns_ node]
set node_(2) [$ns_ node]
$node_(0) random-motion 0
$node_(1) random-motion 0
$node_(2) random-motion 0
#
# Define traffic model #
puts "Loading scenario file..." #source
$val(scene)
# nodes: 3, speed type: 1, min speed: 1.00, max speed: 15.00
# avg speed: 4.97, pause type: 1, pause: 2.00, max x: 500.00, max y: 500.00 #
$node_(0) set X_ 454.060071018640
$node_(0) set Y_ 403.968538862061
$node_(0) set Z_ 0.000000000000
$node_(1) set X_ 22.178026058951
$node_(1) set Y_ 243.738350737276
$node_(1) set Z_ 0.000000000000
$node_(2) set X_ 371.008451369069
$node_(2) set Y_ 185.301693166316
$node_(2) set Z_ 0.000000000000
$ns_ at 0.000000000000 "$node_(0) setdest 356.793785866608 11.405992524802
3.552472957623"
$ns_ at 0.000000000000 "$node_(1) setdest 238.321861617953 391.660135696947
11.421343547674"
$ns_ at 0.000000000000 "$node_(2) setdest 146.063853609674 445.314010285147
9.794277769329"
$god_ set-dist 0 1 16777215
$god_ set-dist 0 2 1
$god_ set-dist 1 2 16777215
$ns_ at 6.588983535475 "$god_ set-dist 0 1 2"
$ns_ at 6.588983535475 "$god_ set-dist 1 2 1"
$ns_ at 17.739115189630 "$god_ set-dist 0 1 1"
$ns_ at 22.931989576748 "$node_(1) setdest 238.321861617953 391.660135696947
0.000000000000"
$ns_ at 24.931989576748 "$node_(1) setdest 320.540534372542 254.623600971352
7.991026077916"
$ns_ at 55.931989576748 "$node_(2) setdest 290.540534372542 254.623600971352
5.991026077916"
$ns_ at 27.621738856783 "$god_ set-dist 0 1 1"
$ns_ at 27.621738856783 "$god_ set-dist 1 2 1"
$ns_ at 27.621738856783 "$god_ set-dist 0 2 2" #
# Destination Unreachables: 2 #
# Route Changes: 4 #
# Link Changes: 3 #
# Node | Route Changes | Link Changes
# 0| 3| 2
# 1| 3| 2
# 2| 2| 2

$ns_ at 35 "$god_ set-dist 0 2 2" #


Nodes and their sizes
for {set i 0} {$i < $val(nn)} {incr i} {
#$node_($i) random-motion 0
$ns_ initial_node_pos $node_($i) 20
}
# Setup traffic flow between nodes
# TCP connections between node_(0) and node_(1)

set tcp [new Agent/TCP]


$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp
$ns_ attach-agent $node_(2) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 3.0 "$ftp start"
#
# Tell nodes when the simulation ends #
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at $val(stop) "$node_($i) reset";
}
$ns_ at $val(stop) "stop"
$ns_ at $val(stop) "puts \"NS EXITING...\" ; $ns_ halt" proc stop {}
{
global ns_ tracefd
$ns_ flush-trace
close $tracefd
}
puts "Starting Simulation..."
$ns_ run
Exercise

Exercise 2 :
Output:
Solution

Screenshot

Results & Discussions


Solution for the exercise #2 is given below:
# Create a new simulator object. set
ns [new Simulator]

# ----- Setup wireless environment. ----


set wireless_tracefile [open dsr-6-nodes.tr w] #
Use new trace format
$ns use-newtrace
set topography [new Topography]
$ns trace-all $wireless_tracefile
$topography load_flatgrid 700 700 #
# Create God #
set god_ [create-god 6]
#global node setting
$ns node-config -adhocRouting DSR \
-llType LL \
-macType Mac/802_11 \
-ifqType CMUPriQueue \
-ifqLen 50 \
-antType Antenna/OmniAntenna \
-propType Propagation/TwoRayGround \
-phyType Phy/WirelessPhy \
-channel [new Channel/WirelessChannel] \
-topoInstance $topography \
-agentTrace ON \
-routerTrace OFF \
-macTrace ON
# Create wireless nodes set
node(0) [$ns node]
$node(0) set X_ 150
$node(0) set Y_ 300
$node(0) set Z_ 0.0
$node(0) color "black"
$ns initial_node_pos $node(0) 30.000000
set node(1) [$ns node]
$node(1) set X_ 300
$node(1) set Y_ 500
$node(1) set Z_ 0.0
$node(1) color "black"
$ns initial_node_pos $node(1) 30.000000
set node(2) [$ns node]
$node(2) set X_ 500
$node(2) set Y_ 500
$node(2) set Z_ 0.0
$node(2) color "black"
$ns initial_node_pos $node(2) 30.000000
set node(3) [$ns node]
$node(3) set X_ 300
$node(3) set Y_ 100
$node(3) set Z_ 0.0
$node(3) color "black"
$ns initial_node_pos $node(3) 30.000000
set node(4) [$ns node]
$node(4) set X_ 500
$node(4) set Y_ 100
$node(4) set Z_ 0.0
$node(4) color "black"
$ns initial_node_pos $node(4) 30.000000
set node(5) [$ns node]
$node(5) set X_ 650
$node(5) set Y_ 300
$node(5) set Z_ 0.0
$node(5) color "black"
$ns initial_node_pos $node(5) 30.000000
# Node movement patterns
# $ns at 30 "$node(0) setdest 150.0 450.0 1.5"
$ns at 4.0 "$node(3) setdest 300.0 500.0 5.0"
$ns at 4.0 "$god_ set-dist 0 5 3"
# Create links between nodes. #
Add Link Loss Models
# Create agents.
set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node(0) $tcp
$ns attach-agent $node(5) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 3.0 "$ftp start"
#
# Tell nodes when the simulation ends #
for {set i 0} {$i < 6 } {incr i} {
$ns at 60.000000 "$node($i) reset";
}
# Connect agents.
# Run the simulation
proc finish {} {
global ns
$ns flush-trace exit
0
}
$ns at 60.000000 "finish"
$ns run

Analyze the trace file and determine when the use of second route commence
Here the node 0 is the source node and node 5 is the destination node. Initially data moves
from node 0 to node 5 through the route 0-3-4-5. This movement begins at time 3.080088359
as shown below.
SFESTs 3.080088359 _0_ 0 [0 -> 5] 1(1) to 3 [0 |3 4 5 ]
• The first field is Established Flowstate (SFEST)
• The second field is the time
• The third field is the node number
• The fourth field is the Header UID
• The fifth field is the source
• The sixth field is the destination
• The next field is the Flow ID and Flow Header
• The next number is the next hop id.
• The next numbers in the square brackets concerns the adresses through which the
data travels to destination.
The above trace indicates flowstate established from source 0 to destination 5 with 3 is the
next hop address through the route 0-3-4-5.
When we see 'D' or SSendFailure in the first field of trace and node number '3' or '4' or '5' in
the -Hs field of the trace(as shown below), then the existing route breaks and data will not
reach to the destination.
d -t 34.114865014 -Hs 3 -Hd -2 -Ni 3 -Nx 300.00 -Ny 250.57 -Nz 0.00 -Ne -
1.000000 -Nl MAC -Nw RET -Ma 256e -Md 4 -Ms 3 -Mt 0

SSendFailure 34.114865014 _3_ 1659 0 0:0 5:0 3->4 0 3 0 4 [0 |3 4 5 ]


• The first field is Send Failure (SSendFailure)
• The second field is the time
• The third field is the node number
• The fourth field is the Header UID
• The fifth field is the protocol type
• The sixth field is the Source : Source port
• The next field is the Destination : Destination port
• After this is the Flow ID and Flow Header
• The next number is the number of Hops: From -> To
• The next field is the number of Hops: Source -> Destination
• The next field is the number of Hops: From -> Destination
• The next number is the number of Addresses
• The next numbers in the square brackets concerns the adresses through which the
data travels to destination.
So roughly in 31.000212318 time data moves from node 0 to 5 through the route 0- 3-4-5.
The Second route commence at time 34.249896832 when we see flowstate established
from 0(source) to 5(destination) with the next hop 3 through the route 0- 1-2-5 as shown
below.
SFESTs 34.249896832 _0_ 1712 [0 -> 5] 3(1) to 1 [0 |1 2 5 ]
For detail explanation of DSR trace formats follow the link given below
http://nsnam.isi.edu/nsnam/index.php/NS-2_Trace_Formats
Plot the number of packets received by each node over the entire time duration of the
simulation
• Choose the tool Trace File Analysis and select wireless (New) simulation mode.
• As per the question given, choose the statistics “Byte Recieved” for plotting the
number of packets received by each node.
• For example, enter node number 5 and choose MAC, RTR and AGT layer and then
select plot.Similarly plot for node number 3 and 1.
• The above graph is shown for byte received by node number 1, 3 and 5.Initially TCP
connection is intiated between node 0 and 5 through node 3,4.At time 34.114865014
TCP connection breaks between node 0 and node3 and second route commence from
node 0 to node 5 via node 1,2 at time 34.249896832.So the above graph shows byte
received by node 3 is starts from time 3.009523851 to 34.114865014 and byte received
by node 1 is starts at time 34.249896832.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy