1 Part II: ns Internals. USC INFORMATION SCIENCES INSTITUTE 2 Outline Fundamental concept Split object: C++/OTcl linkage Plumbing Wired Wireless Scaling.

Slides:



Advertisements
Similar presentations
Jump to first page NS Tutorial: mobile and wireless network simulation Ya Xu USC/ISI June 18, 1999.
Advertisements

Wireless Communication : LAB 3
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
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.
NS2 Chapter 5. Node A node is an OTcl class, but most of its components are TclObjects. All node contain at least the following components An address.
Introduction to Wireless simulations Shao-Cheng Wang.
1 Network Simulation and Testing Polly Huang EE NTU
1 Chapter 3 Otcl Linkage Presenter : 吳龍淵 張群正 2002/03/26.
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.
Random Access MAC for Efficient Broadcast Support in Ad Hoc Networks Ken Tang, Mario Gerla Computer Science Department University of California, Los Angeles.
IEEE OpComm 2006, Berlin, Germany 18. September 2006 A Study of On-Off Attack Models for Wireless Ad Hoc Networks L. Felipe Perrone Dept. of Computer Science.
CMPE 150- Introduction to Computer Networks 1 CMPE 150 Fall 2005 Lecture 22 Introduction to Computer Networks.
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.
Introduction to Network Simulator NS-2 Part II
NS2 Tutorial Aga Zhang Dependable Computing Lab. Outline Introduction Fundamental Skills - Tcl and OTcl Network Simulator - ns-2 Study Project - Mobile.
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.
Introduction to ns-2 Noun Choi Oct. 11, Outline Background ns-2 Internals Short demo Troubleshooting Reference links Q & A.
Introduction to NS2 -Network Simulator- -Prepared by Changyong Jung.
NS2 Tutorial for CS740 Jianming Wu *modified from Aga Zhang.
MOBILE IP SOMULATION IN NS2 Presenter: 吳寶緣. Outlines  Overview  Hierarchical Address Format  Hierarchical Address Format-ex  MoblieIP Demo  Additional.
JIA-HUI HUANG INSTITUTE OF COMPUTER SCIENCE AND INFORMATION ENGINEERING NATIONAL TAIPEI UNIVERSITY OF TECHNOLOGY Network Simulator – NS-2 1.
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.
IP1 The Underlying Technologies. What is inside the Internet? Or What are the key underlying technologies that make it work so successfully? –Packet Switching.
NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address.
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.
Su Wen Department of Computer Science
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.
Design, Implementation and Tracing of Dynamic Backpressure Routing for ns-3 José Núñez-Martínez Research Engineer Centre Tecnològic de Telecomunicacions.
1 ns-2 Tutorial Polly Huang AT&T Labs Research 11 August, 1999.
NS2Work1 LAB 5 Adding New Components High level scripting in otcl Linking otcl and C++ Low level in C++
Group Management in Mobile Ad Hoc Networks Revathi Ranganathan Preeti Venkateswaran.
Network Simulator Tutorial Wireless Networks. Acknowledgements Material is taken from the presentations by Jim Kurose, University of Massachusetts, Amherst.
(Tue) 1 Network Simulator 2 - Introduction for Beginners CNLAB ns - 2 seminar.
The Creation of NS2 Simulated Environment ( 1 ) LI Chengbo
Network Simulation and Simulator Internals 潘仁義
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.
Network Simulator 2 Network Simulator 2 Practice SungKyunKwan-Univ Mobile Computing LAB ( 안혜환
1 NS-2: the network simulator 15 September 2005 Network Lab., SNU Changjee Joo.
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:
Overview of VANET Project(2011) on NS2 Perspective Part 1 of 2 Jae-Myeong Lee Human-centric Mobile Computing Lab.
Jae Chung and Mark Claypool
DMET 602: Networks and Media Lab
(Modified from Polly Huang’s and last year’s original)
NS2_Trace and Monitoring support 報告者:羅士捷
Mobicom ‘99 Per Johansson, Tony Larsson, Nicklas Hedman
Introduction to ns-2: “The” Network Simulator
Karthik Sadasivam Banuprasad Samudrala
Network Performance modelling and simulation
Introduction to ns-2 Noun Choi Oct. 11, 2007.
Aga Zhang Dependable Computing Lab
Presentation transcript:

1 Part II: ns Internals

USC INFORMATION SCIENCES INSTITUTE 2 Outline Fundamental concept Split object: C++/OTcl linkage Plumbing Wired Wireless Scaling

USC INFORMATION SCIENCES INSTITUTE 3 OTcl and C++: The Duality C++ OTcl Pure C++ objects Pure OTcl objects C++/OTcl split objects ns

USC INFORMATION SCIENCES INSTITUTE 4 C++/OTcl Linkage

USC INFORMATION SCIENCES INSTITUTE 5 TclObject Basic hierarchy in ns for split objects Mirrored in both C++ and OTcl Example set tcp [new Agent/TCP] $tcp set packetSize_ 1024 $tcp advanceby 5000

USC INFORMATION SCIENCES INSTITUTE 6 TclObject: Hierarchy and Shadowing TclObject Agent Agent/TCP Agent/TCP OTcl shadow object _o123 Agent/TCP C++ object *tcp TclObject Agent TcpAgent OTcl class hierarchy C++ class hierarchy

USC INFORMATION SCIENCES INSTITUTE 7 TclObject::bind() Link C++ member variables to OTcl object variables C++ TcpAgent::TcpAgent() { bind(“window_”, &wnd_); … } bind_time(), bind_bool(), bind_bw() OTcl set tcp [new Agent/TCP] $tcp set window_ 200

USC INFORMATION SCIENCES INSTITUTE 8 Initialization of Bound Variables Initialization through OTcl class variables Agent/TCP set window_ 50 Do all initialization of bound variables in ~ns/lib/ns-default.tcl Otherwise a warning will be issued when the shadow object is created

USC INFORMATION SCIENCES INSTITUTE 9 Implementation of Bound Variables Class InstVar One object per bound variable – expensive! InstVarInt, InstVarReal, … Created by TclObject::bind() Create instance variable in OTcl stack Tcl_TraceVar() Enable trap read/write to OTcl variable using Tcl_TraceVar() Connect to C++ variable in the trap

USC INFORMATION SCIENCES INSTITUTE 10 TclObject::command() Implement OTcl methods in C++ Trap point: OTcl method cmd{} Send all arguments after cmd{} call to TclObject::command()

USC INFORMATION SCIENCES INSTITUTE 11 TclObject::command() OTcl set tcp [new Agent/TCP] $tcp advance 10 C++ int TcpAgent::command(int argc, const char*const* argv) { if (argc == 3) { if (strcmp(argv[1], “advance”) == 0) { int newseq = atoi(argv[2]); …… return(TCL_OK); } return (Agent::command(argc, argv); }

USC INFORMATION SCIENCES INSTITUTE 12 TclObject::command() $tcp send TclObject::unknown{}$tcp cmd send no such procedure TcpAgent::command() match “send”? Invoke parent: return Agent::command() process and return Yes No OTcl space C++ space

USC INFORMATION SCIENCES INSTITUTE 13 TclObject: Creation and Deletion Global procedures: new{}, delete{} Example set tcp [new Agent/TCP] … delete $tcp

USC INFORMATION SCIENCES INSTITUTE 14 C++ OTcl TclObject: Creation and Deletion invoke parent constructor Agent/TCP constructor parent constructor invoke parent constructor TclObject constructor create C++ object AgentTCP constructor invoke parent constructor invoke parent constructor parent (Agent) constructor do nothing, return TclObject (C++) constructor bind variables and return bind variables and return create OTcl shadow object complete initialization complete initialization which C++ object to create? – TclClass

USC INFORMATION SCIENCES INSTITUTE 15 TclClass TclObject Agent Agent/TCP TclObject Agent TcpAgent NsObject ?? OTcl C++ mirroring Static class TcpClass : public TclClass { public: TcpClass() : TclClass(“Agent/TCP”) {} TclObject* create(int, const char*const*) { return (new TcpAgent()); } } class_tcp; Static class TcpClass : public TclClass { public: TcpClass() : TclClass(“Agent/TCP”) {} TclObject* create(int, const char*const*) { return (new TcpAgent()); } } class_tcp;

USC INFORMATION SCIENCES INSTITUTE 16 TclClass: Mechanism Initialization at runtime startup SplitObject::register{} Create and register OTcl class Agent/TCP TclClass::init() for each statically defined TclClass TcpClass::bind() e.g. Agent/TCP::create-shadow{}  TclClass::create_shadow()

USC INFORMATION SCIENCES INSTITUTE 17 Class Tcl Singleton class with a handle to Tcl interpreter Usage Invoke OTcl procedure Obtain OTcl evaluation results Pass a result string to OTcl Return success/failure code to OTcl

USC INFORMATION SCIENCES INSTITUTE 18 Class Tcl Tcl& tcl = Tcl::instance(); if (argc == 2) { if (strcmp(argv[1], “now”) == 0) { tcl.resultf(“%g”, clock()); return TCL_OK; } tcl.error(“command not found”); return TCL_ERROR; } else if (argc == 3) { tcl.eval(argv[2]); clock_ = atof(tcl.result()); return TCL_OK; }

USC INFORMATION SCIENCES INSTITUTE 19 Class TclCommand C++ implementation of global OTcl commands class RandomCommand : public TclCommand { public: RandomCommand() : TclCommand("ns-random") {} virtual int command(int argc, const char*const* argv); }; int RandomCommand::command(int argc, const char*const* argv) { Tcl& tcl = Tcl::instance(); if (argc == 1) { sprintf(tcl.buffer(), "%u", Random::random()); tcl.result(tcl.buffer()); }

USC INFORMATION SCIENCES INSTITUTE 20 EmbeddedTcl Pre-load OTcl scripts at ns runtime startup ~ns/tcl/lib/ns-lib.tcl: Recursively load ~ns/tcl/lib/ns-lib.tcl: source ns-autoconf.tcl source ns-address.tcl source ns-node.tcl Load everything into a single C++ string Execute this string at runtime startup ~tclcl/tcl-object.tcl Tcl::init(): load ~tclcl/tcl-object.tcl ~ns/tcl/lib/ns-lib.tcl Tcl_AppInit(): load ~ns/tcl/lib/ns-lib.tcl

USC INFORMATION SCIENCES INSTITUTE 21 EmbeddedTcl How it works tcl2c++ tcl2c++ : provided by TclCL, converts tcl scripts into a C++ static character array Makefile.in: tclsh8.0 bin/tcl-expand.tcl tcl/lib/ns- lib.tcl | tcl2c++ et_ns_lib > gen/ns_tcl.cc

USC INFORMATION SCIENCES INSTITUTE 22 Summary TclObject Unified interpreted (OTcl) and compiled (C++) class hierarchies Seamless access (procedure call and variable access) between OTcl and C++ TclClass The mechanism that makes TclObject work Tcl: primitives to access Tcl interpreter

USC INFORMATION SCIENCES INSTITUTE 23 Outline Fundamental concept Split object Plumbing Wired world Wireless world Scaling

USC INFORMATION SCIENCES INSTITUTE 24 ns Internals Discrete event scheduler Network topology Routing Transport Packet flow Packet format Application

USC INFORMATION SCIENCES INSTITUTE 25 Discrete Event Scheduler time_, uid_, next_, handler_ head_ -> Three types of schedulers List: simple linked list, order-preserving, O(N) Heap: O(logN) Calendar: hash-based, fastest, O(1) handler_ -> handle() time_, uid_, next_, handler_ reschedule insert

USC INFORMATION SCIENCES INSTITUTE 26 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_

USC INFORMATION SCIENCES INSTITUTE 27 Network Topology: Link n0n1 enqT_queue_deqT_ drophead_ drpT_ link_ttl_ n1 entry_ head_ tracing simplex link duplex link

USC INFORMATION SCIENCES INSTITUTE 28 Routing n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ Node entry 0 1 enqT_queue_deqT_ drophead_drpT_ link_ttl_ n1 entry _ head_

USC INFORMATION SCIENCES INSTITUTE 29 Routing (con’t) 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

USC INFORMATION SCIENCES INSTITUTE 30 Transport 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_ dst_=1.0 dst_=0.0

USC INFORMATION SCIENCES INSTITUTE 31 Application: Traffic Generator 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_ dst_=1.0 dst_=0.0 Application/FTP

USC INFORMATION SCIENCES INSTITUTE 32 Plumbing: 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 dst_=1.0 dst_=0.0 Application/FTP

USC INFORMATION SCIENCES INSTITUTE 33 Packet Format header data ip header tcp header rtp header trace header cmn header... ts_ ptype_ uid_ size_ iface_

USC INFORMATION SCIENCES INSTITUTE 34 Outline Fundamental concept Split object Plumbing Wired world Wireless world ns scaling

USC INFORMATION SCIENCES INSTITUTE 35 Abstract the Real World Packet headers Mobile node Wireless channel Forwarding and routing Visualization

USC INFORMATION SCIENCES INSTITUTE 36 Wireless Packet Format header data ts_ ptype_ uid_ size_ iface_ IP header cmn header LL MAC 802_ ARP wireless headers

USC INFORMATION SCIENCES INSTITUTE 37 Mobile Node Abstraction Location Coordinates (x,y,z) Movement Speed, direction, starting/ending location, time...

USC INFORMATION SCIENCES INSTITUTE 38 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_

USC INFORMATION SCIENCES INSTITUTE 39 Mobile Node: Components 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

USC INFORMATION SCIENCES INSTITUTE 40 Mobile Node: Components Network interface (PHY) Parameters based on Direct Sequence Spread Spectrum (WaveLan) Interface with: antenna and propagation models Update energy: transmission and reception 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

USC INFORMATION SCIENCES INSTITUTE 41 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 Collision is handled at individual receiver O(N 2 ) messages  grid keeper

USC INFORMATION SCIENCES INSTITUTE 42 Grid-keeper: An Optimization

USC INFORMATION SCIENCES INSTITUTE 43 Outline Fundamental concept Split object Plumbing Wired world Wireless world ns scaling

USC INFORMATION SCIENCES INSTITUTE 44 ns Scaling Limitations to simulation size Memory Run time Solutions Abstraction Fine-tuning (next session)

USC INFORMATION SCIENCES INSTITUTE 45 Memory Footprint of ns Dense Mode 128MB 430

USC INFORMATION SCIENCES INSTITUTE 46 Run Time of ns Dense Mode

USC INFORMATION SCIENCES INSTITUTE 47 Culprit: Details, Details Dense mode tries to capture packet- level behavior Prunes, Joins, … Let’s abstract it out Centralized multicast SessionSim

USC INFORMATION SCIENCES INSTITUTE 48 Centralized Multicast s n1 n2 n3 n4 n5 Centralized Multicast Dense Mode Multicast s n1 n2 n3 n4 n5 Route Computation Unit receiver data prune source

USC INFORMATION SCIENCES INSTITUTE 49 Centralized Multicast Usage $ns mrtproto CtrMcast Limitation No exact dynamic behavior, e.g., routing convergence time Does not mean to replace DM

USC INFORMATION SCIENCES INSTITUTE 50 Further Abstraction Remove all intermediate nodes and links Do not model: Detailed queueing Detailed packet delivery

USC INFORMATION SCIENCES INSTITUTE 51 SessionSim Replication Delay TTL Session Helper: Session Multicast Detailed Packet Distribution s n1 n2 n3 n4 n5 receiver data source n4 n2 s

USC INFORMATION SCIENCES INSTITUTE 52 SessionSim Usage set ns [new SessionSim] instead of set ns [new Simulator] Limitation Distorted end-to-end delay Packet loss due to congestion

USC INFORMATION SCIENCES INSTITUTE 53 Memory Footprint of ns Dense Mode Centralized Multicast SessionSim

USC INFORMATION SCIENCES INSTITUTE 54 Run Time of ns Dense Mode Centralized Multicast SessionSim

USC INFORMATION SCIENCES INSTITUTE 55 Distortion of Centralized Multicast

USC INFORMATION SCIENCES INSTITUTE 56 Distortion of SessionSim

USC INFORMATION SCIENCES INSTITUTE 57 Footnotes My sim still uses too much memory? Or I want large detailed simulation, e.g., Web traffic pattern? Fine-tune your simulator We’ll cover it this afternoon