Presentation is loading. Please wait.

Presentation is loading. Please wait.

DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.

Similar presentations


Presentation on theme: "DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek."— Presentation transcript:

1 DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek

2 Exp 3: NS2

3 What is a Simulation?  “It is the imitation of the operation of a real-world process or system over time. The act of simulating something first requires that a model be developed; this model represents the key characteristics or behaviors/functions of the selected physical or abstract system or process. The model represents the system itself, whereas the simulation represents the operation of the system over time.” Wikipedia  Highly valuable tool for research and analysis

4 What is NS2  Object-oriented, discrete event-driven network simulator  Written in C++ and OTcl  Separates control path from data path implementations  By VINT: Virtual InterNet Testbed

5 Goals of NS2 1-5  Support networking research and education  Protocol design, traffic studies, etc  Protocol comparison  Provide a collaborative environment  Freely distributed, open source Share code, protocols, models, etc  Allow easy comparison of similar protocols  Increase confidence in results More people look at models in more situations Experts develop models  Multiple levels of detail in one simulator

6 Functionalities of NS2 1-6  Wired world  Routing DV, LS, PIM-SM  Transportation: TCP and UDP  Traffic sources: web, ftp, telnet, cbr, stochastic  Queuing disciplines: drop-tail, RED, FQ, SFQ, DRR  QoS: IntServ and Diffserv  Emulation  Wireless  Ad hoc routing and mobile IP  Sensor networks, vehicular networks  Tracing, visualization, various utilities

7 NS Components 1-7  NS, the simulator itself  Nam, the network animator  Visualize ns (or other) output  Nam editor: GUI interface to generate ns scripts  Pre-processing:  Traffic and topology generators  Post-processing:  Simple trace analysis, often in Awk, Perl, or Tcl

8 NS Models 1-8  Traffic models and applications:  Web, FTP, telnet, constant-bit rate, real audio  Transport protocols:  unicast: TCP (Reno, Vegas, etc.), UDP  Multicast: SRM  Routing and queueing:  Wired routing, ad hoc rtg and directed diffusion  queueing protocols: RED, drop-tail, etc  Physical media:  Wired (point-to-point, LANs), wireless (multiple propagation models), satellite

9 Discrete Event Simulator 1-9  Model world as events  Simulator has list of events  Process: take next one, run it, until done  Each event happens in an instant of virtual (simulated) time, but takes an arbitrary amount of real time Consider two nodes on an Ethernet: AB simple queuing model: t=1, A enqueues pkt on LAN t=1.01, LAN dequeues pkt and triggers B

10 C++ and oTCL Sepatarion 1-10  “data” / control separation  C++ for “data”:  per packet processing, core of ns  fast to run, detailed, complete control  OTcl for control:  Simulation scenario configurations  Periodic or triggered action  Manipulating existing C++ objects  fast to write and change + running vs. writing speed – Learning and debugging (two languages)

11 NS Programming 1-11  Create the event scheduler  Turn on tracing  Create network  Setup routing  Insert errors  Create transport connection  Create traffic  Transmit application-level data

12 Creating an Event Scheduler 1-12 Transport Layer  Create event scheduler set ns [new Simulator]  Schedule events $ns at : any legitimate ns/tcl commands $ns at 5.0 “finish”  Start scheduler $ns run Example: simple.tcl set ns [new Simulator] $ns at 1 “puts \“Hello World!\”” $ns at 1.5 “exit” $ns run bash-shell$ ns simple.tcl Hello World! bash-shell$

13 Tracing 1-13  Insert immediately after scheduler!  Trace packets on all links set nf [open out.nam w] $ns trace-all $nf $ns namtrace-all $nf

14 Tracing 1-14

15 Creating a Simple Network 1-15 Transport Layer  Nodes set n0 [$ns node] set n1 [$ns node]  Links and queuing $ns duplex-link $n0 $n1 1Mb 10ms RED  $ns duplex-link $n0 $n1  : DropTail, RED, etc. n1 n0

16 Queuing Methods  Drop Tail: When the buffer is full drop any newly arriving packets 1-16  Has global TCP congestion problem  all nodes stop and start at the same time  Random Early Detection (RED): Starts dropping before the buffer is full. The more data sent by a node, the higher the dropping probability  Stochastic Fairness Queuing: Supports QoS by supporting multiple queues. Packets are taken in a round robin fashion

17 Creating a Larger Topology 1-17 for {set i 0} {$i < 7} {incr i} { set n($i) [$ns node] } for {set i 0} {$i < 7} {incr i} { $ns duplex-link $n($i) $n([expr($i+1)%7]) 1Mb 10ms RED }

18 Network Dynamics 1-18  Link failures  Hooks in routing module to reflect routing changes $ns rtmodel-at up|down $n0 $n1  For example: $ns rtmodel-at 1.0 down $n0 $n1 $ns rtmodel-at 2.0 up $n0 $n1

19 Creating a UDP Link 1-19 n1 n0 udp null set udp [new Agent/UDP] set null [new Agent/Null] $ns attach-agent $n0 $udp $ns attach-agent $n1 $null $ns connect $udp $null

20 Creating Traffic on top of UDP 1-20 n1 n0 udp cbr null  Constant Bit Rate set cbr [new Application/Traffic/CBR] $cbr set packetSize_ 500 $cbr set interval_ 0.005 $cbr attach-agent $udp

21 Creating a TCP Connection 1-21 n1 n0 tcp sink set tcp [new Agent/TCP] set tcpsink [new Agent/TCPSink] $ns attach-agent $n0 $tcp $ns attach-agent $n1 $tcpsink $ns connect $tcp $tcpsink

22 Creating Traffic on top of TCP 1-22 n1 n0 tcp ftp sink  FTP set ftp [new Application/FTP] $ftp attach-agent $tcp  Telnet set telnet [new Application/Telnet] $telnet attach-agent $tcp

23 Inserting Packet Loss 1-23  Creating Error Module set loss_module [new ErrorModel] $loss_module set rate_ 0.01 $loss_module unit pkt $loss_module ranvar [new RandomVariable/Uniform] $loss_module drop-target [new Agent/Null]  Inserting Error Module $ns lossmodel $loss_module $n0 $n1

24 Post-Processing Procedure 1-24  Add a 'finish' procedure that closes the trace file and starts nam. proc finish {} { global ns nf $ns flush-trace close $nf exec nam out.nam & exit 0 }

25 Network Animator 1-25

26 Network Visualization: Nodes and Links 1-26 Nodes  Color $node color red  Shape (can’t be changed after sim starts) $node shape box (circle, box, hexagon)  Label (single string) $ns at 1.1 “ $n0 label \ ” web cache 0\ ”” Links  Color $ns duplex-link-op $n0 $n1 color "green"  Label $ns duplex-link-op $n0 $n1 label “ backbone"

27 Topology Example 1-27  Manual” layout: specify everything $ns duplex-link-op $n(0) $n(1) orient right $ns duplex-link-op $n(1) $n(2) orient right $ns duplex-link-op $n(2) $n(3) orient right $ns duplex-link-op $n(3) $n(4) orient 60deg  If anything missing  automatic layout

28 Simulation Example 1-28


Download ppt "DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek."

Similar presentations


Ads by Google