2015-12-25 The Creation of NS2 Simulated Environment ( 1 ) LI Chengbo

Slides:



Advertisements
Similar presentations
Wireless Communication : LAB 3
Advertisements

Introduction to Network Simulator NS-2 Part I
1 ns-2 Tutorial, part 2 Dave Anderson, Xiaowei Yang (Modified from Polly Huang’s slides)
1 NS Fundamentals (contd..) Padma Haldar USC/ISI.
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.
Introduction to Wireless simulations Shao-Cheng Wang.
1 Network Simulation and Testing Polly Huang EE NTU
NS TUTORIAL Padma Haldar USC/ISI 09/04/02.
15-744: Computer Networking ns-2 Tutorial Based on slides from John Heidemann, Polly Huang, and Amit Manjhi.
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2003) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
1 ns-2 Tutorial Kumar Viswanath & Ignacio Solis UC Santa Cruz.
CprE 543x – ns-2 Tutorial Zak Abichar, Dept of Electrical and Computer Engineering Iowa State University Ames,
1 Ns Tutorial Alhussein A. Abouzeid Elect. Eng. Dept./U. of Washington Parts of this educational presentation use examples available.
Day 3 Outline Multicast example (from Day 2) Wireless Misc. utilities
15-744: Computer Networking L-3 The network simulator ns-2 Slides loosely based on a tutorial by Polly Huang, ETH Zurich.
1 2nd European ns-2 Workshop Day 2 Polly Huang ETH Zurich 18 & 19 April.
Submitters: Stella Pantofel Michael Halperin Igor Berman
Jump to first page NS Tutorial: mobile and wireless network simulation Ya Xu USC/ISI September 10th, 1999.
1 Network Simulator (NS-2) Tutorial These slides can be downloaded from:
EECS122 - UCB1 Measurements and Modeling Table of Contents 1. Measurements Measurements 2. Modeling and its Shortcomings Modeling and its Shortcomings.
Ns Simulation of IEEE SC546 Project (Fall 2002) SOO IL KIM JISUN YOON
Introduction to Network Simulator NS-2 Part II
Network Simulator 2(NS2) Yingyue Xu 8/25/2015. Overview: The Network simulator (NS): discrete event simulator for networks. supports wired, wireless,
Network Simulator (NS2) 1 Tutorial on Network Simulator (NS2) Hemant Kumar Rath Infonet Lab, Dept of Electrical Engineering IIT Bombay, Mumbai
QualNet 2014/05/ 尉遲仲涵. Outline Directory Structure QualNet Basic Message & Event QualNet simulation architecture Protocol Model Programming.
Wireless Networking and Systems CSE 590 ns2 tutorial.
10b_ns: CSci551 SP2002 Friday © 2002 John Heidemann1 NS Tutorial, Class 10 CSci551: Computer Networks SP2002 Friday Section John Heidemann.
1 Introduction to Ns-2 Zhibin WU WINLAB, ECE Dept. Rutgers U.
NS2 - Wireless Network Ming-Feng Yang. 2 2 Outline Basic wireless model Extensions wireless model Example - Ad hoc network Example – WLAN Example – Mobile.
MOBILE IP SOMULATION IN NS2 Presenter: 吳寶緣. Outlines  Overview  Hierarchical Address Format  Hierarchical Address Format-ex  MoblieIP Demo  Additional.
1 Part III: Extending ns. USC INFORMATION SCIENCES INSTITUTE 2 Outline Extending ns In OTcl In C++ Debugging.
NS2 - Appendix Ming-Feng Yang. 2 2 Outline NS2 Models NS2 Directory Structure Extending NS2 in OTcl Extending NS2 in C++ NS2 related links.
JIA-HUI HUANG INSTITUTE OF COMPUTER SCIENCE AND INFORMATION ENGINEERING NATIONAL TAIPEI UNIVERSITY OF TECHNOLOGY Network Simulator – NS-2 1.
Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast.
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
Network Simulator ns-2. 2 Agenda Introduction Interface Tcl and OTcl TclCL Simulator Wired network Wireless network Program Assignment.
Chapter 15 The Addressing Structure in NS. The Default Address Format 32 lower bits for port-id, 1 higher bit for mcast and the rest 32 higher bits for.
NS-2 Tutorial. Motivation What’s NS-2 Network simulator –Discrete event simulator It covers multiple layers –Application layer, transport layer, network.
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.
1 ns-2 Tutorial Polly Huang AT&T Labs Research 11 August, 1999.
Lab 2, Network Simulator ns2 Shiv Kalyanaraman Yong Xia (TA) Satish Raghunath Sept 4,
NS2Work1 LAB 5 Adding New Components High level scripting in otcl Linking otcl and C++ Low level in C++
Network Simulator Tutorial Wireless Networks. Acknowledgements Material is taken from the presentations by Jim Kurose, University of Massachusetts, Amherst.
1 Part II: ns Internals. USC INFORMATION SCIENCES INSTITUTE 2 Outline Fundamental concept Split object: C++/OTcl linkage Plumbing Wired Wireless Scaling.
TNK092: Network Simulation - Nätverkssimulering Lecture #1: Course basics and a first taste of NS2 Vangelis Angelakis Ph.D.
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
© Algirdas Pakstas CS3026N Network Analysis, Design and Simulation 1 CT3020: Network Planning and Simulation Week 6b Prof.DrTech. Algirdas Pakštas.
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
Ch7: Link and Buffer Management. 2 Portrait of A Mobile Node Node ARP Propagation and antenna models MobileNode LL MAC PHY LL CHANNEL LL MAC PHY Classifier:
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)
Mobicom ‘99 Per Johansson, Tony Larsson, Nicklas Hedman
Introduction to ns-2: “The” Network Simulator
Karthik Sadasivam Banuprasad Samudrala
Presentation transcript:

