Saturday, 25 August 2012

Trace File Format in NS2

In the previous post, I showed you how to create a “trace file” in NS2. In this post, I will show you the interpretation of an NS2 trace file.

Example of trace files :-

When using trace-all in NS2, a trace string is created in a trace file. The trace file would look like this.

Trace file format :-

The format of a trace string is shown below:

where 12 fields of the trace string are as follows.

1. Type Identifier:

 • “+”: a packet enque event
 • “-”: a packet deque event
 • “r”: a packet reception event
 • “d”: a packet drop (e.g., sent to dropHead_) event
 • “c”: a packet collision at the MAC level

2. Time: at which the packet tracing string is created .

3-4. Source Node and Destination Node: denote the IDs of the source and the destination nodes of the tracing object.

5. Packet Name: Name of the packet type

6. Packet Size: Size of the packet in bytes.

7. Flags: A 7-digit flag string

 • “-”: disable
 • 1st = “E”: ECN (Explicit Congestion Notification) echo is enabled.
 • 2nd = “P”: the priority in the IP header is enabled.
 • 3rd : Not in use
 • 4th = “A”: Congestion action
 • 5th = “E”: Congestion has occurred.
 • 6th = “F”: The TCP fast start is used.
 • 7th = “N”: Explicit Congestion Notification (ECN) is on.

8. Flow ID

9-10. Source Address and Destination Address: the format of these two fields is “a.b”, where “a” is the address and “b” is the port.

11. Sequence Number

12. Packet Unique ID

Post processing NS2 Result using NS2 Trace

In this post, I will show you a simple (and perhaps the most common way) to create an NS2 trace file. This trace file contains a lot of information. In fact, it contains too much information, which intimidates NS2 users. Don’t worry about it. We will try to interpret NS2 trace files later. For now, let’s focus on how an NS2 trace file can be created.

To create a trace file, you need to do the following two steps:
  1. Create a file to record tracing information.
  2. Record the tracing information to the created file.
Create a File for Writing :-

Tcl uses a command “open” to open a file. The syntax of the command “open” is as follows:
open <filename> <purpose>
where <filename> is the name of the file to be opened, and <purpose> can be
“w” for writing,
“r” for reading, or
“a” for appending
This statement returns a file handle, which can be used to refer to the opened file.
An example of a Tcl statement which opens a file whose name is “” for writing and stores to the file handle in the variable $var is shown below:
set var [ open w ]

Record tracing information in the opened trace file :-

The next step is to record trace information in the opened file. This can be achieved using the following Tcl statement:

$ns trace-all $var

where $ns is the Simulator instance, and $var is the file handle. This statement tells all the tracing objects (e.g., enqT_, deqT_, rcvT_, and drpT_ in the SimpleLink object below) to record information of traversing packets in the trace file whose variable is $var.

There is only one requirement for tracing: The above statement must be located prior to “$ns run”.

After the simulation complete, a trace file would be created. Here is an example of trace files.

The statement “$ns trace-all” inserts tracing object into various places in network topology. The most common place is in a SimpleLink usually used to connect two nodes. The statement “$ns trace-all” inserts few tracing objects into the SimpleLink object as shown above.

A tracing object sits between two NsObject intercepting objects. Once receiving a packet, it prints related tracing information as a line into the trace file. In the above figure, we have four tracing objects:

  • enqT_: Print a line beginning with “+”, indicating an enqueuing event
  • deqT_: Print a line beginning with “-”, indicating a dequeuing event
  • rcvT_: Print a line beginning with “r”, indicating a packet reception event
  • drpT_: Print a line beginning with “d”, indicating a packet dropping event
Tracing Statements in the Trace File:

These tracing objects print information of all traversing packets. Information of packets which do not pass through any of these objects would not appear on the trace file.

The only object responsible for dropping packets in the above figure is queue_. It does so by invoking function drop(p). The function drop(p) in turn sends the packet p to the forwarding NsObject, which in this case is drpT_. It is drpT_, who is responsible for printing dropping information statements (i.e., those begin with ‘d’) in the trace file.

This means that if you drop the packet explicitly (e.g., using drop(p)) without passing the packet through drpT_, no information about dropping packet would appear on the trace file.

IP Routing in NS2

I know. I know. IP is “the most” widely used routing in the computer industry. But, we as people in academic need to be a bit more precise when using buzz words.

IP: refers to IP address. It is different from routing mechanism. IP address is just a hierarchical way of defining an endpoint.
Routing mechanism: is a way of determining the route to get to a given destination. It works according to an underlying routing table.
Routing algorithm: computes a routing table.
Routing protocol: is a set of communication rules, which shall be followed under a certain condition such as a route failure.

