Network Simulator NS2 Internet Technologies 60 375 Varaprasad
- Slides: 44
Network Simulator (NS-2) Internet Technologies 60 -375 © Varaprasad Reddy
Agenda n n n n Overview of NS-2 History Current Status Platforms Supported Discrete Event Simulator NS-2 Environment NS-2 Hierarchy NS-2 Architecture ¨ ¨ ¨ n Node Architecture Multicast Node Architecture Packet Structure Links Traffic Flow Example © Varaprasad Reddy 2
Overview of NS-2 n n n Discrete Event Simulator Packet level Modeling Network protocols ü Collection of Various protocols at multiple layers ü ü ü TCP(reno, tahoe, vegas, sack) MAC(802. 11, 802. 3, TDMA) Ad-hoc Routing (DSDV, DSR, AODV, TORA) Sensor Network (diffusion, gaf) Multicast protocols, Satellite protocols, and many others © Varaprasad Reddy 3
Overview of NS-2 Maintained through VINT project n NS 2 : collaborative simulation environment n ü Freely distributed and open source ü Supports NT research and education ü Protocol design , traffic analysis etc. ü Provides common reference © Varaprasad Reddy 4
History 1995 : Developed by LBL through support of DARPA n 1996: NS was extended and distributed by VINT project n 1997: Satellite models added @ UCB n 1999: Wireless models added @ CMU n Recent incorporation of emulation n © Varaprasad Reddy 5
Current status n Releases: ü Periodic releases (currently 2. 27, Jan 2004) ü Daily snapshots (probably compiles and works, but “unstable”) ü Available from: USC/ISI, UC Berkeley, UK mirror ü More than 10 k users from hundreds of univs © Varaprasad Reddy 6
Platforms supported n Most UNIX and UNIX-like systems Free. BSD ü Linux ü Solaris ü n Windows 98/2000/2003/XP ¨ Cygwin required ¨ Some work , some doesnt © Varaprasad Reddy 7
NS-2 : Components n n NS – Simulator NAM – Network Ani. Mator ¨ n visual demonstration of NS output Preprocessing ¨ Handwritten TCL or ¨ Topology generator n Post analysis ¨ Trace analysis using Perl/TCL/AWK/MATLAB © Varaprasad Reddy 8
User’s Perspective n From the user’s perspective, NS− 2 is an OTcl interpreter that takes an OTcl script as input and produces a trace file as output. © Varaprasad Reddy 9
Discrete event simulator n ns-2 is an discrete event driven simulation Physical activities are translated to events ¨ Events are queued and processed in the order of their scheduled occurrences ¨ Time progresses as the events are processed ¨ Time: 1. 5 sec Time: 1. 7 sec 2 1 Time: 2. 0 sec Time: 1. 8 sec © Varaprasad Reddy 10
Discrete Event Scheduler time_, uid_, next_, handler_ head_ -> handler_ -> handle() insert time_, uid_, next_, handler_ Event Scheduler © Varaprasad Reddy 11
Event Scheduler n Non-Real time schedulers ¨ Implementations : List ¨ Calender is default n Real time schedulers ¨ Used n , Heap , Calender for emulation for direct interaction with real NT. Basic use of an event scheduler: ¨ schedule simulation events, such as when to start an FTP application, when to finish a simulation, or for simulation scenario generation prior to a simulation run. © Varaprasad Reddy 12
NS-2 Environment Simulation Scenario 1 2 set ns_ [new Simulator] Tcl Script set node_(0) [$ns_ node] set node_(1) [$ns_ node] C++ Implementation class Mobile. Node : public Node { friend class Position. Handler; public: Mobile. Node(); • • } © Varaprasad Reddy 13
tcl Interpreter With Extents Event Scheduler otcl 8. 0 Network Component tclcl ns-2 otcl: Object-oriented support n tclcl: C++ and otcl linkage n Discrete event scheduler n Data network (the Internet) components n © Varaprasad Reddy 14
NS-2 Hierarchy © Varaprasad Reddy 15
NS-2 Hierarchy © Varaprasad Reddy 16
NS-2 Directory Structure sim tcl 8. 0 tk 8. 0 otcl Tcl ns-2 tcl code nam-1 C++ code . . . tcl example ex test validation test © Varaprasad Reddy lib . . . tcl code core 17
Node Architecture Node Agent Classifier Node entry point Addr Classifier Local Agent Port Classifiers: packet demultiplexers. Link Agents are either protocol endpoints or related © Varaprasad Reddy objects that generate/fill-in packet fields. Link 18
Multicast Node architecture © Varaprasad Reddy 19
Packets. Packet (events) Structure packet Size determined at simulation config time next_ accessdata( ) bits( ) - packet size Size determined at compile time © Varaprasad Reddy cmn header tcp header - timestamp - type - UID - interface label ip header trace header 20
Links: keeps track of “from” and “to” node objects. blocked Link entry point Enq Trace Queue Deq Trace Drop head Drp Trace Delay © Varaprasad Reddy TTL Rcv Trace 21
N 1 N 2 Node Application Classifier Port Local Agent Classifier Local Port Agent Application Addr Link Enq Trace Queue Link Drop head Deq Trace Delay TTL Rcv Trace Drp Trace © Varaprasad Reddy 22
NS-2 : C++ / OTCL NS-2 Code contains two sets of languages, namely C++ and OTcl. n C++ is used for the creation of objects because of speed and efficiency. n OTcl is used as a front-end to setup the simulator, configure objects and schedule events because of its ease of use. n © Varaprasad Reddy 23
Why two languages? (Tcl & C++) n C++: Detailed protocol simulations require systems programming language ¨ byte manipulation, packet processing, algorithm implementation ¨ Run time speed is important ¨ Turn around time (run simulation, find bug, fix bug, recompile, re-run) is slower n Tcl: Simulation of slightly varying parameters or configurations ¨ quickly exploring a number of scenarios ¨ iteration time (change the model and re-run) is more important © Varaprasad Reddy 24
Tcl or C++? n Tcl ¨ Simple Configuration, Setup, Scenario ¨ If it’s something that can be done without modifying existing Tcl module. n C++ ¨ Anything that requires processing each packet ¨ Needs to change behavior of existing module © Varaprasad Reddy 25
Shadowing Tcl. Object OTcl class hierarchy C++ class hierarchy Tcl. Object() Agent() Agent/DSDVAgent() Agent/DSDV OTcl shadow object Agent/DSDV C++ object © Varaprasad Reddy 26
Object Correspondence Agent/DSDV Constructor Agent Constructor Tcl. Object Constructor Invoke parent Create C++ init complete OTcl shadow TCL C++ Tcl. Object() Constructor Agent. DSDV() Constructor Do nothing, Invoke parent return bind and return © Varaprasad Reddy 27
Outline © Varaprasad Reddy 28
NS-2 Directory Structure sim tcl 8. 0 tk 8. 0 otcl Tcl ns-2 tcl code nam-1 C++ code . . . tcl example ex test validation test © Varaprasad Reddy lib . . . tcl code core 29
Making Changes in C++ Space n Existing code ¨ recompile n Addition ¨ change Makefile and recompile © Varaprasad Reddy 30
Making Changes in otcl Space n Existing code ¨ recompile ¨ source n Addition ¨ source ¨ change Makefile (NS_TCL_LIB), tcl/nslib. tcl (source) and recompile © Varaprasad Reddy 31
Installation n Unix variants ¨ Download NS-allinone-2. 27 package ¨ Contains TCL/TK 8. 4. 5 n o. TCL 1. 8 n Tclcl 1. 15 n Ns 2 n Nam -1 n © Varaprasad Reddy 32
Installation ¨ After successful downloading and unzipping install allinone package , install NS by n install by calling ~/ns-allinone-2. 27/install After successful installation , Validate the scripts by running. /validate in ~/ns-allinone 2. 27/ns-2. 27/ ¨ Its now all set to work with NS ¨ © Varaprasad Reddy 33
Code for simple topology n Creating a Simulator Object ¨ set n ns [new Simulator] Setting up files for trace & NAM ¨ set trace_nam [open out. nam w] ¨ set trace_all [open all. tr w] n Tracing files using their commands ¨ $ns namtrace-all $trace_nam ¨ $ns trace-all $trace_all © Varaprasad Reddy 34
Code for simple topology n Closing trace file and starting NAM ¨ proc finish { } { global ns trace_nam trace_all n $ns flush-trace n close $trace_nam n close $trace_all n exec nam out. nam & n exit 0 } n © Varaprasad Reddy 35
Code for simple topology n Creating LINK & NODE topology ¨ Creating NODES set n 1 [$ns node] n set n 2 [$ns node] n set n 3 [$ns node] n set n 4 [$ns node] n set r 1 [$ns node] n set r 2 [$ns node] n © Varaprasad Reddy 36
Code for simple topology n Creating LINKS ¨ ¨ ¨ ¨ ¨ $ns duplex-link $N 1 $R 1 2 Mb 5 ms Drop. Tail set Duplex. Link 0 [$ns link $N 1 $R 1] $ns duplex-link $N 2 $R 1 2 Mb 5 ms Drop. Tail set Duplex. Link 1 [$ns link $N 2 $R 1] $ns duplex-link $R 1 $R 2 1 Mb 10 ms Drop. Tail set Duplex. Link 2 [$ns link $R 1 $R 2] $ns duplex-link $R 2 $N 3 2 Mb 5 ms Drop. Tail set Duplex. Link 3 [$ns link $R 2 $N 3] $ns duplex-link $R 2 $N 4 2 Mb 5 ms Drop. Tail set Duplex. Link 4 [$ns link $R 2 $N 4] © Varaprasad Reddy 37
Code for simple topology n Orientation of links $ns duplex-link-op $N 1 $R 1 orient right-down ¨ $ns duplex-link-op $N 2 $R 1 orient right-up ¨ $ns duplex-link-op $R 1 $R 2 orient right ¨ $ns duplex-link-op $R 2 $N 3 orient right-up ¨ $ns duplex-link-op $R 2 $N 4 orient right-down ¨ © Varaprasad Reddy 38
Final topology Generated © Varaprasad Reddy 39
Traffic topology aimed at © Varaprasad Reddy 40
Generating Traffic n Attaching AGENT TCP to NODE 1 ¨ ¨ n Attaching AGENT TCP to NODE 2 ¨ ¨ n set TCP 2 [new Agent/TCP] $ns attach-agent $N 2 $TCP 2 Attaching AGENT TCP to NODE 3 ¨ ¨ n set TCP 1 [new Agent/TCP] $ns attach-agent $N 1 $TCP 1 set TCP 3 [new Agent/TCPSink] $ns attach-agent $N 2 $TCP 3 Attaching AGENT TCP to NODE 4 ¨ ¨ set TCP 4 [new Agent/TCPSink] $ns attach-agent $N 2 $TCP 4 © Varaprasad Reddy 41
Generating Traffic n Attaching Application (FTP) ¨ set FTP 0 [new Application/FTP] ¨ set FTP 1 [new Application/FTP] ¨ $FTP 0 attach-agent $TCP 0 ¨ $FTP 1 attach-agent $TCP 1 © Varaprasad Reddy 42
Setting simulation times $ns at 0. 5 "$FTP 0 start" n $ns at 0. 5 "$FTP 1 start" n $ns at 10. 0 "$FTP 0 stop" n $ns at 10. 0 "$FTP 1 stop“ n $ns at 10. 0 “finish” n Making NS run n ¨ $ns run © Varaprasad Reddy 43
© Varaprasad Reddy 44
- Innsbruck uni
- Ns2 simulator tutorial
- Ns2 simulator tutorial
- Karthik dantu
- Awkweb
- Awk ns2
- Ns2 tutorial
- Quantum network simulator
- Network simulator 2
- Onap network slicing
- Network slicing simulator
- Ns3 network simulator
- What is gns in networking
- Network simulator 2 download
- Benchmarksim
- Arc375
- Rm 375-tr-2008 iluminacion tabla
- Berlinsko plavo
- 300 x 375 pikseli
- Com(2018) 375 final
- Sphere of influence imperialism examples
- Waveplate jones matrix
- Ludlum 375
- Csc 375
- Cis 375
- Deret geometri formula
- Internet technologies and applications
- Technologies for network based systems
- Internet or internet
- Vast network
- The internet is the world's largest computer network
- Intranet advantages and disadvantages
- Internet
- International networking adalah
- Internet structure network of networks
- Internet structure network of networks
- Internet international network
- Network as a service for next generation internet
- Protocol outline
- Virtual circuit tables
- What is topology in computer
- Features of peer to peer network and client server network
- Ece 526
- Network centric computing and network centric content
- Packet switched vs circuit switched