ns v2 Workshop Outline 1. Topology Generation, the nodes and the links Kannan Varadhan 2. OTcl and C++: The Duality USC/Information Sciences Institute 3. Routing h kannan@catarina.usc.edu i � Unicast � Multicast � Network Dynamics 18 September, 1997 4. Multicast Transport 5. Issues of Scale The work of K. Varadhan and the VINT project at USC/ISI is supported by the Defense Advanced Research Projects 6. Programming and Simulation Debugging Agency (DARPA) under contract number ABT63-96-C-0054. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the DARPA. Outline Outline 1 2 Nodes Multicast Nodes NODE MULTICAST dmux_ Port Agent Agent NODE Classifier classifier_ Agent Agent dmux_ Agent Agent agents_ agents_ Addr Classifier Node entry <S1,G1> Node entry entry_ entry_ Replicators Multicast classifier_ Classifier <S2,G2> multiclassifier_ Link Link Link Link Link Link Topology Definition Topology Definition 3 4
Classifiers Classifier methods Table of n slots Install entries into classifier – install {} Each slot can point to a TclObject – installNext {} When a packet is received Query entries in classifier — classify () identifies the slot to forward the packet to – elements {} returns current list of elements inserted – slot {} returns handle of object in the specified slot If slot is invalid, the classifier calls no-slot {} Delete entry in a particular slot Many different types of classifiers – clear {} Address Classifiers parse address in packet classify () internal method: receives a packet, and returns a slot MultiPath Classifier returns next slot number to use number for that packet. Replicator uses classifier as a table Topology Definition Topology Definition 5 6 Links Connectors Link Connectors receive incoming packets, and (usually) transmit them to their target_ head_ enqT_ queue_ deqT_ link_ ttl_ Many different types of connectors: Queue holds a certain number of packets. Packets exceeding their queue-size are sent to the queue’s drop-target. drophead_ drpT_ LinkDelay models delay/bandwidth of the link for detailed simulations. TTLChecker decrements TTLs on each packet, drops the packet if the TTL becomes zero. DynaLink transmit packets if the link is up, drop packet otherwise Other tracing related objects Topology Definition Topology Definition 7 8
Connector methods Topology Generation Resources At http://netweb.usc.edu/daniel/research/sims/ Add tracing or monitoring: ntg by Steve Hotz h hotz@isi.edu i – trace – attach-monitors – init-monitor GT-ITM by Ellen Zegura h ewz@cc.gatech.edu i , Ken Calvert h calvert@cc.gatech.edu i TIERS by Matthew Doar h mdoar@nexen.com i rtg by Liming Wei h lwei@cisco.com i , Lee Breslau h breslau@parc.xerox.com i Topology Definition Topology Definition 9 10 Topology Generation OTcl and C++: The Duality Type of Graph Edge Models C++ ntg n -level hierarchy user configurable User’s probability distributions Simulation Script GT-ITM flat random, n -level many different edge hierarchies, transit-stub models networks OTcl ns TIERS 3-level hierarchy Minimum spanning tree + random placement rtg flat random waxman Topology Definition OTcl Linkage 11 12
OTcl Linkage C++ Methods to Access OTcl C++ OTcl The class Tcl class Tcl C++ methods to access the OTcl interpreter – Obtain a handle class TclCommand Basic script to provide limited global commands to the interpreter – Invoke OTcl procedures class EmbeddedTcl Container for Tcl scripts that are pre-loaded at startup – Retrieve the result from the interpreter class TclObject Root of basic object hierarchy in ns – On invocation, pass a result string to the interpreter class TclClass C++ class to set up the TclObject hierarchy class InstVar internal class to bind C++ member variables to OTcl instance variables – Return Success/Failure return codes OTcl Linkage OTcl Linkage 13 14 class Tcl: C++ Methods to access OTcl class TclCommand Tcl& tcl = Tcl::instance (); /* obtain a handle to the interpreter */ if (argc == 2) { /* cmd: foo now */ Defines simple commands that execute in global interpreter context if (strcmp(argv[1], "now") == 0) { tcl.resultf ("%g", clock()); /* pass back the result */ For example, ns-version return TCL_OK; /* return success code to interpreter */ } tcl.result ("command not understood"); /* alternate way of passing result */ return TCL_ERROR; } else if (argc == 3) { /* cmd: foo now i */ h callback if (strcmp(argv[1], "now") != 0) { tcl.error ("command not understood"); /* alternate way to return error */ } char *callback = arv[2]; tcl.eval (callback); /* invoke an OTcl procedure */ tcl.evalc("puts hello, world"); /* another variant */ char* timestr = tcl.result (); /* callback result from the interpreter */ clock() = atof(timestr); } else { Interp* ti = tcl.interp (); /* access the interpreter directly */ ... /* . . . to do whatever */ OTcl Linkage OTcl Linkage 15 16
class EmbeddedTcl: Adding new OTcl code into ns class TclObject container for scripts pre-loaded at startup Basic object hierarchy in ns – ~ Tcl /tcl-object.tcl Hierarchy mirrored in C++ and OTcl – ~ ns /tcl/lib/ns-lib.tcl – scripts recursively sourced by ~ ns /tcl/lib/ns-lib.tcl For example: ~ Tcl /tcl-object.tcl activated by Tcl::init () set srm [new Agent/SRM/Adaptive] ~ ns /tcl/lib/ns-lib.tcl activated by Tcl AppInit () $srm set packetSize_ 1024 $srm traffic-source $s0 OTcl Linkage OTcl Linkage 17 18 class TclObject: Hierarchy and Shadowing class TclObject: Creation/Deletion Mechanisms global procedure new {} TclObject TclObject OTcl instance procedures Object Constructor parent constructor TclObject invoke parent invoke parent constructor constructor constructor Agent Agent create C++ complete complete shadow object initialisation and initialisation and return return Agent/SRM SRMAgent parent constructor object constructor C++ TclObject constructor invoke parent invoke parent Agent/SRM/ constructor constructor ASRMAgent Adaptive bind member bind member return variables and variables and return return _o52 _o52 C++ methods SRM shadow SRM object object C++ class hierarchy and Object OTcl class hierarchy and Object global procedure delete {} OTcl Linkage OTcl Linkage 19 20
class TclObject: Binding Variables Examples of Specify Bound variables makes identical C++ member variables to OTcl instance variables $object set bwvar 1.5m $object set bwvar 1.5mb Syntax $object set bwvar 1500k $object set bwvar 1500kb ASRMAgent::ASRMAgent() { $object set bwvar .1875MB bind("pdistance_", &pdistance_); /* real variable */ $object set bwvar 187.5kB ... $object set bwvar 1.5e6 } $object set timevar 1500m $object set timevar 1.5 Initialisation through OTcl class variables $object set timevar 1.5e9n $object set timevar 1500e9p Agent/SRM/Adaptive set pdistance_ 15.0 $object set boolvar t ;# set to true Agent/SRM set pdistance_ 10.0 $object set boolvar true ... $object set boolvar 1 ;# or any non-zero value $object set boolvar false ;# set to false Other methods: bind () (integers), bind time () (time variables), $object set boolvar junk $object set boolvar 0 bind bw () (bandwidth variables), bind bool () (boolean variables) OTcl Linkage OTcl Linkage 21 22 class TclObject: command () methods class TclObject: command () methods: call sequence Usage: shadow object is accessed by a cmd {} procedure, called “ instproc- $srm distance? ;# instproc-like usage like ” or $srm cmd distance? ;# explicit usage For example, distance? {} is an “instance procedure” of an Adaptive SRM agent C++ methods OTcl instance procedures? int ASRMAgent::command(int argc, const char*const*argv) (1) { TclObject:: No such unknown{} TclObject:: $srm distance? Tcl& tcl = Tcl::instance(); command() procedure $srm cmd if (argc == 3) { distance? if (strcmp(argv[1], "distance?") == 0) (2) { int sender = atoi(argv[2]); Y N match SRMinfo* sp = get_state(sender); "distance?" tcl.tesultf("%f", sp->distance_); return TCL_OK; (3) } invoke parent’s process command() } and return method return (SRMAgent::command(argc, argv)); (4) } OTcl Linkage OTcl Linkage 23 24
Recommend
More recommend