jia-hui huang institute of computer science and information engineering national taipei university...
TRANSCRIPT
JIA-HUI HUANG
INSTITUTE OF COMPUTER SCIENCE AND INFORMATION ENGINEERING
NATIONAL TAIPEI UNIVERSITY OF TECHNOLOGY2007.10.15
Network Simulator – NS-21
Introduction
Methods for network research Analytical
General expression or close form Mathematical model
Emulation Real code Duplicates the functions of one system with a different
system Simulation
Abstract model Behavior of system
4
Introduction (cont.)
Self-Developed Without strong persuasion
Simulation frameworks Commercial
OPNET QualNet OMNEST (commercial version of OMNetT++)
Free NS-2 (network simulator version 2) OMNetT++
5
Introduction (cont.)
Ns-2 is a discrete event simulator Scheduler Advance of time depends on the timing of events
Object-oriented simulator C++ : fast to run, slower to change – protocol
implementation Otcl : slower to run, fast to change – simulation
configuration
Components Ns – simulator itself Nam – network animator
Visualize ns (or other) output
6
Introduction (cont.)
Pre-processing Traffic and topology model
Post-processing Trace analysis, often in awk, perl, or tcl
Simulation procedure
Problems
Simulate the environment
Run with ns-2
Analysis the result
Finish
Modify
No
Finish the simulation
Yes
7
Installation
Platform Unix Windows (cygwin)
Packages Tcl/tk Otcl tclcl Ns-2 Nam Xgraph C++ compiler
Ns AllInOne package
8
Installation (cont.)
Cygwin, AllInOne installation (windows) http://140.116.72.80/~smallko/ns2/setup_en.htm
Installation problems http://www.isi.edu/nsnam/ns/ns-problems.html#general
Cygwin setup gcc
Ns-2 setup Path setting Cygwin/home/user-name/.bashrc
Testing (startxwin.bat) - ~/ns-allinone-x.x/ns-x.x/ns-tutorial/examples
9
TCL script
TCL script for scenario setupScenario script format
Simulator object Trace file Finish procedure Network setup (node, link, agent, parameter…) Other procedure, if any Event scheduling (run simulation, stop simulation …)
10
TCL script (cont.)
Example topology
0 1CBR
#Create a simulator objectset ns [new Simulator]
#Open the nam trace fileset nf [open out.nam w]$ns namtrace-all $nf
#Define a 'finish' procedureproc finish {} { global ns nf $ns flush-trace #Close the trace file close $nf #Execute nam on the trace file exec nam out.nam & exit 0}
11
#Create two nodesset n0 [$ns node]set n1 [$ns node]
#Create a duplex link between the nodes$ns duplex-link $n0 $n1 1Mb 10ms DropTail
#Create a UDP agent and attach it to node n0set udp0 [new Agent/UDP]$ns attach-agent $n0 $udp0
# Create a CBR traffic source and attach it to udp0set cbr0 [new Application/Traffic/CBR]$cbr0 set packetSize_ 500$cbr0 set interval_ 0.005$cbr0 attach-agent $udp0
#Create a Null agent (a traffic sink) and attach it to node n1set null0 [new Agent/Null]$ns attach-agent $n1 $null0#Connect the traffic source with the traffic sink$ns connect $udp0 $null0#Schedule events for the CBR agent$ns at 0.5 "$cbr0 start"$ns at 4.5 "$cbr0 stop"#Call the finish procedure after 5 seconds of simulation time$ns at 5.0 "finish"
#Run the simulation$ns run
12
Related tools
nsBench Graphical User Interface For NS Language - java Features
Nodes, simplex/duplex links and Lans Agents: TCP, UDP, TCP/Reno, … Application Traffic: FTP, Telnet, …. …. http://www.mnlab.cs.depaul.edu/projects/nsbench/
13
Related tools (cont.)
NSG Java based ns2 scenario generator For wireless ad-hoc scenario Features
wireless node Connection between nodes Node movement
http://wushoupong.googlepages.com/ns2scenariosgeneratorchinese
14
Related tools (cont.)
Topology Generator Georgia Tech Internetwork Topology Models (GT-ITM) How closely model correlate with real network ? Transit-Stub model Transit domain
Interconnect stub domains Example topology
15
New protocol for ns
Packet type Structure declaration – packet header Name binding
Bind packet header to TCL interface Usage
Routing agent MANET routing protocol Agent object Tcl hook Important functions
16
Packet type
Packet header #include <packet.h>
#define HDR_PROTONAME_PKT(p) hdr_protoname_pkt::access(p)struct hdr_protoname_pkt {
…. (define some fields of packet)static int offset_;inline static int& offset() { return offset_ ; }inline static hdr_protoname_pkt* access(const Packet* p) {
return (hdr_protoname_pkt*)p->access(offset_); }
17
Packet type (cont.)
Name bindingint protoname_pkt::offset_;static class ProtonameHeaderClass : public PacketHeaderClass {public:
ProtonameHeaderClass()PacketHeaderClass("PacketHeader/Protoname",
sizeof(hdr_protoname_pkt)) { bind_offset(&hdr_protoname_pkt::offset_);}
}
18
Packet type (cont.)
UsagePacket* p = allocpkt();
struct hdr_cmn* ch = HDR_CMN(p); struct hdr_ip* ih = HDR_IP(p); struct hdr_protoname_pkt* ph = HDR_PROTONAME_PKT(p);
ph->….
ih->….
ch->…
19
Routing agent
Agent object#include <agent.h>
….class NewProtocol : public Agent {protected :
…public :
NewProtocol(nsaddr_t);int command (int, const char*const*);void recv(Packet*, Handler*);
….}
20
Routing agent (cont.)
Tcl hook Let NewProtocl to be instantiated from Tcl.static class ProtonameClass : public TclClass {public:
ProtonameClass() : TclClass("Agent/Protoname") {}TclObject* create(int argc, const char*const* argv) {
assert(argc == 5);return (new
Protoname((nsaddr_t)Address::instance().str2addr(argv[4])));}
}
21
Routing agent (cont.)
Important functions Command()
Operations that we went to make accessible from TCL maodv-join-group maodv-leave-group Example - maodv.cc, MAODV_SimScript.tcl, cbr-5-3-2
Recv () Invoked whenever the routing agent receives a packet
22
Needed changes
Needed changes Packet type declaration - \ns-x.xx\common\packet.h Tracing support - \ns-x.xx\cmu-trace.h Tcl library
Tcl\lib\ns-packet.tcl Tcl\lib\ns-default.tcl
Priority queue - \queue\priqueue.cc Make file
23
Example1 - TCP slow start
Transport layer protocol UDP – user datagram protocol (connectionless,
unreliable service) TCP – transmission control protocol (connect-oriented,
reliable, with flow and congestion control service) Connection-oriented – three-way handshaking Reliable – acknowledgment, retransmission Flow control – sender won’t buffers by transmitting to
much and too fast Congestion control – to limit the total amount of data
entering the internet
24
Example1 - TCP slow start (cont.)
Important variables for congestion control – slow start cwnd – congestion window ssthresh – defines threshold between two slow start
phase and congestion control phaseOperations – slow start
When connection begins, increase rate exponentially fast until first loss event (slow start phase)
Set ssthresh = cwnd/2 Set cwnd = 1 and perform slow start process For cwnd >= ssthresh, increase cwnd linearly
(congestion avoidance)
25
Example1 - TCP slow start (cont.)
TCP standards TCP Tahoe – slow start & congestion avoidance
RFC 2581 TCP Vegas TCP Reno
RFC 2581 TCP NewReno
RFC 2582 FACK (forward acknowledgement) SACK (selective acknowledgement)
RFC 2018
26
Example1 - TCP slow start (cont.)
TCP experiment – congestion window TCP Tahoe
Slow-start Congestion avoidance
n0
n1
n2 n3
Simulation topology
Receiver
Source2(UDP)
Source1 (TCP)
27
Example2 – queuing system
Queuing systems M/M/1 M/D/1 …
Notation Arrival process/Service time/Servers M = exponential, D = Deterministic, ….
28
Queuing system – M/M/1 (cont.)
Arrival & departure model Poisson arrival Exponential distribution
single serverParameters
Arrival rate λ Departure rate (service time) μ load (stability condition : ρ < 1)
(# of packets in system)
1
][QE
29
Tips31
Ns document is not easy to understandError message is not very usefulUnderstand and ImplementationImplementation issuesIterative design