ISSNSM — International Summer School on Network and Service Management
2nd ISSNSM’s Tutorial on
Simulating Networks with Network Simulator 2 (ns-2)
(Tutorial T2)
Speaker:
Frank Eyermann
June 3, 2008
ISSNM program chaired by Burkhard Stiller, David Hausheer, University of Zürich
ISSNM laboratory organization chaired by Cristian Morariu, Peter Racz, University of Zürich
NS-2 Network Simulator 2
This tutorial/training course was supported in part by the EC IST-EMANICS Network of Excellence (#26854).
2008 Frank Eyermann
1
Tutorial – Emanics Summer School, Zurich 3rd June, 2008
Introduction
– Frank.Eyermann@unibw.de
– Information Systems Laboratory – Faculty for Computer Science – Universität der Bundeswehr, Munich
2008 Frank Eyermann
2
1
(cid:137)Frank Eyermann
Exercise 1.1: ns-2’s Hello World
– Two nodes, link in between – Sender agent: Agent/UDP – Receiver agent: Agent/Null – Connect agents – Data source: Application/Traffic/CBR – Run from 0.5 to 4.5 sec, finish at 5.0 sec 1000 Byte, Rate 1,5mbit
Application/Traffic/CBR
Agent/Null
Agent/UDP
2mb 10ms DropTail
Node
Node
2008 Frank Eyermann
3
(cid:137)Create the following scenario
Exercise 1.2
Application/FTP
Agent/TCP
1 mb 10 ms DropTail
Node
Agent/TCPSink
Agent/Null
Node
Node
1000 Byte, Rate 1,5mbit
2mb 10ms DropTail
Application/Traffic/CBR
Agent/UDP
2mb 10ms DropTail
Node
2008 Frank Eyermann
4
2
(cid:137)Extend to the following scenario
– Connect the appropriate agents – Start the FTP application at t = 0.5s – Start the CBR data source at t = 1s – Terminate both at t = 4.5 s – Visualize the bottle neck queue:
$ns duplex-link-op $n2 $n3 queuePos 0.5
Exercise 1.2
– Observe the queue and the load on the
bottleneck link
2008 Frank Eyermann
5
(cid:137)Run the simulation (cid:137)Replay the simulation with nam.
Exercise 1.3
– from DropTail to RED (Random Early Detect) – What changes can you observe?
(cid:137)Change the bottleneck drop policy
– Change the RED queue parameters trying to
make it smoother
– set l [$ns link $n2 $n3] – set q [$l queue] – #$q set thresh_ ?? # default 0 – #$q set maxthresh_ ?? # default 50 – #$q set linterm_ ?? # default 0.1
2008 Frank Eyermann
6
3
(cid:137)The FTP traffic is now very bursty.
Exercise 1.4
– $agent set fid_ number
(cid:137)Based on 1.2 (cid:137)Name each flow
– $ns color number Color
(cid:137)Color flow 1 red and flow 2 blue
(cid:137)Predefine the links’ orientation for better
down
layout – $ns duplex-link-op $n0 $n1 orient right-
2008 Frank Eyermann
7
(cid:137)Restart simulation
Exercise 1.5
– Despite tuning the queue’s parameter the
queue length changes in drastically
– Color the packets – Do you see why the RED queue does not
perform as expected?
– What function needs to be implemented?
2008 Frank Eyermann
8
4
(cid:137)Based on exercise 1.3
Exercise 2.1: Tracing
(cid:137)Based on exercise 1.4 (cid:137)Trace all events on the bottleneck link (cid:137)Create a second trace file for only the
drops
(cid:137)Open the document „NS-2 Trace
2008 Frank Eyermann
9
Formats“ – What is the normal trace format?
Exercise 2.2: Monitoring
(cid:137)Based on Exercise 1.4 (cid:137)Create a monitor for the central node (cid:137)Use sampleInterval=0.1 to
2008 Frank Eyermann
10
5
periodically write information to file (cid:137)Do not forget to trigger the monitoring
Exercise 2.3: Monitoring
(cid:137)Based on Exercise 1.4 (cid:137)Create a monitor for the central node (cid:137)Read all 0.05 sec the following values for
each time period: – Throughput – Packet drops – Average packets in queue – Average time of a packet in queue
2008 Frank Eyermann
11
(cid:137)Write them to a file
Exercise 2.3: Monitoring
– You need to create a Samples object for the
average delay
– Create a procedure which retrieves the infor-
mation from the Monitor and writes them to file – The average packets in queue you get from the
respective built-in integrator
– Care for the case when no packets have been
received in one period
– Have the procedure schedule itself again at
[expr [$ns now] + 0.05]
2008 Frank Eyermann
12
6
(cid:137)Hints:
Exercise 2.4: Monitoring
(cid:137)Based on exercise 1.2 and 1.3 (cid:137)Compare utilization of the bottleneck
respective data
2008 Frank Eyermann
13
link and average time of a packet in the queue for DropTail and RED queuing discipline – Use QueueMonitors and Samples for the
Exercise 2.5: Monitoring Flows
– Use the standard output format – Look for the format at page 243 of ns_doc.pdf
2008 Frank Eyermann
14
7
(cid:137)Based on exercise 2.2 (cid:137)Monitor the both flows separately
Exercise 3.1: Trace Post-Processing
(cid:137)Based on exercise 2.3 (cid:137)Visualize the drops and the average
2008 Frank Eyermann
15
packets in the queue with xgraph and gnuplot
(cid:137)Create the following scenario (cid:137)All clients pull FTP data from
Client 1
Exercise 3.2
0.5 to 4.5 sec
Client 2
16Mbit 25ms
16Mbit 25ms
100 Mbit 8ms DropTail
56 Mbit 12 ms DropTail
16Mbit 25ms
FTP Server
16Mbit 25ms
Client 3
Client 4
2008 Frank Eyermann
16
8
Exercise 3.2
(cid:137)Should Client 1 invest in upgrading to a
25 MBit/s or 50 MBit/s link?
(cid:137)Or better invest in a Fast-Path option
reducing the delay to 15ms?
(cid:137)Could the provider’s queuing discipline
2008 Frank Eyermann
17
influence the user’s decision?
Exercise 3.3
(cid:137)Based on exercise 1.4 (cid:137)Visualize the packet jitter of the CBR
to skip dropped packets
2008 Frank Eyermann
18
9
data – Remember
Exercise 4.1: LANs
4 FTP-Clients
FTP-Server
Router
(cid:137)Create a typical 10 MBit/s Ethernet
(cid:137)The LAN delay should be 1 ms (cid:137)The connection from the server to the
router is a WAN (2mbit/s, 10 ms)
2008 Frank Eyermann
19
(cid:137)Simulate 5 sec. FTP-Transfer
Exercise 4.2
(cid:137)nam shows a quite long queue (cid:137)What is the average queuing delay of a
packet?
(cid:137)How could the delay be reduced? Think
2008 Frank Eyermann
20
10
of exercise 1.3 – Repeat the simulation
Exercise 5.1: Routing
(cid:137)Create the following scenario, all links
1
2
8
3
7
4
6
10MBit, 8 ms, DropTail
5
2008 Frank Eyermann
21
(cid:137)Send CBR data 1 -> 6, 3 -> 8, 5 -> 2, 7 -> 4 Rate = 1.5 MBit, Size = 500 Byte (cid:137)Activate session- based routing
Exercise 5.2
– Fails each 1.5 sec for 0.5 sec
(cid:137)Link node 1 to node 2
– Is down between 1.6 and 2.5 sec
2008 Frank Eyermann
22
11
(cid:137)Node 5
Exercise 5.3: Routing
(cid:137)Based on exercise 4.1 (cid:137)Dialup backup line, if WAN connection
down
RAS-Server
2008 Frank Eyermann
23
fails – Volume based, quite expensive – 1mb, 15ms – Simulate deterministic failure 2sec up, 0,5sec
Bug in ns-2.3x
nodes-list]
{
# XXX using dummy 0 for 'changes'
$node notify-mcast 0
} – “LAN” is a node (LanNode) but misses
notify-mcast
– Hack: find method notifiy-mcast of node – Create an (empty) method stub for LanNode – Run make in folder ns-2.33
2008 Frank Eyermann
24
12
(cid:137)On activating or deactivating of a link: foreach node [[Simulator instance] all-