Wednesday, March 17, 2010

Including New Modules into NS2

Your New NS2 Modules
You are doing research. One day you come up with a great idea, and you want to show it to the world how great your idea is. So you decided to go for NS2. You start learning NS2, while developing your idea using C++ and Tcl.

The Coding Completes; Frustration Begins
Great! After a long work, you finish coding in C++ and Tcl. Now, you are asking yourself, "What do I do next?"

Of course you would like to incorporate you codes into NS2, you don't really know how. Frustrated, eh?

Including Your Modules into NS2
The following slide shows you how new modules are incorporated into NS2:
Including Your Modules into NS 2

View more presentations from Teerawat Issariyakul.

------------------------------------------------------------------------------------------------------------
For more information about incorporating new modules into NS2, see Chapter 2 in the following book from Springer:
T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009.

You may also find lecture notes and other resource at the following website: http://www.ece.ubc.ca/~teerawat/NS2.htm

3 comments:

Unknown said...

Hi,
I'm following the steps in Chapter 14 "Developing New Modules for NS2" of
your book; to add a multi flow packet scheduling
mechanism. I've corrected some errors in the code but I can't add the
instproc to simulator :

I've added these lines to ./tcl/lib/ns-lib.tcl

Simulator instproc sch-link { n1 n2 bw delay num_queues } {
$self instvar link_ queueMap_ nullAgent_ useasim_
set sid [$n1 id]
set did [$n2 id]
set link_($sid:$did) [new LinkSch $n1 $n2 $bw $delay $num_queues]
set pushback 0
$n1 add-neighbor $n2 $pushback
}
Simulator instproc add-flow { n1 n2 fid } {
$self instvar link_
set sid [$n1 id]
set did [$n2 id]
$link_($sid:$did) add-flow $fid
}

I've also added the LinkSch definition to ./tcl/lib/ns-link.tcl

But get this error

(_o3 cmd line 1)
invoked from within
"_o3 cmd sch-link _o10 _o13 5Mb 500ns 2"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o3" line 2)
(SplitObject unknown line 2)
invoked from within
"$ns sch-link $n1 $n2 5Mb 500ns $num_queues"

which sounds like the class and the methods added are not binded.

here's my code :

set num_queues [lindex $argv 0]
set ns [new Simulator]
set n1 [$ns node]
set n2 [$ns node]
$ns sch-link $n1 $n2 5Mb 500ns $num_queues

Thanks in advance.

Teerawat Issariyakul said...

You may place your modified code at the beginning of the Tcl file as well.

Unknown said...

Research Networking (RN) is about using web-based tools to discover and use research and scholarly information about people and resources. research networking tools (RN tools) serve as knowledge management systems for the research enterprise.