DMN1 : COMMUNICATION PROTOCOL SIMULATION

Faculty of Engineering

Multimedia University

Marking Scheme

No / Component / Criteria / Not answered – 0 marks
Poor – 2 marks
Acceptable – 4 (max) marks
1 / Viva / Students able to understand some questions related to the experiments
2 / Report / Report follow scientific format
3 / Report / The experiment is conducted thoroughly and result is well analyzed
4 / Report / The report provide good reasons and justifications to support the conclusion

Total marks = 16

Lab 1 contributes 5% to the course work mark.

1.0 OBJECTIVES

To understand and simulate network traffic using NS2 network simulator.

To investigate and observe TCP and UDP protocols implemented in the transport layer.

To study and analyse the different applications run over different transport layer protocols.

2.0LIST OF EQUIPMENT AND SOFTWARE

Computer running ns-allinone (latest release is 2.31) is a package which contains required components and some optional components used in running NS-2. The package contains an "install" script to automatically configure, compile and install these components.

Currently the package contains:

  • Tcl release 8.4.14 (Main component)
  • Tk release 8.4.14 ( Main component)
  • Otcl release 1.13 ( Main component)
  • TclCL release 1.19 ( Main component)
  • Ns release 2.31 (Main component)
  • Nam (Animation purpose)
  • Gnuplot (Plotting purpose)

External storage (thumb drive brought by student) to save the simulation output.

Download codes before come for lab experiment at the course page in MMLS.

3.0LAB EXPECTATIONS

Work on pre-experimental preparation.

Answer pre-experimental questions.

Work on the lab experiments.

Record results and make analysis from the results’ experiment.

Answer post-experimental questions.

4.0INTRODUCTION

NS or the network simulator (also popularly called ns-2, in reference to its current generation) is a discrete event network simulator. NS-2 is popularly used in the simulation of routing and multicast protocols, among others, and is heavily used in ad-hoc networking research. NS-2 supports an array of popular network protocols, offering simulation results for wired and wireless networks alike. It can be also used as limited-functionality network emulator. It is popular in academia for its extensibility (due to its open source model) and plentiful online documentation. NS-2 is licensed for use under version 2 of the GNU General Public License.

NS-2 consists of these modelling network components:

  • Traffic models and applications
  • Web, FTP, telnet, audio, sensor networks
  • Transport protocols
  • TCP (Reno, SACK, etc), UDP, multicast
  • Routing and queuing
  • static routing, DV routing, multicast, ad-hoc routing
  • queuing disciplines: drop-tail, RED, FQ
  • Link layer
  • wired, wireless, satellite

It also provides useful infrastructure for tracing, visualization, error models, etc. Programmers can modify and create their own modules.

For tracing proposes, user can extract the raw data from data file (example out.tr)

From there raw data, graph for analysis can be executed as shown below:

5.0PRE-EXPERIMENTAL QUESTIONS

5.1Name three other simulation tools commonly used for network simulation.

5.2What is the difference between a .tcl file extension with a .nam file extension.

5.3Explain the working of a sliding window flow control protocol.

6.0EXPERIMENTS

START RUNNING KNOPPIX

For these experiments, we will be using Knoppix with embedded NS-2. Knoppix is complete Linux distribution that can run for a single CD. Usually this kind of distribution is called a live CD where it can load Linux system without installing it on a hard drive. The distribution used for this experiment come with NS-2 embedded in it. Hence, student can run the NS-2 without having to install it on the hard drive. Please get a Knoppix CD from the lab technician.

Note: please insert your thumb drive onto the USB slots before run the Knoppix.

Start using Knoppix

After Knoppix uploaded, type the command below to run the KDE environment:

startx

Bring up the Console, and setup path for nam and xgraph line by line (press Enter after each line):

sh-3.00# PATH=”$PATH:/usr/local/ns-allinone-2.29/nam-1.11”

sh-3.00# export PATH

sh-3.00# PATH=”$PATH:/usr/local/ns-allinone-2.29/xgraph-12.1”

sh-3.00# export PATH

To check either the paths are already set, type the commands below one by one. It should return the path to the required applications:

sh-3.00# which ns

sh-3.00# which nam

sh-3.00# which xgraph

To set your working path, type

sh-3.00# cd Desktop

From now on, save all the documents and files on your desktop.

Eject and shutdown Knoppix

At the end of session, after logout from the KDE environment, press the below keys simultaneously to eject the CD:

Ctrl+Alt+Del

6.1EXPERIMENT

6.1.1Experiment1: Simple UDP Simulation

Open the file name experiment1.tcl. Observe the code to understand a simple script for UDP simulation.

Question 1: What is the name of the nam file created and what is the purpose of this nam file?

Run experiment1a.tcl

sh-3.00# ns experiment1.tcl

Observation 1: Observe and note down your observation.

Question 2: Can you name the application that is running in this experiment.

Question 3: The UDP connection is running a CBR traffic. What is CBR stand for and give one application example that use CBR traffic?

Question 4: Why are there packets drop in node0?

Observation 2: Try changing the link bandwidth from 1Mbps to 1MBps. What is the different from from the previous execution? Explain your observation.

Observation 3: Change the queuing policy Droptail at line 28 to FQ. Write your observation. (FQ stands for stochastic fair queuing.)

6.1.2Experiment2: TCP Simulation with Sliding Windows Protocol

Run the experiment1b.tcl with the arguments below:

ns experiment2.tcl <cong_window> <link_delay>

sh-3.00# ns experiment2.tcl 100 100ms

Observation 4: Observe the differences as compare to Experiment1.

Observation 5: What do you observe every time the packet transmitted exceeded the link bandwidth capacity?