The Creation of NS2 Simulated Environment ( 1 ) LI Chengbo

tcl Interpreter With Extensions tcl otcl tclcl U I Event Scheduler Network Component A Little Bit of Review C++

Example Script set ns [new Simulator] set n0 [$ns node] set n1 [$ns node] n0n1 set ftp [new Application/FTP] $ftp attach-agent $tcp $ns at 0.2 "$ftp start" $ns at 1.2 ” exit" $ns run $ns duplex-link $n0 $n1 1.5Mb 10ms DropTail set tcp [$ns create-connection TCP $n0 TCPSink $n1 0]

Basic ns-2: Covered wired & wireless unicast & multicast TCP & UDP errors & network dynamics ns & nam tracing application-level support

Outline for Today ns-2 Internal Making changes New components –in otcl –otcl and C++ Linkage –in C++

ns-2 Internals Discrete Event Scheduler Network Topology Routing Transport Application Packet Flow Packet Format

Discrete Event Scheduler time_, uid_, next_, handler_ handler_ -> handle() time_, uid_, next_, handler_ insert head_ ->

Network Topology - Node n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ Node entry Unicast Node Multicast Classifier classifier_ dmux_ entry_ Node entry Multicast Node multiclassifier_

Network Topology - Link n0n1 enqT_queue_deqT_ drophead_drpT_ link_ttl_ n1 entry_ head_

Routing n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ Node entry 0 1 enqT_queue_deqT_ drophead_drpT_ link_ttl_ n1 entry_ head_

Routing (cont.) n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ 0 1 Addr Classifier Port Classifier classifier_ dmux_ entry_ 1 0 Link n0-n1 Link n1-n0

Transport n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ 0 Agent/TCP agents_ Addr Classifier Port Classifier classifier_ dmux_ entry_ 1 0 Link n0-n1 Link n1-n0 0 Agent/TCPSink agents_ dst_addr_=1 dst_port_=0 dst_addr_=0 dst_port_=0

Application 0 1 n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ 0 Agent/TCP agents_ Addr Classifier Port Classifier classifier_ dmux_ entry_ 1 0 Link n0-n1 Link n1-n0 0 Agent/TCPSink agents_ Application/FTP dst_addr_=1 dst_port_=0 dst_addr_=0 dst_port_=0

Packet Flow 0 1 n0n1 Addr Classifier Port Classifier entry_ 0 Agent/TCP Addr Classifier Port Classifier entry_ 1 0 Link n0-n1 Link n1-n0 0 Agent/TCPSink Application/FTP dst_addr_=1 dst_port_=0 dst_addr_=0 dst_port_=0

Packet Format header data ip header tcp header rtp header trace header cmn header... ts_ ptype_ uid_ size_ iface_

NS-2 Wireless Internal Packet headers Mobile node Wireless channel NS-2 Wireless Internal

Wireless Packet Format header data ts_ ptype_ uid_ size_ iface_ IP header cmn header LL MAC 802_ ARP wireless headers

Portrait of A Mobile Node Node ARP Propagation and antenna models MobileNode LL MAC PHY LL CHANNEL LL MAC PHY Classifier: Forwarding Agent: Protocol Entity Node Entry LL: Link layer object IFQ: Interface queue MAC: Mac object PHY: Net interface protocol agent routing agent addr classifier port classifier 255 IFQ defaulttarget_

Mobile Node: Layer 2 Link Layer –Same as LAN, but with a separate ARP module Interface queue –Give priority to routing protocol packets Mac Layer –IEEE –RTS/CTS/DATA/ACK for all unicast packets –DATA for all broadcast packets

Mobile Node: Layer 1 Network interface (PHY) –Parameters based on Direct Sequence Spread Spectrum (WaveLan) –Interface with: antenna and propagation models –Update energy: transmission, reception, and idle Radio Propagation Model –Friss-space attenuation(1/r 2 ) at near distance –Two-ray Ground (1/r 4 ) at far distance Antenna –Omni-directional, unity-gain

Wireless Channel Duplicate packets to all mobile nodes attached to the channel except the sender It is the receiver ’ s responsibility to decide if it will accept the packet –Whether the sender is close enough –Collision is also handled at individual receivers –O(N 2 ) messages  grid keeper

