NS2 Ultimate
Classifiers and Routing Modules: Putting a routing modules rtnotif_ and ptnotif_ in a node using “$ns node”

Note: This is a detailed note for the book, Introduction to Network Simulator NS2. You may have to read chapter 6 of the book for better understanding.

Introduction

This post is a sequel of the previous post, which demonstrated the relationship of classifiers, routing modules, and nodes:

What’s in This Post

So far, what we have looks like the figure below. In the previous post, I discussed how the blue block (classifier_) is inserted in to a node.

This post focuses on how two yellow blocks are placed into a node.

The purposes of routing modules rtnotif_ and ptnotif_

Again, a routing module acts as a single point of management for all relevant classifiers in a node. It is an entry point which propagates commands for all related classifiers. From the above figure, a node has 2 default routing modules, which have different purposes.

  • rtnotif_: propagates routing information for all attached classifiers.
  • ptnotif_: propagates transport layer bridging information for all attached classifiers.

By default, you should never directly configure classifiers. If you want to add a routing entry, you should do so through rtnotif_. If you want to attach a (transport layer) agent to a node, you should do so through ptnotif_.

In the following, I will use the notation as indicated in the previous post. Please have a look to refresh your memory.

Structure

Both the routing modules are created using “$ns node”. As in the previous post, I will divide the statement “$ns node” into three parts:

  • Part I. $ns node
  • Part II. Constructor of Class Node
  • Part III. Inserting Routing Modules and Classifiers

In fact, the creation of routing modules happens in Part III only. So I am going straight to Part III.

Part III. Inserting Routing Modules and Classifiers

If you recall, this part carries out the last step in the part II:

$mod register $self

where $mod is the base routing module, and $self is the Node instance that we are working on. This means NS2 executes the following instproc

[f_RT] RtModule/Base::register {node}
-> $self next $node

Here, the only relevant statement is “$self next $node”. This statement invokes the instproc register (same name) of the base class of class RtModule/Base which is class RtModule.

Instproc register of class RtModule

There are 2 related steps within instproc RtModule::register, i.e.,

[f_RT] RtModule::register { node }

      ->

$node route-notify $self

      ->

$node port-notify $self

Now, let’s look at each steps in sequence

  1. [f_NT] Node::route-notify{module}: Insert a routing module $module in the node we are working on. The name of this routing module is $rtnotif_, which propagates routing information for all related (address) classifiers: 
        ->
    if {$rtnotif_ == “”} {
        set rtnotif_ $module
    }
        If
    $rtnotif_
        does not exists, store the input routing module (namely
    $module
        ) in the instvar
    $rtnotif_
        of the node we are working on.


        ->
    else {
        $rtnotif_ route-notify $module
    }
        Otherwise, invoke OTcl commands (defined in C++) which concatenates
    $module
        to the end of the routing module chain whose head routing module is
    $rtnotif_
        .
  2. [f_NT] Node::port-notify{module}: Insert a routing module $module in the node we are working on. The name of this routing module is $ptnotif_, which propagates transport layer bridge information for all related (port) classifiers.
        ->
    lappend ptnotif_ $module
        which stores the input routing module (namely
    $module
        ) as the last entry of the list of routing module
    $ptnotif_
      . Note, a data type ‘list’ in Tcl is similar to ‘array’ in C++.

Summary: What we have done

Again, another long post, isn’t it. But look at the above figure. We have added two more yellow blocks into a node. There are still few more to go. So stay tune!

======================================================

Source: T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2011. Buy it now from Amazon:

  

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