Observation 6: What happen when you change the value of <cong_window> to 10, 50, 500 and 1000? Explain your observation.

6.1.3Experiment3: TCP versus UDP

Run the file experiment3.tcl with the link capacity as an argument:

sh-3.00# ns experiment3.tcl 1MB

Observation 7:Write down your observation.

Question 5: What colour represent the TCP connection? How did you come to this conclusion?

Observation 8: Try changing the argument values for example 1Mb. What do you observe?

6.1.4Experiment4: Sending FTP and CBR from different sources

Manipulate the code given in experiment3.tcl to make it sending and receiving from different sources but sharing the same command link as shown in Figure 1. Give your new file name as experiment4.tcl.

Figure 1

Show the instructor the successful animation.

Observation 9: Comment on your observation.

Plotting with XGRAPH

We are going to use xgraph, a simple graph plotting tool, to help in our analysis. Xgraph read files that consist of 2 columns of data – one column provides the x-axis data and the other column provides the y-axis data. To extract certain columns from NS2 trace file (e.g. outexperiment4.tr), we may use the following command:

sh-3.00# awk ‘{print $2, $12}’ trace.tr > plot.tr

The above command will select data from column 2 and column 12 from file ‘trace.tr’ and save it into new file ‘plot.tr’:

To start plotting:

sh-3.00# xgraph plot1.tr

Question 6: What is “awk”?

7.0POST-EXPERIMENTAL ANALYSIS AND DISCUSSIONS

7.1How do you run the nam animator from command line?

7.2What happen to the packets when the packets were dropped during transmission?

7.3By using awk, write a script to extract the throughput performance of the FTP and CBR connections in Experiment 4. Comment on the throughput performance observed.

7.4What can you conclude from these experiments?

8.0REFERENCES

[1] The Network Simulator - NS-2 (no date). Home page. [Online]. University of Michigan. [2007, June 11].

[2] NS Manual (no date). Home page. [Online]. University of Michigan. [2007, June 11].

[3] NS by Example (no date). Home page. [Online]. University of Michigan. [2007, June 11].

[4] Fred Halsall, “Computer Networking and the Internet”, 5th Edition, Addison Wesley; 2005

ETM4116 / 1

Appendix I

How to Start

Create an event scheduler
set ns [new Simulator]
Open a file for trace data
set nf [open out.nam w]
$ns namtrace-all $nf
A procedure to close file and start NAM
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit 0
}
Schedule the procedure
$ns at 5.0 "finish"
Start simulation
$ns run

Topology

Node
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
Link
$ns duplex-link $n0 $n1 1Mb 5ms DropTail
$ns duplex-link $n1 $n2 400Kb 10ms DropTail

Agent/Application

Create a UDP agent and attach it to node n0
set udp [new Agent/UDP]
$ns attach-agent $n0 $udp
Create a CBR traffic source and attach it to udp0
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
Create a null agent to be traffic sink
set null [new Agent/Null]
$ns attach-agent $n2 $null
Connect them
$ns connect $udp $null
Schedule the event
$ns at 0.5 "$cbr start"
$ns at 4.5 "$cbr stop"
Create a TCP agent and attach it to node n0
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
Create a FTP traffic source and attach it to udp0
set ftp [new Application/FTP]
$ftp attach-agent $tcp
Create a TCPSink agent to be traffic sink
set sink [new Agent/TCPSink]
$ns attach-agent $n2 $sink
Connect them
$ns connect $tcp $sink
Schedule the event
$ns at 0.5 "$ftp start"
$ns at 4.5 "$ftp stop"

Traces

Traces in NS-2 format
$ns trace-all [open tr.out w]
<event> <time> <from> <to> <pkt> <size> -- <fid> <src> <dst> <seq> <attr>
+ 1 0 2 cbr 210 ------0 0.0 3.1 0 0
- 1 0 2 cbr 210 ------0 0.0 3.1 0 0
r 1.00234 0 2 cbr 210 ------0 0.0 3.1 0 0
d 1.04218 1 2 cbr 210 ------0 0.0 3.1 0 0
Traces in NAM format
$ns namtrace-all [open tr.nam w]
Turn on tracing on specific links
$ns trace-queue $n0 $n1
$ns namtrace-queue $n0 $n1

Event and Queuing

Schedule events
$ns at <time> <event>
<event>: any legitimate ns/tcl commands
Links and queuing
$ns duplex-link $n0 $n1 <bandwidth> <delay> <queue_type>
<queue_type>: DropTail, RED, CBQ, FQ, SFQ, DRR

Routing

Unicast
$ns rtproto <type>
<type>: Static, Session, DV, cost, multi-path
Multicast
$ns multicast (right after [new Simulator])
or set ns [new Simulator –multicast on]
$ns mrtproto <type>
<type>: CtrMcast, DM, ST, BST (centralized,dense mode, shared tree)

Traffic on top of UDP

UDP
set udp [new Agent/UDP]
set null [new Agent/Null]
$ns attach-agent $n0 $udp
$ns attach-agent $n1 $null
$ns connect $udp $null
CBR
set src [new Application/Traffic/CBR]
Exponential or Pareto
set src [new Application/Traffic/Exponential]
set src [new Application/Traffic/Pareto]

Traffic on Top of TCP

TCP
set tcp [new Agent/TCP]
set tcpsink [new Agent/TCPSink]
$ns attach-agent $n0 $tcp
$ns attach-agent $n1 $tcpsink
$ns connect $tcp $tcpsink
FTP
set ftp [new Application/FTP]
$ftp attach-agent $tcp
Telnet
set telnet [new Application/Telnet]
$telnet attach-agent $tcp
ETM4116 / 1
ETM4116 / 1
ETM4116 / 1