Download presentation
Presentation is loading. Please wait.
Published byValentine Anthony Modified over 9 years ago
1
1 Introduction to NS-2 r Tutorial overview of NS m Create basic NS simulation r Walk-through a simple example m Model specification m Execution and trace analysis http://www-net.cs.umass.edu/~honggang/ns-cs653/
2
2 NS-2, the network simulator r Academic project over 10 years old m freely distributed, open source r Currently maintained by ISI (Information Sciences Institute) m DARPA + NSF projects r ~ 200K LoC, 403 page manual r Large user base m mostly academics r “de facto” standard in networking research r Main website: http://www.isi.edu/nsnam/ns
3
3 NS Functionality r Discrete event simulator r Modeling Network Components m Traffic models and applications Web, FTP, telnet, audio, sensor nets m Transport protocols TCP (Reno, SACK, etc), UDP, multicast m Routing and queueing static routing, DV routing, multicast, ad-hoc routing queueing disciplines: drop-tail, RED, FQ m Link layer wired, wireless, satellite r Providing Infrastructure m tracing, visualization, error models, etc m modify or create your own modules
4
4 NS components r NS, the simulator itself (this is all we’ll have time for) r NAM, the Network AniMator m visualize NS (or other) output m GUI input simple Ns scenarios r pre-processing: m traffic and topology generators r post-processing: m simple trace analysis, often in Awk, Perl, or Tcl r Tutorial: http://www.isi.edu/nsnam/ns/tutorial r NS by example: http://nile.wpi.edu/NS/
5
5 NS Software Structure: C++ and OTCL r Uses two languages r C++ for the core of NS simulator m per packet processing m fast to run, detailed, complete control r OTCL for control [our focus] m simulation setup, configuration m fast to write and change
6
6 Steps when using NS r Create OTCL script for your network model m nodes, links, traffic sources, sinks, etc. r Parameterize simulation objects m Links: queue sizes, link speeds, … m Transport Protocols: TCP flavor and parameters (more than 30), … r Collect statistics m dump everything to trace, post process it m gather stats during simulation within OTCL script m modify Ns source code r Run NS multiple times m confidence intervals
7
7 Create a Basic NS Simulation 1. Create event scheduler 2. Create nodes and links 3. Create connections 4. Create traffic sources/sinks 5. Enable tracing
8
8 Create a Basic NS Simulation 1. Create the event scheduler 2. Create nodes and links 3. Create connections 4. Create traffic sources/sinks 5. Enable tracing
9
9 Step 1: Creating Event Scheduler r Create scheduler m set ns [new Simulator] r Schedule event m $ns at m : any legitimate Ns/TCL commands r Start scheduler m $ns run
10
10 Create a Basic NS Simulation 1. Create the event scheduler 2. Create nodes and links 3. Create connections 4. Create traffic sources/sinks 5. Enable tracing
11
11 Step 2: Creating Network (Nodes + Links) r Nodes m set n0 [$ns node] m set n1 [$ns node] r Links: connect together two nodes m $ns duplex-link $n0 $n1 m determines propagation delay m determines queueing policy DropTail, RED, CBQ, FQ, SFQ, DRR
12
12 Create a Basic NS Simulation 1. Create the event scheduler 2. Create nodes and links 3. Create connections 4. Create traffic sources/sinks 5. Enable tracing
13
13 Step 3: Create Connections r Transports: m TCP, UDP, multicast, etc. m transport protocol instances attach to nodes
14
14 Creating Transport Channels: UDP r source and sink m set u_src [new Agent/UDP] m set u_dst [new Agent/NULL] r attach them to nodes, then connect to each other m $ns attach-agent $n0 $u_src m $ns attach-agent $n1 $u_dst m $ns connect $u_src $u_dst
15
15 Creating Transport Channels: TCP r source and sink m set t_src [new Agent/TCP/Newreno] m set t_dst [new Agent/TCPSink] m “Newreno” flavor of TCP r attach to nodes and each other m $ns attach-agent $n0 $t_src m $ns attach-agent $n1 $t_dst m $ns connect $t_src $t_dst
16
16 Create a Basic NS Simulation 1. Create the event scheduler 2. Create nodes and links 3. Create connections 4. Create traffic sources/sinks 5. Enable tracing
17
17 Step 4: Create Traffic Models r Traffic (applications): m Web, ftp, telnet, audio, etc. m application objects attach to transport protocol objects m generates traffic into transport protocol
18
18 Creating Traffic over TCP Channels How to create a FTP session over TCP? r create traffic model m set ftp [new Application/FTP] m default is “infinite” file size r attach to TCP channel m $ftp attach-agent $t_src r schedule start time m $ns at “$ftp start”
19
19 Creating Traffic over UDP Channels How to create a CBR (Constant Bit Rate) model over UDP? m set cbr [new Application/Traffic/CBR] m $cbr set packetSize_ 512 m $cbr set interval_ 0.250 m $cbr attach-agent $u_src m $ns at “$cbr start”
20
20 Create a Basic NS Simulation 1. Create the event scheduler 2. Create nodes and links 3. Create connections 4. Create traffic sources/sinks 5. Enable tracing
21
21 Tracing: dump everything into a file r Trace packets on individual link r Tracefile format: -- + 1 0 2 tcp 900 ------- 1 0.0 3.1 7 15 - 1 0 2 tcp 900 ------- 1 0.0 3.1 7 15 r 1.00234 0 2 tcp 900 ------- 1 0.0 3.1 7 15 + enqueue - dequeue r receive d drop time nodes involved in this event Node 0 Node 1 enqueue receive dequeue drop
22
22 r Trace packets on individual links r Tracefile format: -- + 1 0 2 tcp 900 ------- 1 0.0 3.1 7 15 - 1 0 2 tcp 900 ------- 1 0.0 3.1 7 15 r 1.00234 0 2 tcp 900 ------- 1 0.0 3.1 7 15 + enqueue - dequeue r receive d drop time nodes involved in this event packet type packet length packet flags flow ID source dest addresses seq number packet ID Tracing: dump everything into a file
23
23 Tracing via Monitors r Queue monitor: the queue to access a link r Flow monitor: particular flow within queue m to specify a link, we need: set link [$ns link $n0 $n1] m to create a flow monitor: set fmon [$ns makeflowmon Fid] $ns attach-fmon $link $fmon $ns at “puts $fmon set pdrops_”
24
24 Introduction to NS-2: r Tutorial overview of NS m Create basic NS simulation r Walk-through simple example m Model specification m Execution and trace analysis
25
25 Walk-through example acks full duplex acks full duplex Node 2 Node 0 Node 1
26
26 Walk-through example 2 FTP sources One On-Off Source (voice) acks 12 TCP dest One On-Off dest One CBR dest 2 Mbps full duplex 5 msec prop delay 100 packet buffer Drop-tail policy acks 1 Mbps full duplex 10 msec prop delay 700 packet buffer Drop-tail policy 10 FTP sources One UDP 2 TCP SACK W_max = 32 MSS = 1400 10 TCP NewReno W_max = 32 MSS = 1400 Node 0 Node 1 Node 2 One UDP One CBR source 12 FTP dest Two UDP dest fat link thin link performance tracing
27
27 Introduction to NS-2: r Tutorial overview of NS m Create basic NS simulation r Walk-through simple example m Model specification m Execution and trace analysis See handout for source code
28
28 NS Trace file (link n1->n2): NS-trace.txt... + 11.533441 1 2 tcp 1440 ------- 12 1.2 2.4 96 2092 r 11.535694 1 2 tcp 1440 ------- 12 1.2 2.4 65 1527 - 11.537214 1 2 exp 180 ------- 100 0.2 2.13 284 1528 - 11.538654 1 2 cbr 1440 ------- 101 1.11 2.14 155 1530 r 11.547214 1 2 tcp 1440 ------- 12 1.2 2.4 66 1529 + 11.54728 1 2 tcp 1440 ------- 12 1.2 2.4 97 2095 r 11.548654 1 2 exp 180 ------- 100 0.2 2.13 284 1528 + 11.55 1 2 cbr 1440 ------- 101 1.11 2.14 211 2096 - 11.550174 1 2 tcp 1440 ------- 12 1.2 2.4 67 1534 r 11.560174 1 2 cbr 1440 ------- 101 1.11 2.14 155 1530 - 11.561694 1 2 exp 180 ------- 100 0.2 2.13 285 1532 + 11.56222 1 2 tcp 1440 ------- 12 1.2 2.4 98 2097 - 11.563134 1 2 tcp 1440 ------- 12 1.2 2.4 68 1537 r 11.571694 1 2 tcp 1440 ------- 12 1.2 2.4 67 1534 r 11.573134 1 2 exp 180 ------- 100 0.2 2.13 285 1532 - 11.574654 1 2 exp 180 ------- 100 0.2 2.13 286 1536... 0.0114sec=180*8/(10^6)+0.01
29
29 Flow Monitor (link n1->n2) Trace : packet-trace.txt... 10 356 1394.6939635123624 1262 906 0 4 7 3 0 10.5 367 1575.3875777393503 1325 958 0 8 15 7 0 1 1 0 0 11 366 1759.8340061666161 1384 1018 0 8 15 7 0 1 1 0 0 11.5 370 1944.0583990191849 1448 1078 0 8 15 7 0 1 1 0 0 12 380 2131.710863713804 1512 1132 0 8 15 7 0 1 1 0 0 12.5 382 2325.178644727122 1558 1176 0 8 15 7 0 1 1 0 0 13 382 2516.7615454470124 1613 1231 0 8 15 7 0 1 1 0 0 13.5 395 2710.8647514290892 1676 1281 0 8 15 7 0 2 3 1 0 14 421 2912.3462186990751 1747 1326 0 16 31 15 0 2 3 1 0 14.5 432 3130.3858423193769 1805 1373 0 16 31 15 0 2 3 1 0 15 436 3344.5896974377333 1862 1426 0 16 31 15 0 2 3 1 0 15.5 462 3571.3811182311597 1937 1475 0 16 31 15 0 2 3 1 0 16 477 3804.653159658757 1995 1518 0 16 31 15 0 2 3 1 0 16.5 495 4049.5929326563519 2057 1562 0 16 31 15 0 2 3 1 0 17 531 4303.9211771379323 2136 1605 0 16 31 15 0 2 3 1 0...
30
30 Results - Queue Statistics r Red - instantaneous r Green - running average r Blue - average w/o transient r Purple - packet drops
31
31 Results - Flow Statistics r Red - TCP flow 1 r Green - TCP flow 2 r Number of packets in queue mimics TCP Window behavior
32
32 Results - Flow Statistics r Congestion Windows of Flow 1 and Flow 2 r Cumulative dropped packets of Flow 1 and Flow 2
33
33 Performance Queue Statistics r Multiple runs to obtain confidence intervals
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.