Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jae Chung and Mark Claypool

Similar presentations


Presentation on theme: "Jae Chung and Mark Claypool"— Presentation transcript:

1 http://nile.wpi.edu/NS/ Jae Chung and Mark Claypool
NS2 by example Jae Chung and Mark Claypool

2 OTcl Linkage adding a new basic network object an example
working around making OTcl linkage from C++ code an example creating a simple and dull agent called "MyAgent“ no behavior of an agent (i.e. no packet creation and transmission)

3 Export C++ class to OTcl
MyAgent C++ Network Component Derived from Agent OTCL的物件 Linkage object between C++ and OTCL OTCL Agent/MyAgentOtcl The Linkage Objec

4 啟動時就會產生負責建立C++的object, 只會有一個
How it works NS started  executes static variable "class_my_agent" the "Agent/MyAgentOtcl" class and its appropriate methods (member functions) are created in OTcl space ) create an instance in OTcl space by "new Agent/MyAgentOtcl" "MyAgentClass::create" that creates an instance of "MyAgent" and returns the address. 啟動時就會產生負責建立C++的object, 只會有一個

5 Export C++ class variables to OTcl
configure (or change) variables in C++ from OTcl using the input simulation script. binding functions are placed in the "MyAgent" constructor function - bind(): real or integer variables - bind_time(): time variable - bind_bw(): bandwidth variable - bind_bool(): boolean variable

6 Export C++ Object Control Commands to OTcl
defining a "command" member function of your C++ object ("MyAgent")

7 Execute an OTcl command from C++.
Example: to print message in OTcl space Get the address of “Tcl::instance()” Then you can use function in OTcl

8 Compile and Run Download "ex-linkage.cc" file, and save it under the "ns-2/common" directory. Open "Makefile", add “common/ex-linkage.o" at the end of object file list (OBJ_CC = ). Re-compile NS using the "make" command. Download the "ex-linkage.tcl" file that contains "MyAgent" testing OTcl commands. (see Figure 22 for the input script and the result) Run the OTcl script using command "ns ex-linkage.tcl".

9 Example argc = 2, argv[0], argv[1]

10 Add New Queue Objective priority 15 to Q1 Others to Q2
Total queue size (Q1+Q2) <=PQ Serve Q1 and Q2 in turn

11 Constructor 物件建立時會執行

12

13 Compile and Run Download “dtrr-queue.h“ & “dtrr-queue.cc” files, and save it under the "ns-2/queue" directory. Open "Makefile", add “queue/dtrr-queue.o" at the end of object file list (OBJ_CC = ). Re-compile NS using the "make" command. Download and run the "ex-dtrr-queue1.tcl” file

14 ex-dtrr-queue1.tcl 修改成根據flow id (fid)來判斷
Fid=1 to queue 1, high priority Otherwise, to queue 2, low priority Observe that no loss at CBR flow if it is set to fid=1.


Download ppt "Jae Chung and Mark Claypool"

Similar presentations


Ads by Google