EECS 122 Introduction to Computer Networks Fall 2004

  • Slides: 16
Download presentation
EECS 122 Introduction to Computer Networks (Fall 2004) Network simulator 2 (ns-2) Department of

EECS 122 Introduction to Computer Networks (Fall 2004) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences University of California Berkeley Slides: K. Fall, J. Heidemann, P. Huang, K. Lai, A. Parekh, I. Stoica, S. Katz, Stoica F 04 Shenker, J. Walrand

EECS 122: Introduction to Computer Networks Network Simulator ns 2 Computer Science Division Department

EECS 122: Introduction to Computer Networks Network Simulator ns 2 Computer Science Division Department of Electrical Engineering and Computer Sciences University of California, Berkeley, CA 94720 -1776 EECS 122 - UCB Katz, Stoica F 04

Outline § § § Goals Discrete event simulation Basic ns-2 Examples Project requirements Katz,

Outline § § § Goals Discrete event simulation Basic ns-2 Examples Project requirements Katz, Stoica F 04 3

What is ns-2? § § Discrete event simulator Models network protocols - § Wired,

What is ns-2? § § Discrete event simulator Models network protocols - § Wired, wireless, satellite TCP, UDP, multicast, unicast Web, telnet, ftp Ad-hoc routing, sensor networks Infrastructure: stats, tracing, error models, etc. Multiple levels of detail in one simulator Katz, Stoica F 04 4

Why simulate? § § § Can examine protocol in controlled environment Repeatable experiments Alternatives:

Why simulate? § § § Can examine protocol in controlled environment Repeatable experiments Alternatives: - Experimentation: operational details, but: limited scale, limited flexibility - Analysis: can provide deeper understanding, but: ignores implementation details Katz, Stoica F 04 5

ns-2 components § ns: the Network Simulation engine - executes tcl scripts containing simulation

ns-2 components § ns: the Network Simulation engine - executes tcl scripts containing simulation setup and events § nam: the Network Ani. Mator - visualize ns output tcl script (specification of experiment) ns-2 trace file (output) nam Katz, Stoica F 04 6

Discrete event simulation § model world as events - maintain queue of events, ordered

Discrete event simulation § model world as events - maintain queue of events, ordered by time - maintain [virtual time] - repeat: • extract event at head, set [virtual time]=event’s time • process it • if processing generates another event, add it to queue § each event takes predefined amount of virtual time, arbitrary amount of real time - having a slow CPU makes simulation run slower (in real time), but doesn’t change result Katz, Stoica F 04 7

Discrete event example S D Event queue A. TIME A. 1 s B. C.

Discrete event example S D Event queue A. TIME A. 1 s B. C. D. delay value transmission 0. 005 s propagation 0. 01 s B. 1. 005 s EVENT S decides to send pkt to D S starts sending pkt S finishes transmitting pkt to D C. 1. 01 s D begins to recv pkt D. 1. 015 s D recvs entire pkt and delivers to application S D Katz, Stoica F 04 8

o. Tcl overview § programming language used for setting up simulation environment - object

o. Tcl overview § programming language used for setting up simulation environment - object oriented - interpreted (slow) § Used for - Setting up topology Placing agents Injecting events Configuring tracing Examples: § variables - set x 10 - puts “x is $x” § expressions - set y [pow x 2] - set y [expr x+x*3] § control - if ($x>0) { return $x } else { return [expr -$x] } - while ($x >0) { puts $x • set x [eval x+1] } Katz, Stoica F 04 9

Basic ns-2 § Create scheduler - set ns [new Simulator] § Create node -

Basic ns-2 § Create scheduler - set ns [new Simulator] § Create node - set <var> [$ns node] - example: set n 0 [$ns node] § Create link - $ns <link-type> <node 1> <node 2> <bandwidth> <delay> <queuetype> - example: $ns duplex-link $n 0 $n 1 10 Mb 100 ms Drop. Tail § Schedule event - $ns at <time> <event> - example: $ns at 10. 0 “$ftp start” § Start scheduler - $ns run Katz, Stoica F 04 10

#Create a simulator object set ns [new Simulator] #Create three nodes set n 0

#Create a simulator object set ns [new Simulator] #Create three nodes set n 0 [$ns node] set n 1 [$ns node] set n 2 [$ns node] Example #Create link between the nodes $ns duplex-link $n 0 $n 1 4 Mb 10 ms Drop. Tail $ns duplex-link $n 2 $n 1 1 Mb 10 ms Drop. Tail $ns queue-limit $n 1 $n 2 10 #Create a TCP agent and attach it to node n 0 set tcp 0 [new Agent/TCP] $ns attach-agent $n 0 $tcp 0 #Create a TCP sink agent and attach it to node n 2 set sink [new Agent/TCPSink] $ns attach-agent $n 2 $sink #Connect both agents $ns connect $tcp 0 $sink # create an FTP source set ftp [new Application/FTP] $ftp set maxpkts_ 1000 $ftp attach-agent $tcp 0 #Inject starting events $ns at 0. 0 "$ftp start" $ns at 10. 0 "$ftp stop" $ns at 10. 1 "finish" #Run the simulation $ns run ftp tcp-sink n 0 n 1 n 2 Katz, Stoica F 04 11

nam visualization demo § Now I show a an instance of nam running the

nam visualization demo § Now I show a an instance of nam running the example on the previous slide… We just saw this… tcl script (specification of experiment) Now I will show you this… ns-2 trace file (output) nam Katz, Stoica F 04 12

Analysis Katz, Stoica F 04 13

Analysis Katz, Stoica F 04 13

Project 2: ns 2 -- overview § § Goal: learn how to simulate networks

Project 2: ns 2 -- overview § § Goal: learn how to simulate networks with ns-2, understand how different TCP behaves Task 1 - Familiarize with ns-2 - Write basic scripts to define network topologies, to specify transport agents, to log traces, to parse trace, and to mine the trace data to understand how the transport protocol behaves § Task 2 - Reverse engineering - Given a blackbox TCP implementation, you figure what the blackbox is. - Understand how different TCP behaves under packet losses. - Refer to the reference papers in the last slide. Katz, Stoica F 04 14

Project 2: ns 2 -- requirements § Project details: - § Project 2 web

Project 2: ns 2 -- requirements § Project details: - § Project 2 web page You MUST: 1. use the version of ns 2 supplied on the instructional machines 2. be familiar with the simulation results and the contents of your report, be prepared to answer questions § Project due 11: 59 PM, October 28. Katz, Stoica F 04 15

Reference Papers § § [1] K. Fall and S. Floyd. Simulation-based Comparisons of Tahoe,

Reference Papers § § [1] K. Fall and S. Floyd. Simulation-based Comparisons of Tahoe, Reno, and SACK TCP. Computer Communication Review, 1996. (We strongly recommend to read this paper for project 2. ) [2] L. Brakmo, S. O'Malley, and L. Peterson. TCP Vegas: New Techniques for Congestion Detection and Avoidance. Proc. of SIGCOMM, 1994. (This paper explains TCP Vegas. If you feel the textbook does not cover enough about TCP vegas, please read this paper. ) [3] V. Jacobson and M. J. Karels. Congestion Avoidance and Control. Proc. of SIGCOMM, 1988. (This is the seminal paper in TCP congestion control. ) [4] D. Chiu and R. Jain. Analysis of the Increase and Decrease Algorithms for Congestion Avoidance in Computer Networks and ISDN Systems, 1989. (If you want to know how AIMD achieves efficiency and fairness more in detail, please read this one. ) Katz, Stoica F 04 16