Network Simulator Project
Network Simulator Project
“Earthquake”
Spring 2004
Page 1 / 15
Plan
1. Introduction
2. Proposal
3. Design
4. Observations
a. Changing Traffic Sources
b. Changing Queue Type
c. Changing Record Interval
5. Listing
6. Bibliography
Page 2 / 15
1 Introduction
The aim of this project is to simulate a dynamic network and examine the results of several
unattended effects to the flow. ISI Network Simulator (a.k.a. NS) simulates the network,
XGraph takes the flow graphics and ISI Network Animator (a.k.a. NAM) presents the
visualization.
The environment used to realize the simulation is a RedHat Linux 9.0 running with Linux
Kernel 2.6.5 on an Intel Pentium III 550 MHz with 128 MB SDRAM. NS 2.27, NAM 1.10,
XGraph 12.1, OTCL 1.8, TCL 8.4.5, TCLCL 1.15, TK 8.4.5, XGraph-12.1, Zlib 1.1.4 are
used and all are installed by “ns-all-in-one” package with version number 2.27, which is
downloaded from “http://www.isi.edu.tr/ns-nam”.
The main reference to learn NS was Marc Greis’ Tutorial, which is also shipped with NS
package. Some of the listing is taken from its tutorial.
Page 3 / 15
2 Proposal
In our network, it happens an earthquake and because of this and its continuing shocks,
several links are broken in time. The initial design of city network was as fallowing:
Internet
Telecom (ISP)
1
City
Earthquake
University’s
3 4 Research Lab
Satelite
Connection
2
Academic
Staff Residence
The academic staff, which is in their staff residence, wants to make videoconference over the
Internet in order to consulate with other academics in the world about the earthquake and
make vital decisions for the city safe. But how they could do this while everything goes
down?
All links are the same and have 1MB capacity, 100ms delay and a DropTail queue. Node 2, 3
and 4 are Constant Bit Rate (CBR) UDP sources and are generating an Expoo traffic versus
the node 0.
The total simulation time is 5 seconds. When the simulation starts, all three sources also start
producing packets. But after 0.5 second, the link 03 fails and after 0.5 second from this
incident, link 12 also stops transmitting. The catastrophe is continuing and after 2 second
from the beginning, link 23 breaks down. Now is our network as above:
Page 4 / 15
Figure 2.2: Network after 2 seconds.
Then, the engineers finish to repair link 03 in 3rd second, which was down in the first 0.5
second. This was a good decision, because link 01 breaks down after 0.75 second. Now the
network looks like:
3 4
All sources produce packets for 4.5 seconds. This simulation will show us how the three
sources are affected by this reorganizations and how many bytes they could send.
Page 5 / 15
3 Design
I designed this network with Anjuta using TCL code. At first, I create a NS object:
The sources have to reengineer their paths, because their first decisions may be useless in
time. In the tutorial of Mike Greis’, it is recommended to add this line in the beginning, just
after the creation of NS object.
$ns rtproto DV
I have three sources and I like to distinguish them while the traffic becomes chaotic. So I
assign three colors to them.
I will use NAM in order to visualize things. I used three files to save their traffic.
While tests, I saw that NAM isn’t capable to design how I have imagined the network, so I
have to give it some information about the picture.
Page 6 / 15
$ns duplex-link-op $n2 $n3 orient left-up
$ns duplex-link-op $n2 $n4 orient right-up
Then I told NS what to do on exit. I want that it closes the trace files and displays it in a
graphical form.
proc finish {} {
global f0 f1 f2
#Close the output files
close $f0
close $f1
close $f2
#Call xgraph to display the results
exec xgraph out_2-0.tr out_3-0.tr out_4-0.tr -geometry 800x400&
exit 0
}
I use “attach-traffic” function to attach traffics to the sources. It takes the source node (2, 3 or
4), the sink, the size of the packages, the burst, the idle time, the rate and the color associated
to the traffic.
proc record {} {
global sink2 sink3 sink4 f0 f1 f2
set ns [Simulator instance]
set time 0.1
set bw0 [$sink2 set bytes_]
set bw1 [$sink3 set bytes_]
set bw2 [$sink4 set bytes_]
set now [$ns now]
puts $f0 "$now [expr $bw0/$time*8/1000000]"
puts $f1 "$now [expr $bw1/$time*8/1000000]"
puts $f2 "$now [expr $bw2/$time*8/1000000]"
$sink2 set bytes_ 0
$sink3 set bytes_ 0
$sink4 set bytes_ 0
$ns at [expr $now+$time] "record"
}
Page 7 / 15
set sink2 [new Agent/LossMonitor]
set sink3 [new Agent/LossMonitor]
set sink4 [new Agent/LossMonitor]
$ns attach-agent $n0 $sink2
$ns attach-agent $n0 $sink3
$ns attach-agent $n0 $sink4
And finally I was ready to apply the scenario. In the beginning all three starts running.
But things go wrong and some modifications realize, as explained in the proposal.
$ns run
Page 8 / 15
4 Observations
I used iterative software development techniques, because it was my first NS simulation. It
helped me too much and I didn’t lost in the strange NS error messages. As I told in the design
section, I learned that I have to give respective node position in order to have something
similar to proposals topology, which is a result of this technique. Here, blue, red and green
lines are produced by nodes 2, 3 and 4 respectively and XGraph result is:
From this graph, I observe that traffic 30 has a shortest response time because it has the
smallest rate/size ratio. Fallowed by 40, the longest response time is calculated for traffic 3
0, which have an initial path of 4230.
The values go to 0 periodically, because they are set to 0 on each call of “record” procedure.
If we disable this, we obtain total bytes transmitted by each traffic:
Page 9 / 15
Figure 4.2: XGraph output for total bytes sent.
The blue line has a larger value because its packet size is the smallest. Green and red lines
because of the same reason fallow it.
Now all three produce same traffic. In the result graph, three colors has similar structures:
Page 10 / 15
The result of this action is:
The line above tells NS to record 5 times less then it does for the original code. The result is:
This is very obvious because the more we augment the interval, the less we see the small
pikes. The consequence comes from record procedure, which resets sent bytes to 0.
Page 11 / 15
5 Listing
# Create a simulator object
set ns [new Simulator]
$ns rtproto DV
# Assign colors
$ns color 1 Blue
$ns color 2 Red
$ns color 3 Green
# Create 5 nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
# Organize links
$ns duplex-link-op $n0 $n1 orient down
$ns duplex-link-op $n0 $n3 orient left-down
$ns duplex-link-op $n1 $n2 orient down
$ns duplex-link-op $n1 $n3 orient left
$ns duplex-link-op $n1 $n4 orient right
$ns duplex-link-op $n2 $n3 orient left-up
$ns duplex-link-op $n2 $n4 orient right-up
Page 12 / 15
close $f2
# Call xgraph to display the results
exec xgraph out_2-0.tr out_3-0.tr out_4-0.tr -geometry 800x400 &
exec nam odev.nam &
exit 0
}
Page 13 / 15
$ns at [expr $now+$time] "record"
}
Page 14 / 15
6 Bibliography
[1] Marc Greis’ Tutorial, ISI NS All in One Software, NS Documentation, 2004
[2] Jianping Wang, NS-2 Tutorial, Multimedia Networking Group, The Department of
Computer Science, UVA, 2003
Page 15 / 15