Here is a example set of parameters in practice:

Addressing = IP Address
Routing mechanism = Routing table; Route Summary
Routing algorithm = Dijkstra
Routing protocol = OSPF

What about NS2?

By default, NS2 uses the following setting

Addressing = Flat address (1,2,3,…)
Routing mechanism = Address classifiers
Routing algorithm = Dijkstra
Routing protocol = Static (The condition of all the nodes does not change throughout the simulation)

Do You Really Need IP?

I have received quite a few questions like “How do I implement IP in NS2?” My first response would be “this is too vague”. You really have to break down your questions. At least, you have to identify which of the above 4 topics you would like to study.

For example, if you would like to study routing protocols, you’d probably refer to OSPF or BGP routing protocols. If your focus is on the communiation protocols of the routing, you can use the following setting

Addressing: Flat
Routing Mechansism: Classifier
Routing Algrithm: Dijkstra (used by default as a part of OSPF)

which are the default setting of NS2.

Routing in NS2

The default routing protocol of NS2 is static routing. This means that there would be no change in topology throughout the simulation. In this case, NS2 configures the routing information once when the simulation start with the OTcl statement “$ns run”. The process proceeds as follows:

Step 1: [OTcl] Simulator::run
Step 2: [OTcl] Routelogic::configure
Step 3: [OTcl] Agent/rtProto/Static::init-all
Step 4: [OTcl] Simulator::compute-routes
Step 5: [OTcl] Simulator::computer-flat-route
Step 6: [OTcl] RouteLogic::compute
Step 7: [OTcl] Simulator::populate-flat-classifier

Step 6: The OTcl class RouteLogic is bound to the C++ class with the same name (see file ns-2.35/routing/,h). The OTcl command compute simply executes the funciton compute_routes(…) in the C++ domain. From this point, you have look closely of what NS2 does and apply necessary changes to fit your needs.

Step 7: See how NS2 populate the routing information to all the Nodes. You will need to look into this step to see how routing information are delivered to all related Nodes.

Network Simulator 2 Tutorials

1.  For Learning about Network Simulator 2 basics you can use Marc Greis Tutorials here.

2. You can use following materials

Install Mannasim Patch in NS 2.34 for Wireless Sensor Network Simmulation

1. Download Mannsim Patch for NS 2.34 here.

2. Type the following command on the ns-allinone-2.29 folder:
  • patch -p1 < ns2.34-mannasim-gcc4.3.patch
3. Install NS 2.34 as shown in previous post . 

To test MannaSim installation two simulation scripts are provided bellow. The first one simulates a flat network of homogeneous sensors and the second a hierarchical network composed of two diferent classes of sensor nodes.

If you have any installation problem then post comments......

Install NS 2.34 in Ubuntu 10.10

1. Download & install some packages from repository by following commands :
  • $ sudo apt-get update
  • $ sudo apt-get install build-essential autoconf automake libxmu-dev 
2. Download  ns-2.34 and extract in your home directory.

3. Install the development files for X Windows plus the g++ compiler:
  • sudo apt-get install xorg-dev g++ xgraph
4.  Edit line 6304 of "otcl-1.13/configure"  from SHLIB_LD="gcc -shared" to SHLIB_LD="ld -shared"

5. Now run command in terminal : 
  • $  ./install
6. Set environment variables
  • $ gedit ~/.bashrc
7. Add the following lines to the end of the file. Remember replace “/your/path” by the folder where you have     stored extracted the ns-2 file (For example, if your Linux account name is blackpearl, and you have
    extracted  the file to your home directory, you have to change /your path to /home/blackpearl).


8. Ensure that it immediately takes effect:
  • $ source ~/.bashrc
9. You can test the installation by doing the following:
  • $ cd ns-2.35
  • $ ./validate

Friday, 3 August 2012

Latest swype keyboard for Samsung Galaxy SL-I9003

  • Phone must be rooted
  • Root Explorer application(Link)
  • Swype.apk & (download links are below)

Procedure: (ALWAYS, Backup files. Just in case!)

  1. Download the 2 files given from the links below.
  2. Open Root Explorer.
  3. Paste the downloaded Swype.apk to "/system/app " folder.
  4. Now paste the to "/system/lib " folder
  5. Close root Explorer and reboot phone.

 Not working on other phones...Only for SGSL-I9003

Superb Fonts for Samsung Galaxy

Here is the link of installable APKs for the phone.

Download link: FONT COLLECTION

How to install ?

  1. Extract zip file.
  2. Transfer APKs to phone.
  3. Install it and check out font in settings,entry will be available of installed font.

Deodexed firmware for Samsung galaxy sl i9003

