NS2 First Report Submitters: Stella Pantofel Michael Halperin Igor Berman Simulation of Explicit Congestion Notification(ECN) and Random Early Detection(RED) With TCP Reno and TCP Sack The outline of the project Using NS-2 simulator, we simulate a congested network that uses RED with ECN with following options: – – – – TCP Reno / TCP SACK Different RED threshold parameters . Variable number of connections. The network will have usual links and a satellite link. We will supply results (graphs) that compare the throughput and the congestion window behavior. Example Topologies : The main idea of any chosen topology is to create a bottle neck in order to simulate the congestion problem. In the 1st case the link zero-one is the bottle neck of the topology. In the 2nd case the link two-three is the bottle neck. Description of NS2 options using Tcl • Defining variables/constants: – set NodeNumber 10 • Comments: – # this is comment • New instance of simulator: – set ns [new Simulator] • New node: – set N [$ns node] • New link: $ns <kind of link> <src> <dst> <bandwidth><delay><kind of queue> – Example: set link [$ns simplex-link $N $D 2Mb 1ms RED] Ns2 options continue… • New protocol agent: – set tcpAgent [new Agent/TCP/Newreno] – set tcpAgetn [new Agent/TCP/Sack1] • Attaching to node some agent – $ns attach-agent $n0 $tcpAgent • And sink agent – set sink [new Agent/TCPSink/DelAck] – set sink [new Agent/TCPSink/Sack1] – $ns attach-agent $n4 $sink • Connecting tcp and sink agents: – $ns connect $tcp $sink Parameters to Tcp Agent • Size of window: – $tcp set window_ 8000 • Size of packet – $tcp set packetSize_ 552 • Flow id: – $tcp set fid_ $k • Ecn option: – $tcp set ecn_ 1 Creating new application over Tcp agent • Creation: – set ftp [new Application/FTP] • Attaching: – $ftp attach-agent $tcp • Type: – $ftp set type_ FTP Scheduling Events In format of: $ns2 at <time> <event> • Examples: – $ns at 0.1 "$ftp start“ – $ns at 124.0 "$ftp stop“ • And at the end: – $ns run Red Queue Parameters: • Queue/RED set thresh_ 5 • Queue/RED set maxthresh_ 15 • Queue/RED set q_weight_ 0.002 Remark: Parameters should be set, before defining new instance of queue. ECN options • Red queue marks messages rather than throws them away: – Queue/RED set setbit_ true : turning option on – $redq set setbit_ true : defining particular queue • Tcp agent have to support ecn option: – Agent/TCP set old_ecn_ 1 : turning option on – $tcpAgent set ecn_ 1 : defining particular agent Error model over the link • Creation of loss module: – set loss_module [new ErrorModel] • Rate of loosing packets: – $loss_module set rate_ 0.2 • Loss module uses random generator of uniformly distributed random variable: – $loss_module ranvar [new RandomVariable/Uniform] • Where go lost packets to: – $loss_module drop-target [new Agent/Null] • Connecting loss model with link between 2 nodes: – $ns lossmodel $loss_module $n2 $n3 Random variables and their uses • Uses: – Delays between connections. – Delays of the links. – Size of data. • Example: – Delays between connections are distributed exponentially: Random variables and their uses continue… • Define generator for random variable: – set rng [new RNG] • Define seed to generator (if 0 generates each time new sequence of values. – $rng2 seed 2 • Define new random variable and parameters to it: – set RV [new RandomVariable/Exponential] – $RV set avg_ 0.3 – $RV use-rng $rng1 • Use: – set t [expr $t + [$RV value]] – $tcp set starts $t Traces of the simulation • Simulator allows to get information about the events registered in the network. • Example: – $ns trace-all <filename> • The output file will contain following data: <event><time><source><destination><flags> and more… • By using these files as input to different scripts we can calculate desired statistics. – Example: throughput per time unit on any specified link. Congestion Window Behavior • Each time unit we sample the window size of the given TCP connection. – The command we use in order to sample: • $tcp set cwnd_ • Cwnd_ is the current window size of the TCP connection • The result is recorded in a special file. • Later on this file is processed and a graph is created from its data