370 likes | 466 Views
Performing RWA Simulation With NS. An introduction to NS & RWA simulation constructs. Outline. Part I: NS Programming Basics Object oriented mechanisms Overview of NS Simulator The Lamp Example Packet Handling in NS—from a transport protocol’s perspective
E N D
Performing RWA Simulation With NS An introduction to NS & RWA simulation constructs
Outline • Part I: NS Programming Basics • Object oriented mechanisms • Overview of NS Simulator • The Lamp Example • Packet Handling in NS—from a transport protocol’s perspective • Part II: Build in NS a platform for RWASimulation • Network Model • Architectural Overview • Internals…
What’s Object Oriented… • Object An object is a software bundle of variables and related methods.[java.sun.com] • Variable => State • Methods => Behavior • OOP. A software design method that models the characteristics of abstract or real objects using classes.[java.sun.com]
Why Object Oriented… • Modularity • Easy for maintenance • Easy for code Reuse • Information hiding • Transparency • Security • Inheritance • Structuring and Organizing Software
Object Oriented Programming structa Classa member v1;member v2;method m1;method m2; … variable v1;variable v2; … Classbbase class a member v2b;method m2b; … procedurep Some operation on instances of struct a
C++Compiled Hierarchy OTclInterpreted Hierarchy NS – A Schematic Overview
NS – A Schematic Overview • C++ /OTcl Implementation • C++ and OTcl Interaction • OTcl • Object Implementation • Simulation Scripts • What to do? • For ordinary users • For Advanced users
An Example -- Lamp • May change ON/OFF Status • May change brightness • Status and Brightness may be monitored
From this example,You will know how to… • Implement a class in C++ • Implement a class in OTcl • Combine OTcl and C++ codes • Write simple simulation scripts
An Example: Lamp • Interfaces: switch: switch the ON/OFF status of the lamp object show_status: Show the current ON/OFF status of the lamp object brighten: make the lamp object brighter darken: make the lamp object darker • Member variables status: current status of the lamp object, {ON, OFF} brightness: current brightness of the lamp object in integer voltage, current, resistance: electro. character. of the lamp object OTcl C++ OTcl C++
Lamp Implementation in C++ class Lamp_C: public TclObject { private: real resistance, current, voltage; int brightness; public: Lamp_C(real r) {resistance = r;} void brighten(int step); void darken(int step); } void Lamp_C::brighten(int step) { resistance -= log(step); //need check here!!! current = voltage/resistance; brightness = C*pow (current, 2); } void Lamp_C::darken(int step) { resistance +=log(step); //need check here!!! current = voltage/resistance; brightness = C*pow (current, 2); } … Lamp_C mylamp = newLamp_C(50.0); mylamp.brighten(10); mylamp.darken(30); …
Lamp Implementation in OTcl Class Lamp_TCL Lamp_TCL set status OFF Lamp_TCL set brightness 0 Lamp_TCL instproc switch { state } { $self instvar status if {$state != “”} { set status $state } return $status } Lamp_TCL instproc show_status { } { $self instvar status puts “Current status is :$status” puts “Current brightness is :$brightness” } C:\ns-2.1b8win\ns↲ % % set mylamp [new Lamp_TCL] % $mylampshow_status % $mylampswitch ON % $mylampshow_status Result: Current status is :OFF Current brightness is : 0 Current status is :ON Current brightness is : 0
Comparing C++ and OTcl • Class Lamp_TCL • Lamp_TCL set status OFF • Lamp_TCL set brightness 0 • Lamp_TCL instproc switch { state } { • #... • } • Lamp_TCL instproc show_status { } { • #... • } • class Lamp_C: public TclObject { • private: • real resistance, current, voltage; • int brightness; • public: • Lamp_C(real r) {resistance = r;} • void brighten(int step); • void darken(int step); • } • void Lamp_C::brighten(int step) { • // … • } • void Lamp_C::darken(int step) { • //… • }
NS: OTcl and C++ Combined Static class LampClass:public TclClass { public: LampClass::TclClass(“Lamp_TCL”) {} TclObject * create(int, const char * const *) { return (new Lamp_C( )); } }class_Lamp; Int Lamp_C::init( ){ … bind(“brightness”,&brightness); … } • int Lamp_C::command(int ac, const char*const* av){ • if (strcmp(av[1], “brighten") == 0){ • int step = atoi(av[2]); • brighten(step); • return TCL_OK; • } • if (strcmp(av[1], “darken”) == 0) { • int step = atoi(av[2]); • darken(step); • return TCL_OK; • } • return TclObject::command(ac,av); • }
NS: OTcl and C++ Combined • if (strcmp(av[1], “darken”) == 0) { • int step = atoi(av[2]); • Tcl & tcl = Tcl::instance(); • char cmd[50],ret[10]; • sprintf(cmd, “%s switch”, name()); • tcl.eval(cmd); • if(strcmp(tcl.result(), “OFF”)){ • return TCL_OK; • } • darken(step); • return TCL_OK; • }
NS: OTcl and C++ Combined C:\NetSim\ns-2.1b8a-win\ns↲ % %set mylamp [new Lamp_TCL] % $mylampshow_status % $mylampswitch ON % $mylampbrighten 100 % $mylampshow_status % Result: Current status is :OFF Current brightness is : 0 Current status is :ON Current brightness is : 32 • Use OTcl –magic of manipulating: • Configuration, setup and one-time stuff • Manipulating existing C++ objects • Use C++ –power of Computing: • Packet processing • Computational complex jobs • Anything you like !
Lamp Conclusion • Interfaces: switch, show_status, brighten, darken brighten, darken • Member variables status brightness, voltage, current, resistance • Implementation • C++/OTcl • OTcl Invocation in C++ : tcl.eval(...), tcl.result(...); • C++ Invocation in OTcl : Lamp::command(...); • Variable binding: bind(...);
Packet Handling in NS:From A Protocol’s Perspective int RWAAgent::command(int argc, const char * const * argv){ … if (strcmp(argv[1],”get-connect-request”) = = 0){ Packet *pkt = allocpkt(); hdr_rwa *hdrrwa = hdr_rwa::access(pkt); hdrrwa->msg_type = CONNECTION_REQUEST; … send(pkt,0); } … } >>>
Packet Handling in NS:From A Protocol’s Perspective void RWAAgent::recv(Packet* pkt, Handler*){ hdr_rwa *hdrrwa = hdr_rwa::access(pkt); int msgtype = hdrrwa->msg_type; … switch (msgtype){ case CONNECTION_REQUEST: //process this packet … break; … } Packet::free(pkt); }
Build in NS a platform for RWA Simulation • Extensions to Class Simulator • Extensions to Class Node • RWA Agents new! • Connection Request Generator new!
Components • DWDM Node • Interfaces , Fibers, Wavelengths • Wavelength Converter • RWA Agent • Simple Signaling(Connection Setup/Teardown) • Routing (Fixed, Explicit Routing) • Connection Request Generator • Arrival Rate • Hold Time
Architectural Overview Linked_DWDM_nodes_ Linked_interfaces_ Linked_RWA_Agents_
Architectural Overview RWA Agent DWDM Node • Edge Node • Transit Node Connect Request Generator RWA Peer
Internals of Connection Request Generator • Descriptions • Base Class: TrafficGenerator • Functionality: generating connection request • Hold time … • Destination node… • Wavelength change allowed ? • “$agent get-connect-request $ht $dst $change_allow” • Configurable Parameters: • Mean arrival rate • Mean hold time
Internals of RWA Agent • Descriptions: • Base Class: Agent • Functionality: • Packet processing • Connection request/setup/release • Route lookups • Change node status • A list of timers • Connection timeouts …
Internals of RWA Agent • OTcl part • Route lookups • Interfacing with Node • C++ Part • Receiving/processing/sending packets • Connection timeouts
Structure of A RWA Packet struct hdr_rwa{ int src, dst; int sid; int msg_type; int fid, lambda; char er[MAX_HOPS*5]; int rtptr; … } • Message Types: • CONNECTION_REQUEST_MSG • CONNECTION_RELEASE_MSG • CONNECTION_CONFIRM_MSG • CONNECTION_BLOCKED_MSG • EXPLICIT_ROUTE_MSG • Global Session ID: • NODEID * CONST + local_sid …
Finding RWA Peers Node/DWDM instproc get-rwa-agent {peer_node} { $self instvar linked_rwa_agents_ set na [llength $linked_rwa_agents_] for {set i 0} {$i < $na } {incr i} { set rwa_agent [lindex $linked_rwa_agents_ $i] if {[$rwa_agent set peer_node_] == $peer_node} { return $rwa_agent } } return -1 }
Internals of DWDM Node • Descriptions • Base class: Node • Functionality • Management of physical resources • Data structures • Lambda_table • Converter_table • ER_routing_table • Connection_table
Internals of DWDM Node • OTcl part • Attaching RWA agents/Traffic generator • Interfacing with RWA • Physical interface mapping (objectindex) • C++ Part • A Lambda table /converter table /connection table • Connection query interface • Nodal statistics • Static Routes
struct connect_struct{ short src, dst; int global_sid_; short in_lambda, out_lambda; short in_inf, out_inf; short in_fid, out_fid; short prevhop; int holdtime; int er_entry; entry_status status; }; Connection Table Structure sid = NODEID * CONST + local_sid [Prefix][local] [Globally Unique]
To Start Simulation… • Create Network Topology • Create DWDM Nodes • Build Links between Nodes • Configure RWA Agents on every node • Install Traffic Generator on Edge Nodes • Configure Traffic Generators • Install Static Routes On Edge Nodes • Start Traffic and do an “$ns run”
Thank You! Questions are welcome…