Outline for Today ns-2 Internal Making changes New components –in otcl –otcl and C++ Linkage –in C++ debugging

Making Changes In C++ space –Straight forward –Recompile In otcl space –source in the simulation scripts –Or recompile –Ex. changing the packet size tcl/ex/simple.tcl CBR source packet size 210 Change to 420

Understanding The Makefile Defined variables –For example c++ compiler in CPP Header files to include in INCLUDES cc files to compiles in OBJ_CC tcl files to merge in NS_TCL_LIB Commands –For example distclean to clean the distribution ns to build ns binary

Adding New Components in otcl otcl and C++ linkage in C++

New Component Purely in otcl Additional.tcl file Adding new files –change Makefile (NS_TCL_LIB) –source in tcl/lib/ns-lib.tcl –recompile

Example: Agent/Message n0 n1 n4 n5 n2 n3 128Kb, 50ms 10Mb, 1ms CC cross traffic SR msg agent

Agent/Message A UDP agent (without UDP header) Up to 64 bytes user message Good for fast prototyping a simple idea Usage requires extending ns functionality SR pkt: 64 bytes of arbitrary string Receiver-side processing

Agent/Message: Step 1 Define sender class Sender –superclass Agent/Message # Message format: “Addr Op SeqNo” Sender instproc send-next {} { $self instvar seq_ agent_addr_ $self send “$agent_addr_ send $seq_” incr seq_ global ns $ns at [expr [$ns now]+0.1] "$self send-next" }

Agent/Message: Step 2 Define sender packet processing Sender instproc recv msg { $self instvar agent_addr_ set sdr [lindex $msg 0] set seq [lindex $msg 2] puts "Sender gets ack $seq from $sdr" }

Agent/Message: Step 3 Define receiver packet processing Class Receiver –superclass Agent/Message Receiver instproc recv msg { $self instvar agent_addr_ set sdr [lindex $msg 0] set seq [lindex $msg 2] puts “Receiver gets seq $seq from $sdr” $self send “$agent_addr_ ack $seq” }

Agent/Message: Step 4 Scheduler and tracing # Create scheduler set ns [new Simulator] # Turn on Tracing set fd [new “message.nam” w] $ns namtrace-all $fd

Agent/Message: Step 5 Topology for {set i 0} {$i < 6} {incr i} { set n($i) [$ns node] } $ns duplex-link $n(0) $n(1) 128kb 50ms DropTail $ns duplex-link $n(1) $n(4) 10Mb 1ms DropTail $ns duplex-link $n(1) $n(5) 10Mb 1ms DropTail $ns duplex-link $n(0) $n(2) 10Mb 1ms DropTail $ns duplex-link $n(0) $n(3) 10Mb 1ms DropTail $ns queue-limit $n(0) $n(1) 5 $ns queue-limit $n(1) $n(0) 5

Agent/Message: Step 6 Routing # Packet loss produced by queueing # Routing protocol: let’s run distance vector $ns rtproto DV

Agent/Message: Step 7 Cross traffic set udp0 [new Agent/UDP] $ns attach-agent $n(2) $udp0 set null0 [new Agent/NULL] $ns attach-agent $n(4) $null0 $ns connect $udp0 $null0 set exp0 [new Application/Traffic/Exponential] $exp0 set rate_ 128k $exp0 attach-agent $udp0 $ns at 1.0 “$exp0 start”

Agent/Message: Step 8 Message agents set sdr [new Sender] $sdr set packetSize_ 1000 set rcvr [new Receiver] $rcvr set packetSize_ 40 $ns attach $n(3) $sdr $ns attach $n(5) $rcvr $ns connect $sdr $rcvr $ns connect $rcvr $sdr $ns at 1.1 “$sdr send-next”

Agent/Message: Step 9 End-of-simulation wrapper (as usual) $ns at 2.0 finish proc finish {} { global ns fd $ns flush-trace close $fd exit 0 }

Agent/Message: Result Example output >./ns msg.tcl Receiver gets seq 0 from 0 Sender gets ack 0 from 1 Receiver gets seq 1 from 0 Sender gets ack 1 from 1 Receiver gets seq 2 from 0 Sender gets ack 2 from 1 Receiver gets seq 3 from 0 Sender gets ack 3 from 1 Receiver gets seq 4 from 0 Sender gets ack 4 from 1 Receiver gets seq 5 from 0

Add Your Changes into ns TK8.0OTcltclclTcl8.0ns-2nam-1 tcl extest lib... examples validation tests C++ code OTcl code ns-allinone mcast mysrc msg.tcl

Add Your Change into ns tcl/lib/ns-lib.tcl Class Simulator … source../mysrc/msg.tcl Makefile NS_TCL_LIB = \ tcl/mysrc/msg.tcl \ … make distclean./configure –Or: change Makefile.in, make distclean, then./configure

Adding New Components In otcl otcl and C++ linkage In C++