Showing posts with label simulator. Show all posts
Showing posts with label simulator. Show all posts

May 3, 2007

Hacks : Adding Forward Error Correction (FEC) into NS-2 Sender & Receiver Agents


This is a hack for NS FEC sender and receiver agents. The sender agent waits for a request from the receiver and then sends the file. Below is a description on integration of these agents into NS. (For more information, please refer to the ping tutorial)

Forward error correction (FEC) is a system of error control for data transmission, whereby the sender adds redundant data to its messages, which allows the receiver to detect and correct errors (within some bound) without the need to ask the sender for additional data. The advantage of forward error correction is that retransmission of data can often be avoided, at the cost of higher bandwidth requirements on average, and is therefore applied in situations where retransmissions are relatively costly or impossible.

Steps :

  1. Get the following files to put in your NS Agent C++ directory:
    • FEC Agent fec.h fec.cc
    • FEC Sender Agent fec_snd.h fec_snd.cc
    • FEC Receiver Agent fec_rcv.h fec_rcv.cc
  2. 2. Add fec.o, fec_snd.o, and fec_rcv.o to NS Makefile
  3. In packet.h, add "PT_FEC," to the "enum packet_t" list and add "name_[PT_FEC]= "fec";" to the class p_info p_info() function.
  4. Perform a "make depend". Ignore any warnings.
  5. Add the following to the end of tcl/lib/ns-default.tcl:
    • Agent/FEC/Snd set packetSize_ 64
    • Agent/FEC/Snd set rate_ 100Kbps
    • Agent/FEC/Snd set extraPkts_ 0
    • Agent/FEC/Snd set debug_ false
    • Agent/FEC/Rcv set debug_ false
  6. Add the following to the "foreach pair" list in tcl/lib/ns-packet.tcl:
    • { FEC off_fec_ }
  7. Run "make"
  8. Try ns on the example TCL script, fec.tcl
  9. You can also try this TCL multicast script, mfec.tcl


Download the source files, here

tags :

May 1, 2007

NS-2 Emulation Extensions


The network simulator ns-2 is a widely accepted discrete event network simulator, actively used for wired and wireless network simulations. It has a highy detailed model of the lower layers (Physical and MAC) of wireless IEEE 802.11 networks.

Ns-2 has also an emulation feature, i.e. the ability to introduce the simulator into a live network and to simulate a desired network between real applications in real-time.

Within the scope of this project we developed some methods and extensions to the ns-2 to combine wireless network simulation and network emulation. Now ns-2 can emulate an arbitrary IEEE 802.11 network between real applications. Furthermore, our extensions are generic, i.e. can be applied to any network supported in the ns-2.

NS-2 emulation extensions use two methods for network emulation: Single Host and Distributed Clients. In the first method the simulator and all the applications run on one computer. We use User-Mode-Linux virtual machines and emulate a ns-2 netwok among them. The applications run inside the virtual machines and do not notice that they communicate through a simulated network.

In the Distributed Clients method we run the applications and the simulator on separated machines for better scalability. Here we use TUN/TAP virtual network interfaces and map them to nodes in the ns-2 simulator. The network among these TUN/TAP interfaces is again simulated. The applications interact with it in the same way they would interact with a real network.

More Info.

tags :

Apr 30, 2007

Extended Network Simulator NS-2 Nam Editor


The Extended Nam Editor is an editor that allows the graphical creation of ns2 scripts. It extends the basic Nam Editor with the following features:

  1. Integration with existing topology generators
  2. Localization and visualization of set of nodes on large network topologies according to different selection criteria;
  3. Instantiation of agents of any types on all the nodes of a given node set;
  4. Definition of new node types;
  5. Support for simulations of web cache systems.

Topology Generator Interface
The manual generation of complex Network Topology is a tedious and error prone activity.

In order to simulate networks with realistic topologies, it is a common practice to use ad-hoc topology generators, whose output is usually not compatible with the ns2 syntax. Hence, several tools have been developed to translate topology descriptions generated by topology generators in ns-scripts that can be used in the definition of a simulation scenario.

