Nov 23, 2011

Install ns2.1b9a + TENS in Ubuntu 10.04


ns2.1b9a which is an old version NS2 has very strong OS dependency, so I choose Ubuntu 10.04(64-bit).


-------------------------------------Install NS2-----------------------------------------------------------


1) First of all, download the NS-2 package ns-allinone-2.1b9a-gcc32. http://www.isi.edu/nsnam/dist/ns-allinone-2.1b9a-gcc32.tar.gz

2) Install "build-essential" and "libxmu-dev"

sudo apt-get install build-essential

sudo apt-get install libxmu-dev


3) Because in Ubuntu10.04, the gcc compiler version is gcc-4.4 which is too high to compile ns2.19b, we have to install gcc-3.3 and g++-3.3 by ourselves.

Go to http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-3.3/ and download

"cpp-3.3_3.3.6-15ubuntu6_amd64.deb" "g++-3.3_3.3.6-15ubuntu6_amd64.deb" "gcc-3.3-base_3.3.6-15ubuntu6_amd64.deb" "gcc-3.3_3.3.6-15ubuntu6_amd64.deb" and " libstdc++5-3.3-dev_3.3.6-15ubuntu6_amd64.deb"

. (Depend on your system, the version may be different) Then install them by sudo dpkg --force-depends -i xxx.deb

To check compiler version, we use ls /usr/bin/gcc* -ll or ls /usr/bin/g++* -ll. We also can add the compiler options

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-3.3

To change the default gcc version, we use

ln -sf /usr/bin/gcc-3.3 /usr/bin/gcc

ln -sf /usr/bin/g++-3.3 /usr/bin/g++

4) Now we are able to install NS2. First of all, tar xzvf ns-allinone-2.1b9a-gcc32.tar.gz and touch ns-allinone-2.1b9a/tcl8.3.2/generic/tclStubInit.c

5) Before running "./install", we have to modify some files (This is very important!!). Go to ns-allinone folder,

find . -name configure

You will see a list of configure files. Replace any line which is like system=MP-RAS-`awk '{print $3}' /etc/.relid'` to system=MP-RAS-`awk '{print $3}' /etc/.relid`


The original one will cause the error in tcl8.3.2, tk8.3.2 and otcl-1.8, checking system version (for dynamic loading)... ./configure: 1: Syntax error: Unterminated quoted string tcl8.3.2 configuration failed! Exiting



6) Modify otcl-xx/config.sub, tclcl-xx/config.sub and configure file in Nam folder.

Where "| x86 |"
appears, you must put "| x86 | x86_64 |". Where "| x86-* |" appears, you must put "| x86-* | x86_64-* |".


In nam config.sub file, it may not have "|86|", so just find out "case $basic_machine in"


It will cause the error, checking build system type... Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized configure: error: /bin/sh ./config.sub x86_64-unknown-linux-gnu failed otcl-1.8 configuration failed! Exiting ... or x86_64-unknown-linux-gnu failed nam1.0a11a configuration failed!


7) After the modification, ns2 may be compiled successfully. Just run ./install

8) When it is done, edit .bashrc file and configure environment variables. Put them at the end of file.
export NS_HOME=/home/XX/ns-allinone-2.1b9a

export PATH=$PATH:$NS_HOME/bin:$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NS_HOME/otcl-1.0a8:$NS_HOME/lib:$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix

export TCL_LIBRARY=$NS_HOME/tcl8.3.2/library/


9) Finally, source .bashrc

cd ns-2.1b9a

./validate


The Test may not be successful, but it will not effect too much.


--------------------------------------Install TENS------------------------------------------------------------


10) After the NS2 installation, we will start to make The Enhanced Network Simulator (TENS). So just follow the tutorial (http://www.cse.iitk.ac.in/users/braman/tens/)


The only thing is that when type in make depend, it may have an error pcap.h is not found. So open the Ubuntu Software Center, search libpcap and install all the related packages.


11) Congratulation! It is done!

Nov 18, 2011

Interview Test 2011


Here is some of the written exam questions in the interviews I attended. They are just based on my memory, so maybe I forget some parts. And mostly they are about IT, mobile programming, software engineering and networking technology.

# What do you think is the most important ability for a software developer? And why?

# What is TDD? Plz describe it.

# What are the differences between composition and inheritance in OO programming? Which one do you prefer?

# What are the heap and stack? Plz give an example by C or C++ to explain them respectively.

# Now you have a table like this,

Name      Home      Phone      Email

Paul      London      92821921      paul@abc.com

Amy      NY      92712345      amy@abc.com

John      HK      54378722      john@oefd.com

Paul      NY      86433478      paul_ny@abc.com

Plz use SQL to make it as the name is unique, like "Paul, Amy, John".

# Plz give three database engines.

# What is the difference between auto-generated primary key and item`s primary key? Which one will you use and why?

# Plz give three mobile OS. And What is their processor structure respectively?

# What are the three primary data types in C programming? What are the three non-primary data types?

# What is the exact output of the follow PHP script?

< ?php

$i = 1;

$a = &$i;

$b = $a++;

print $a;

print $b;

print $i;

?>

# Plz illustrate the two way communication process of an instant message software. You just need to write the pseudo codes.

# In object-oriented programming, what are the meanings of a) abstract class, b) object interface?

# In MySQL, what is the difference between left join, right join and inner join?

# What is bad about this line of code and how can you improve it?

$db->query(“SELECT username FROM user WHERE userid=”.$_REQUEST[‘uid’]);

# Please write a function to remove all html tags in a string, using regular expression.

# Please describe how to do character conversion from Traditional Chinese to Simplified Chinese using PHP.

# Please write a function to calculate the number of days between 2 dates.

# Please describe how you can schedule a daily job to remove log files older than 3 days, under a certain directory in a Redhat/CentOS Linux machine.

# In IE6, how to make a < div > 1px height with CSS?