Saturday, May 2, 2009

NS2 trace-queue v.s monitor-queue

In NS2, we may wonder the queue behavior under the specific network setting and configuration. NS2 provides two mechanisms trace-queue and monitor-queue for users to observe the queue dynamics.

However, which one should we use ? If you prefer the event-based and packet-based analysis, then please use trace-queue. For sample-based analysis and time-aggregated statistics, the monitor-queue is a better choice.

# example 1: capture every packet in the queue of the link of n0 to n1, and store the trace in qm.tr

set f1 [open qm.tr w]
$ns trace-queue $n0 $n1 $f1

# example 2 : sample the q every 0.1 sec. store the trace in qm.mon

set qm [$ns monitor-queue $n0 $n1 [open qm.mon w] 0.1];
[$ns link $n0 $n1] queue-sample-timeout;


Thursday, April 30, 2009

Kill Tasks in Windows XP using DOS command

A multitask application if not well written may leave unterminated tasks in OS.

Try to kill unwanted tasks using command "tasklist" first.
After getting the task ID you want to delete, then type "taskkill /PID your_task_id"
or "taskkill /F /IM your_prog_name".

What is the difference between array address ary and &ary in C

What is the difference between array and &array in visual C++? given
int array[] = {3,4,5,2,9};
int *ptr1, *ptr2;

if we assign ptr1=array and ptr2=&array, the compiler will complain that
cannot convert from 'int (*)[5]' to 'int *' for ptr2=&array. That is because &array return pointer to array of integer of size 5. and array return pointer to integer.

We can experiment another statement as follows
printf("(&array+1) address= %d\n",(&array)); and
printf("(array+1) address= %d\n",(array));


Then the address difference between (&array+1) and (array+1) is 1310592-1310576=16 bytes since (&array+1) increase 20 bytes and (array+1) increase 4 bytes from the base address of the array.

On the other hand, if we have the statements as follows.
ptr1=array;
ptr2=(int*)&array;
printf("(&array) address= %d\n",ptr1);
printf("(array) address= %d\n",ptr2);
i.e. cast the type of &array into (int*), then above prints will be the same.

Tuesday, April 28, 2009

NS2.33 installation in Linux Ubuntu

It may be a frustrated experience during the installation of NS2, the following provides useful steps to help install Network Simulator 2.33 in Ubuntu.

1. download ns-allinone-2.33.tar.gz
2. copy ns-allinone-2.33.tar.gz to /home/username.
3. sudo apt-get install build-essential (for gcc)
sudo apt-get install g++
sudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev
sudo apt-get install libxmu-dev.

4. cd /home/username
tar xvfz ns-allinone-2.33.tar.gz

5. cd ns-allinone-2.33.tar.gz
./install


6. Add environment variables by typing "gedit .bashrc"

export PATH=$PATH:/home/username/ns-allinone-2.33/bin:/home/username/ns-allinone-2.33/tcl8.4.18/unix:/home/username/ns-allinone-2.33/tk8.4.18/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/username/ns-allinone-2.33/otcl-1.13:/home/username/ns-allinone-2.33/lib
export TCL_LIBRARY=$TCL_LIBRARY:/home/username/ns-allinone-2.33/tcl8.4.18/library

7. Activate the new environment variables by directly typing
"source ~/.bashrc" or log-out Ubuntu to reload the environment variable

8. cd /ns-allinone-2.33/ns-2.33
./validate

9. sudo apt-get install gawk gnuplot if you prefer.

10. type command "ns" in the terminal. If it shows "%", then you are done.

For those who are interested in ns2 tcl scripts, the following is a link useful for novices http://www.isi.edu/nsnam/ns/tutorial/

~Install the share folder for Sun VirtualBox

Sometimes, we need to share files between the host and guest OS in the virtual machine. However, how can we achieve it? The followings are steps using the window host and ubuntu guest running in Sun VirtualBox as an example.

(A) Install the Linux Guest additions in the virtual box first.

(a.1) sudo apt-get install dkms
(a.2) mount VBoxGuestAdditions.iso as Linux guest's virtual CD
(a.3) cd /media/cdrom0
(a.4) sudo sh ./VBoxLinuxAdditions-x86.run

(B) Set the share folder of the host by GUI.
select “Shared folders” from the “Devices” menu, or click on the folder icon on the status bar in the bottom right corner of the virtual machine window.


or
(C) Set the share folder of the host by command line.
(c.1) sudo apt-get install virtualbox-ose
(c.2) VBoxManage sharedfolder add "VM name" --name "sharename" --hostpath "C:\temp"
(c.3) For transient VM shares, add the --transient option to the above command line

(D) Mount the host folder to the guest OS.
(d.1) sudo modprobe vboxvfs
(d.2) In a Linux guest, use the following command: sudo mount -t vboxsf sharename mountpoint

Replace sharename (use lowercase) with the share name specified with VBoxManage or the GUI, and mountpoint with the path where you want the share to be mounted on the guest (e.g. /mnt/share). The usual mount rules apply, that is, create this directory first if it does not exist yet.

(E) Your share folder is supposed to work now. :-)

How to clone a virtual machine?

you can simply copy the .vdi file, paste it into a target directory, and then run "VBoxManage internalcommands sethduuid target_vdi" command or "VBoxManage clonehd /path/src_vdi /path/target_vdi -format VDI".

How to enable Clipboard?
VBoxManage --clipboard bidirectional.

Sunday, April 26, 2009

Unable to install NS2 due to the X Library problem

When I tried to install NS2 on Red Hat, it shows that

checking for tclcl.h... -I../tclcl-1.19
checking for libtclcl... -L../tclcl-1.19 -ltclcl
checking for tcl2c++... ../tclcl-1.19
checking for X11 header files
checking for X11 library archive
checking for XOpenDisplay in -lX11... no
can't find X library
Ns configuration failed! Exiting ...
Please check http://www.isi.edu/nsnam/ns/ns-problems.html
for common problems and bug fixes.

How to cope with the shortage of X library?
If we use cygwin instead of RedHat to install ns2, it still lacks of package xorg-x11-bin and even worse the new version of Cygwin no longer supports xorg-x11-bin.


Since there exist some problem when installing NS2 in Red Hat and Cygwin. an workaround solution is to install NS2 in Ubuntu, which is more promising as shown at
http://c-perl-programming.blogspot.com/2009/04/ns2-installation-in-linux-ubuntu.html

Thursday, April 23, 2009

Hello

Hello Blogger!
 
Delicious Bookmark this on Delicious