NS-2 Training
4/15/2013
Introduction NS-2: Network Simulator Generation 2
Latest Release: 2.35 / Nov. 4, 2011 http://sourceforge.net/projects/nsnam/files/allinone/ns-
allinone-2.35/
Other Simulators
OPNET
QualNet
ns-3
Installation (1/2) Cygwin
Linux-like environment for Windows Download
http://140.116.164.80/~smallko/ns2/cygwin.rar http://www.cygwin.com/
NS-2 The latest version: ns-2.35 ns-allinone-2.28/2.29 Download
http://sourceforge.net/projects/nsnam/files/ http://140.116.164.80/~smallko/ns2/ns-allinone-2.28.rar
Installation (2/2) Nam: Network Animator (nam-1.15 released
Nov 4 2011) animation tool for viewing network simulation
traces and real world packet traces http://sourceforge.net/projects/nsnam/files/nam-1/ http://www.isi.edu/nsnam/nam/index.html
TCL Codes TCL (Tool Command Language)
pronounced as "tickle"
Basic terms Create a new simulator
Definitions for nam
Open a trace file
Network behaviors Nodes, links, queue size, node position, traffic types,
simulation times, etc.
set ns [new Simulator]
set nf [open out.nam w]$ns namtrace-all $nfset nd [open out.tr w]$ns trace-all $nd
• Initialize the packet format• Create a scheduler• Select the default address format• /ns-2.xx/tcl/lib/ns-lib.tcl
Output data NAM Trace
• appeared as "------" since no flag is set• Explicit Congestion Notification
Analysis AWK
Alfred Aho, Peter Weinberger, and Brian Kernighan programming language that is designed for
processing text-based data pronounced as the same as the name of the bird,
“auk”
Run AWK file Commands
file1.awk a command file
file2.tr a primary input file
out.txt an output file
awk -f file1.awk file2.tr
awk -f file1.awk file2.tr > out.txt
AWK Form
Pattern is typically an expression Action is a series of commands
In NS-2 Simulator
/pattern/ { action }
BEGIN { action }
END { action }
AWK You can measure
Delay, Jitter, Packet loss, and Throughput Example
Rests of this project WiMAX module
http://140.116.164.80/~smallko/ns2/ns-allinone-2.29_wimax.rar 長庚大學
Install cygwin first and then download this file. Decompress it. After that, run “./configure; make clean; make depend; make”
ns-allinone-2.29_wimax\ns-2.29\mac\802_16\traffic
Rests of this project MPEG
modify the file packet.h in the common folder modify the file agent.h in the common folder modify the file agent.cc in the common folder create a folder under ns-2.27 and put added files in
it modify the file tcl/lib/ns-default.tcl modify the Makefile recomplie NS2
RTP add a folder into the ns directory modify ns-default.tcl modify the Makefile recomplie NS2
Rests of this project Correctly Decodable Frames in a GOP
A. Ziviani, B. E. Wolnger, J. F. Rezende, O. C. M. B. Duarte, and S. Fdida, “Joint Adoption of QoS Schemes for MPEG Streams,” Multimedia Tools and Applications, vol. 26 no. 1, pp. 59-80, May 2005.
計算機網路實驗—使用 NS2模擬多媒體通訊與無線網路,柯志亨團隊
Resources Gunplot
Plot the analyzed results of awk Web site
NS2 使用說明手冊 http://hpds.ee.ncku.edu.tw/~smallko/ns2/ns2.htm
MPEG http://hpds.ee.ncku.edu.tw/~smallko/ns2/
Evalvid_in_NS2.htm RTP
http://140.116..80/~yufrank/YCY/myevalvid_rtp.htm http://hpds.ee.ncku.edu.tw/~smallko/ns2/measure.htm http://searun.iteye.com/blog/362415
Resources Books
計算機網路實驗—以 NS2模擬工具實作,柯志亨 計算機網路實驗—使用 NS2模擬多媒體通訊與無線網路,柯志亨團隊