JIA-HUI HUANG INSTITUTE OF COMPUTER SCIENCE AND INFORMATION ENGINEERING NATIONAL TAIPEI UNIVERSITY OF TECHNOLOGY 2007.10.15 Network Simulator – NS-2 1.

Slides:



Advertisements
Similar presentations
Network Simulator and problems in installing. Introduction Problems in installing Wired networks modified example2.tcl commands in OTcl usual problems.
Advertisements

1 NS-2 Tutorial COMP R2 University of Manitoba March 4, 2009.
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2004) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
Wireless Communication : LAB 3
Introduction to Network Simulator NS-2 Part I
1 ns-2 Tutorial, part 2 Dave Anderson, Xiaowei Yang (Modified from Polly Huang’s slides)
Network Simulation One tool to simulation network protocols for the Internet is the network simulator (NS) The simulation environment needs to be set-
An Introduction to NS-2 * Gayatri Swamynathan CS 276 TA *some slides are from a presentation by Haobo Yu & Nader Salehi, USC/ISI.
NS-2 Shahin Shayandeh December 2004 Session 2. Ns programming  Create the event scheduler  Turn on tracing  Create network  Setup routing  Insert.
Brief Intro to ns2: The most widely used Network Simulator COMP5416 Advanced Network Technologies Based on: Marc Greis's
Ns-2 Tutorial Exercise (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Adopted from Nicolas’s slides Jianping Wang,
Ns-2 tutorial Karthik Sadasivam Banuprasad Samudrala CSCI 5931 Network Security Instructor : Dr. T. Andrew Yang.
How to Add a New Protocol in NS2 Xu Leiming CSCW Lab. at CS Dept., Tsinghua Univ. June 1, 2001.
5-Jul-141 S.Pushpalatha, Associate Professor, PSNACET.
Introduction to NS. Information Main website Documentation, mailing list archive, tutorial Location of Source codes –C++ files.
15-744: Computer Networking ns-2 Tutorial Based on slides from John Heidemann, Polly Huang, and Amit Manjhi.
Transport Layer 3-1 outline r TCP m segment structure m reliable data transfer m flow control m congestion control.
Transport Layer 3-1 Fast Retransmit r time-out period often relatively long: m long delay before resending lost packet r detect lost segments via duplicate.
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2003) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
CprE 543x – ns-2 Tutorial Zak Abichar, Dept of Electrical and Computer Engineering Iowa State University Ames,
Transport Layer 3-1 Outline r TCP m Congestion control m Flow control.
1 © 2003, Cisco Systems, Inc. All rights reserved. CCNA 1 v3.0 Module 11 TCP/IP Transport and Application Layers.
15-744: Computer Networking L-3 The network simulator ns-2 Slides loosely based on a tutorial by Polly Huang, ETH Zurich.
TCP in Heterogeneous Network Md. Ehtesamul Haque # P.
Submitters: Stella Pantofel Michael Halperin Igor Berman
Department of Electronic Engineering City University of Hong Kong EE3900 Computer Networks Transport Protocols Slide 1 Transport Protocols.
EECS122 - UCB1 Measurements and Modeling Table of Contents 1. Measurements Measurements 2. Modeling and its Shortcomings Modeling and its Shortcomings.
Network Simulator (NS2) 1 Tutorial on Network Simulator (NS2) Hemant Kumar Rath Infonet Lab, Dept of Electrical Engineering IIT Bombay, Mumbai
NS2 Agents Leo Bhebhe. Contents Introduction Application Composition Attaching Transport Agents to Nodes UDP Agent TCP Agents SCTP Agents Agent SRM.
Wireless Networking and Systems CSE 590 ns2 tutorial.
Introduction to NS2 -Network Simulator- -Prepared by Changyong Jung.
Copyright 2003 CCNA 1 Chapter 9 TCP/IP Transport and Application Layers By Your Name.
Transport Layer Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University.
Date : 2010/11/23 Speaker : Chia-Wen Lu 1.  Network Simulation  Introduction to NS2  Simple Simulation Example 2.
Bridging the Gap: Turning a Network Simulation into an Emulation Mac Newbold.
NS2 - Appendix Ming-Feng Yang. 2 2 Outline NS2 Models NS2 Directory Structure Extending NS2 in OTcl Extending NS2 in C++ NS2 related links.
CCNA 1 v3.0 Module 11 TCP/IP Transport and Application Layers.
Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast.
TNK092: Network Simulation - Nätverkssimulering Lecture 3: TCP Vangelis Angelakis.
NetFlow Very useful for traffic analysis Very useful for traffic analysis Standard sampler: Standard sampler: –Cisco Netflow –Juniper Traffic Sampling.
1 Network Simulator Tutorial. 2 Network Simulation * Motivation: Learn fundamentals of evaluating network performance via simulation Overview: fundamentals.
Internet Computing KUT Youn-Hee Han
Quality evaluation of MPEG4 video transmission over GPRS networks.. Presented by: Abdullah M. Rana Multimedia Communication.
1 ns-2 Tutorial Haobo Yu, Nader Salehi USC/ISI
1 NS Fundamentals. USC INFORMATION SCIENCES INSTITUTE 2 OTcl and C++: The Duality C++ OTcl Pure C++ objects Pure OTcl objects C++/OTcl split objects ns.
Ns-2 Tutorial (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Jianping Wang, 2002 cs757 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.
Lab 2, Network Simulator ns2 Shiv Kalyanaraman Yong Xia (TA) Satish Raghunath Sept 4,
Network Simulator Tutorial Wireless Networks. Acknowledgements Material is taken from the presentations by Jim Kurose, University of Massachusetts, Amherst.
Network Simulator 2. Introduction Open source network simulator NS uses two languages: C++ and OTcl  C++ is fast to run but slower to change Kernel 
1 Transport Control Protocol for Wireless Connections ElAarag and Bassiouni Vehicle Technology Conference 1999.
The Creation of NS2 Simulated Environment ( 1 ) LI Chengbo
TNK092: Network Simulation - Nätverkssimulering Lecture #1: Course basics and a first taste of NS2 Vangelis Angelakis Ph.D.
TCP OVER ADHOC NETWORK. TCP Basics TCP (Transmission Control Protocol) was designed to provide reliable end-to-end delivery of data over unreliable networks.
July 7, 2003 Building a Wireless LAN traffic test case in ns2 Radio Science Laboratory Department of Electrical and Computer Engineering The University.
NS-2 Shahin Shayandeh December 2004 Session 1. Ns-2, the Network Simulator  A discrete event simulator Simple model  Focused on modeling network protocols.
Lab 2, Network Simulator ns2
1 NS-2: the network simulator 15 September 2005 Network Lab., SNU Changjee Joo.
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
Ch 1: Simulation of Computer Networks. 1.1 Computer Networks and the Layering Concept Layering Concept Service Interface Protocol.
NS-2 Training 12/12/2011. Introduction  NS-2: Network Simulator Generation 2  Latest Release: 2.35 / Nov. 4, 2011 
NS-2 Simulator 최 종 훈 Contents  About NS  Installation  Based on Linux  Based on Windows  Architecture  Using NS-2  Example  References.
ECE 6610 Sandeep Kakumanu GNAN research Lab
DMET 602: Networks and Media Lab
(Modified from Polly Huang’s and last year’s original)
Network Simulator Tutorial
Introduction to Networks
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Karthik Sadasivam Banuprasad Samudrala
Presentation transcript:

JIA-HUI HUANG INSTITUTE OF COMPUTER SCIENCE AND INFORMATION ENGINEERING NATIONAL TAIPEI UNIVERSITY OF TECHNOLOGY Network Simulator – NS-2 1

Reference Ns document 2

Outline Introduction Installation TCL script Related tools New protocol for NS Examples Conclusion 3

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 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)  Installation problems  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 setup Scenario 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 #Create a simulator object set ns [new Simulator] #Open the nam trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc 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 nodes set 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 n0 set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ $cbr0 attach-agent $udp0 #Create a Null agent (a traffic sink) and attach it to node n1 set 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, ….  …. 

Related tools (cont.) NSG  Java based ns2 scenario generator  For wireless ad-hoc scenario  Features  wireless node  Connection between nodes  Node movement  hinese hinese 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 #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 binding int 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.) Usage Packet* 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 …. 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  Recv ()  Invoked whenever the routing agent receives a packet 22

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 phase Operations – 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

Example1 - TCP slow start (cont.) TCP experiment – congestion window  TCP Tahoe  Slow-start  Congestion avoidance n0 n1 n2n3 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 server Parameters  Arrival rate λ  Departure rate (service time) μ  load (stability condition : ρ < 1)  (# of packets in system) 29

Queuing system – M/M/1 (cont.) queue.tcl  Arrival rate : 30  Departure rate : 33  E[Q] = 10 30

Tips 31 Ns document is not easy to understand Error message is not very useful Understand and Implementation Implementation issues Iterative design

Conclusion Basic concept of NS2 Two levels of simulation Exist modules for NS beginner 32

Internet domain structure Example of Internet domain structure 33