Unfortunately, scripts produced in this way are not compatible with the Nam Editor, hence networks created by common topology generators cannot be modified interactively. Such a limitation is sometimes annoying, in particular when the automatically generated topology needs to be further adapted, e.g. by instantiating agents on particular network nodes.

Nam-Editor provides a graphical interface to:
  • GT-ITM topology generator;
  • INET topology generator;

It is now possible to create, visualize and modify topologies created according to the following topology models:
  1. flat-itm;
  2. hierarchical-itm;
  3. transit-stub-itm;
  4. INET;


More info here

tags :



Jan 24, 2006

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)

Initialization of network simulator event

Things to remember when initialization of network simulator, Ns-2

When a new simulation object is created in tcl, the initialization procedure performs the following operations:

  • initialize the packet format (calls create_packetformat)
  • create a scheduler (defaults to a calendar scheduler)
  • create a "null agent" (a discard sink used in various places)
** Ns-2 is an event-driven simulator, therefore scheduler is a crucial component for simulation to determine all the events to be simulated accordingly.

There are 4 different types of scheduler that is created by using a different data structure:

  1. a simple linked-list,
  2. heap,
  3. calendar queue (default)
  4. and a special type called "real-time".
The actual definition of event is found is ~ns/scheduler.h

class Event {
public;
Event* next_; /* event list */
Handler* handler_; /* handler to call when event ready */
double time_; /* time at which event is ready */
int uid_; /* unique ID */
Event() : time_(0), uid_(0) {}
};
/*
* The base class for all event handlers. When an event’s scheduled
* time arrives, it is passed to handle which must consume it.
* i.e., if it needs to be freed it, it must be freed by the handler.
*/
class Handler {
public:
virtual void handle(Event* event);
};

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.

Jan 23, 2006

Network Simutator, Ns-2 Trace format

Normal Trace Format

This information comes from The ns Manual "Trace and Monitoring Support: Trace File Format" chapter. This trace is used normal wired operations. The trace starts with one of four possible characters.

Event Abbreviation Type Value
Normal Event r: Receive
d: Drop
e: Error
+: Enqueue
-: Dequeue
%g %d %d %s %d %s %d %d.%d %d.%d %d %d
double Time
int Source Node
int Destination Node
string Packet Name
int Packet Size
string Flags
int Flow ID
int Source Address
int Destination Address
int Sequence Number
int Unique Packet ID

Depending on the packet type, the trace may log additional information:

Event Type Value
TCP Trace %d 0x%x %d %d
int Ack Number
hexadecimalFlags
int Header Length
int Socket Address Length
Satellite Trace %.2f %.2f %.2f %.2f
double Source Latitude
double Source Longitude
double Destination Latitude
double Destination Longitude

** For more click here

Jan 22, 2006

Network Simulator, NS-2

Network Simulator, NS-2 is a discrete event based simulator. It's a dual language simulator which consists of Object oriented Tcl/Tk and C++ as part of the front-end interpreter. Users can create simulator object through intrepeter and objects can be instantiated within the intrepreter.

Network Simulator, NS-2 manual can be obtained from here.

I used NS-2 on Cygwin.

There is a wiki on how to install and run Ns-2 on Cygwin.

** Before running Ns-2 cygwin, we need to set the path for Ns-2 in Cygwin

Copy the following path and paste it at the bottom of .bashrc file (this is for Cygwin and Ns-2 version 2.29)
---------------------------------------------------------------

export NS_HOME=`pwd`/ns-allinone-2.29
export PATH=$NS_HOME/tcl8.4.11/unix:$NS_HOME/tk8.4.11/unix:$NS_HOME/bin:$PATH
export LD_LIBRARY_PATH=$NS_HOME/otcl-1.11:$NS_HOME/lib:$NS_HOME/tcl8.4.11/
unix:$NS_HOME/tk8.4.11/ unix:$LD_LIBRARY_PATH

export TCL_LIBRARY=$NS_HOME/tcl8.4.11/library

Basically to start running Ns-2 on Cygwin, we need to initiate the graphical mode by typing "startxwin.bat"














and we can run any ns-2 tcl script by entering the ns command followed by the script

example :

ns example1.tcl