Objectoriented programming Protocol layering. Modularity and extensibility. Large scale simulation. Maintenance and reusability. Splitlanguage programming. Scripting language (Tcl). System programming language .(C) | Network Simulator ns-2 Agenda Introduction Interface Tcl and OTcl TclCL Simulator Wired network Wireless network Program Assignment Introduction NS-2: network simulator version 2 Discrete event simulator Packet level simulation Features Open source Scheduling, routing and congestion control Wired networks: P2P links, LAN Wireless networks: terrestrial (ad-hoc, cellular; GPRS, UMTS, WLAN, Bluetooth), satellite Emulation and trace NS-2: Paradigm Object-oriented programming Protocol layering Modularity and extensibility Large scale simulation Maintenance and reusability Split-language programming Scripting language (Tcl) System programming language (C) NS-2: Split Languages Tcl scripts (Tcl/OTcl) Interpreted (interactive) Setup and configuration C codes (C/C++) Compiled (efficient) Algorithms and protocols TclCL (OTcl/C++) Link Tcl/OTcl scripts and C/C++ codes Provide a layer of C++ glue over OTcl NS-2: Split Objects OTcl C++ Pure OTcl objects Pure C++ objects OTcl/C++ . | Network Simulator ns-2 Agenda Introduction Interface Tcl and OTcl TclCL Simulator Wired network Wireless network Program Assignment Introduction NS-2: network simulator version 2 Discrete event simulator Packet level simulation Features Open source Scheduling, routing and congestion control Wired networks: P2P links, LAN Wireless networks: terrestrial (ad-hoc, cellular; GPRS, UMTS, WLAN, Bluetooth), satellite Emulation and trace NS-2: Paradigm Object-oriented programming Protocol layering Modularity and extensibility Large scale simulation Maintenance and reusability Split-language programming Scripting language (Tcl) System programming language (C) NS-2: Split Languages Tcl scripts (Tcl/OTcl) Interpreted (interactive) Setup and configuration C codes (C/C++) Compiled (efficient) Algorithms and protocols TclCL (OTcl/C++) Link Tcl/OTcl scripts and C/C++ codes Provide a layer of C++ glue over OTcl NS-2: Split Objects OTcl C++ Pure OTcl objects Pure C++ objects OTcl/C++ split objects NS-2 TclCL linkage NS-2: A Tcl Script Example /home>ns /home> #!/home/hsieh/ set ns [new Simulator] set nf [open w] $ns trace-all $nf for {set i 0} {$i NS-2: A C++ Code Example static class UdpAgentClass : public TclClass { public: UdpAgentClass() : TclClass("Agent/UDP") {} TclObject* create(int, const char*const*) { return (new UdpAgent()); } } class_udp_agent; UdpAgent::UdpAgent() : Agent(PT_UDP), seqno_(-1) { bind("packetSize_", &size_); } void UdpAgent::sendmsg(int nbytes, AppData* data, const char* flags) { Packet *p; p = allocpkt(); hdr_cmn::access(p)->size() = size_; hdr_rtp::access(p)->seqno() = ++seqno_; .