Here is the Download Links: - 104 MB (new) - 104 MB (new) - 100 MB (new) - 104 MB (new) - 117 MB - 117 MB (116.1 MB)

New Link to DDKP2 Deodex File: Link2 (115.11 MB)
Deodex_XXKPQ Credit: Manrock

New Link to XXKPQ Deodex File: Link2

Deodex_XXKPN Credit: jZanetti (113.5 MB) (108.26 MB) (117.01 MB) ( 107 MB) Updated

Delete unwanted Apps (202.52 KB)


Other CF-ROOT's

For Flashing XXKPM (Via ODIN)
1. Flash xxkpe pit,apboot,pda,phone,csc.
2. Falsh xxkpm (pda)

For CWM Recovery and Rooting:
3. First Install CF-ROOT. Pl. refer to the CF-ROOT link. Flash it through ODIN as pda.

For De-Odexing:

4. Copy the to the root of the external SD card.
5. Go to CWM Recovery mode and flash the zip.6. Done De-Odexing.
7. Reboot (Delete does not work without rebooting after de-odexing)8. Flash from CWM Recovery to delete unwanted apps.

Samsung Galaxy SL I9003 Latest Gingerbread 2.3.6 XXKPQ[Official European Firmware]

Download Link : XXKPQ[2.3.6]


CF-ROOT for All Gingerbread Firmwares of I9003

Samsung Galaxy SL I9003 Latest Gingerbread 2.3.6 DDKP3[Official Indian Firmware]

Download Link : DDKP3[2.3.6]

Version : An Official Samsung Released Stock ROM

How to upgrade firmware using ODIN in Samsung galaxy SL-i9003?

  • Before proceeding to update, you need to ensure that you have synced all your contacts with your Google Account, all sms, applications, videos and music files which are there in your phone should be taken a backup or else the data will be lost. Anything which is in SD card will not be lost, so you can alternatively move to SD Card.
  • Next up remove the SIM card as well as the external SD cards if any in your phone, just to make sure that in an unlikely event the data in it doesn’t get corrupted,
  • Ensure that you have kept original USB cable handy which you have got with your Galaxy SL I9003 and also the Galaxy SL I9003 device,
  • Additionally, ensure that your phone has at least more than 50% of battery power left, this is just an advisory which if followed then you will not experience any difficulties as while updation of the device the battery consumption is at a maximum, Anything less than 50% of battery is not recommended to go ahead with as its dangerous to proceed.
  • Ensure that your computer/laptop which runs on a XP, Vista or Window s 7 OS the firewall and other antivirus programs are disabled and also you should have admin privileges to download and install the software including the drivers and also along with this you will be requiring the USB port on your computer which supports USB 2.0.
  • (Optional) Many of the Galaxy SL I9003 users have reported the problem that they are unable to get into the download mode which is the top most necessity for updating your device, so for all those just follow the given instructions which are mentioned below and you can easily fix the download mode and also the recovery mode bug. This procedure is only for those w hose devices unable to get into the download mode and the recovery mode.
  • Please note that flashing with the firmwares doesn’t mean that you are ROOTING your device. If you have flashed with Voodoo Lag fixes then too you can easily flash your device with this firmware.
  • Ensure that you have closed the KIES completely and also disable any firew alls, antivirus if any.

  • Download firmware from or If downloaded firmware contain 4 files like Boot, CODE, Modem, CSC
    then follow procedure from 1 otherwise go to step 4.
    1. Connect phone via USB cable after going in download mode to Computer.
      [The download mode can be entered by holding the Volume Down button + the Home key button (the middle button). While holding these both buttons, you need to switch ON your device.]
    2.  Now , as soon as you get into the download mode, you will have to connect the Galaxy SL I9003 to the computer with the help of USB cable w hile Odin opened in the desktop. As soon as you connect the phone, you will see that first ID:COM box as show n below will turn yellow and in the message box you will see that it will show ADDED as show n the below snapshot and after that you will have to add the files respectively as shown below ,

      PIT – latona_20110114.pit,
      Phone – MODEM_I9003XXKPE_REV_00_CL1041909.tar.md5,
      CSC – GT-I9003-CSC-MULTI-OXAKPE.tar.md5
    3.  Check that Re-partition option is checked.
    4. If it contain only one tar file then give path to PDA in odin flash tool.
      Files Added in XXKPQ
    5. Click on start.
    6. Phone will restart after firmware upgrade.If phone doesnt start and goes on loop mode at samsung logo then open phone recovery mode[The recovery mode can be entered by holding the Volume Up button + the Home key button (the middle button). While holding these both buttons, you need to switch ON your device.] and clear cache partition and wipe all data.