Showing posts with label nodes. Show all posts
Showing posts with label nodes. Show all posts

Mar 29, 2006

How to get the number of nodes in the network in C++ code

Here's the code on how to get the number of nodes in the network based on C++ code for Ns2



For more info, click here

Tags :

Jan 24, 2006

What kind of configuration for a node?

Procedures to configure an individual node can be classified into:

  • Control functions ($node entry - entry point to a node, $node reset - reset all agents at the node)
  • Address and Port number management, unicast routing functions ($node id - return the node number) , agents are attached to a specific port for a node, $node agent (port) will return the port of the agents are attached to
  • Agent management - attach agent - will attach agent to a port
  • Adding neighbors - each node will keep track of nearby neighbor through instance of neighbor_
Overall node configuration can be done by $node node-config

The question is : "What happen when a node is created?"

As I am peeling the layer of Ns-2, after initialization of Ns-2 simulator, the next step would be to create a node. So the question that one should be asking is "What happen when a node is created?"

Actually a node is comprises of classifier objects. The node itself is a standalone object in oTcl. There are 2 types of nodes, an unicast node and a multicast node. An unicast node comprises of address classifier (classifier_) and port classifier (dmux_).

A node will contain an address that will be increased montonously from the initial value of 0. It will also a list of all connected neighbors.

So what the classifier is for?

The classifier will sit in the node and will have the following :

  • all the agents connected (eg. Tcp, sink, ...)
  • a node type identifier (type of node)
  • a routing module (what type of routing method is used eg. unicast, multicast, etc)

Links properties of two nodes

To send packets between two nodes, there should be a link between two nodes. In Ns-2, the link properties can be modified to effect bandwidth, delay and queue type.

Link Types

A data rate is the flow of data measured in bits across a network, through an Internet connection, or between I/O devices such as disk drives. NS-2 supports emulation a number of different data flow types across a variety of wired and wireless media links. Links can be used to simulate different topologies such as mesh, point to point, star network topology.

After creating a set of nodes in the tcl script, (for this example we will just make two nodes) we can start by making a simple link, as with the node being composed of classifiers, a simple link is built up from a sequence of connectors. The following command describes the syntax to link two nodes with a simplex-link "$ns duplex-link node node bandwidth delay queue_type":
set ns [new Simulator]set node0 [$ns node]
set node1 [$ns node]

$ns simplex-link $node0 $node1 1Mb 10ms DropTail

The command creates a link from node0 to node1, with specified bandwidth and delay characteristics, the link uses a queue of type DropTail.

The "simplex-link" is a uni-directional link which means that traffic can only travel in one direction along the link. Therefore in order to have bi-directional traffic the "duplex-link" should be used allowing communication in opposite directions simultaneously.

note: two simples-link's in opposite direction are equivalent to one duplex-link, e.g: duplex-link, e.g:

$ns simplex-link $node0 $node1 1Mb 10ms DropTail
$ns simplex-link $node1 $node0 1Mb 10ms DropTail


the same result can be achieved with:

$ns duplex-link $node0 $node1 1Mb 10ms DropTail

Bandwidth and Delay

Both the commands above create a link from node0 to node1, with specified bandwidth and delay characteristics, these characteristics can be altered by changing the relevant parameters. The first parameter is bandwidth (in examples above "1Mb"), this is the amount of data that can be passed along the link channel in a given period of time, this parameter can be given in decimal form, for example "0.056Mb" which could also be achieved with "56Kb".

The second parameter affects the delay characteristics of the link, these characteristics can be used to simulate the delay which may be caused by propagation - the time the signal takes to travel across the cable length, noise - external signals effecting signal quality, or processing - delay caused by processing of traffic, this is given in milliseconds.