Pages

Wednesday, June 30, 2010

Socket Programming

Here are a few helpful links for those who wish to learn socket programming.
http://www.tenouk.com/cnlinuxsockettutorials.html start from ch 1 and continue further, there is no end to iy, it all depends on how much you wish to learn. :)

For those of you who are getting jumpy and dont want to go through the details this page lists the details of the functions and there parameters that are being used. http://www.tenouk.com/Module39b.html

You can download and run the client and server executables to see what output is expected from you.

Monday, June 28, 2010

Setting up a shared folder in virtual box, windows host , ubuntu guest

You might be wondering if there is any way of getting your data from the virtual disk into your real machine or vice-versa, tension not, it is very easy. All you need to do is set up a shared folder. In order to do this follow the following easy steps.
  1. Go to virtual machine settings and select the shared folders tab.
  2. Now add the path of the folder you want to share and give a name to it, this will be used in your Ubuntu VM machine. Note: if you add the Desktop folder with its default name, i.e. "Desktop" you will not be able to set up sharing, this is some bug, so i recommend changing the folder name to "shared" or something else.
  3. Also check make permanent if you wish to use the folder again after reboot :)
  4. Now make a folder in which to map the shared folder e.g "mkdir ~/Desktop/share"
  5. now use the following command "sudo mount -t vboxsf share ~/Desktop/home" where share is the name of the shared folder you gave in virtual machine settings and ~/Desktop/share is the path where you wish to map the shared folder.
  6. Or you may edit the /etc/fstab file and put the following line in the end of it"share /home/username/Desktop vboxsf auto 0 0" notice here the ~ wont work, so you need to give the full path, and the last two arguments are zero not alphabet 'o'.
  7. Now open the folder and enjoy.

Notes:
  1. The Ubuntu folder that you are mapping to must be empty
  2. If you are already in the shared folder, it wont show any files, you need to cd back into the folder to be able to see the files.

Sunday, June 27, 2010

DCN lab make files

In order to do the lab you need these files
you will additionally need these files too, keep these files safe they will be used in the next lab too.
If you need additional help you can refer to my previous post http://zaidmunir.blogspot.com/2010/06/useful-links-for-learning-linux.html

Installing ns-2 for multiple users

There are a few tips that might save you considerable time and irritation if you follow them.
  1. Firstly, never install ns-2 in the home folder, make a folder at "/" for installing applications, for instance "/Apps" in this case.
  2. Installing for multiple users is no big deal, just install it like you would for a single user, if you are looking for Ubuntu install instructions you can refer to my earlier post http://zaidmunir.blogspot.com/2010/06/installing-ns2-on-ubuntu-910.html you just need to prefix the commands mentioned in the link with a sudo :)
  • After installing it just make a minor change, instead of making changes to the ~./bashrc file make the same changes to /etc/bash.bashrc if you are using Ubuntu or /etc/bashrc for other flavours of Linux.
  • Now go the user which is most probably a "desktop user" you can switch environments without having to log off using the command "su username -" and enter password when prompted for it. Now you would be in the username's environment. now if you run ns-2 it would run but when you run the validation checks, it would fail. This is because the folder that you created at root does not have write privileges by default. You can change this issuing the command "sudo chmod -Rf +w /Apps/ns-allinone-2.34" or you can use "sudo chmod -Rf 777 /Apps/ns-allinone-2.34" this would cause the specified folder and its subfolder to have wrx permissions for all users.
  • Now you can run the validation tests and in a while you should get an all tests passed message. Whola, you are ready to go. By following this method all the users can run ns-2 without any issue. :)

I can not agree more

"People who have no hold over their process of thinking are likely to be ruined by liberty of thought. If thought is immature, liberty of thought becomes a method of converting men into animals", Dr. Allama Muhammad Iqbal

Saturday, June 26, 2010

Useful links for Learning linux

For beginners here is a link to Linux basics http://www.ee.surrey.ac.uk/Teaching/Unix/

For a quick to the point intro https://help.ubuntu.com/community/UsingTheTerminal

One thing you wont be able to escape once you start working on Linux is MakeFiles, here is a very nice link explaining all that you need to know about Make files.

http://mrbook.org/tutorials/make/
in case you need more
http://www.opussoftware.com/tutorial/TutMakefile.htm

The next thing for a bit advanced users, well you would definitely feel the need to mould your machine according to your taste. Scripting my friend is the answer. Its a really powerful tool, once you get the feel of it you won't be able to let go of it. Here is a link to an excellent tutorial on scripting. It has one little bug, just replace !/bin/sh with !/bin/bash and you are all set to go :) Enjoy :D
http://www.freeos.com/guides/lsst/index.html

Friday, June 25, 2010

Installing ns2 on Ubuntu 9.10

A lot of people dread having to install ns2. Well here is a simple tutorial to get you through in just a single go. Mostly people fail at installing ns2 in the first go because of the missing libraries and dependencies.

Here is what you do to install ns2 in the first go.

1. Download ns-allinone-2.34

2. cd into the directory where you have downloaded the ns-allinone-2.34.tar.gz file. Then issue the command cp ns-allinone-2.34.tar.gz ~/

3. Then type cd ~/ to get into your home folder

4. Then use the command tar -xvzf ns-allinone-2.34.tar.gz

5. But before you can continue you need to install the following libraries

autoconf
automake
gcc
g++
build-essential
libxmu-dev
libtool
libxt-dev

6. You can download and install the libraries individually using the command sudo apt-get install libraryname e.g
sudo apt-get install autoconf

7. Now you are all set to proceed, but before you do there is one more modification that needs to be made, cd into ns-allinone-2.34/otcl-1.13 and then use the command gedit configure to make the following changes to the configure file.

change the following line
SHLIB_LD = "ld -shared" to SHLIB_LD = "gcc -shared", you would find that the string SHLIB_LD occurs at many places, you are to change the one that is written under Linux*)

OR you may try typing export CC = gcc-4.3 to change the environment variable, though i have not tried this seemingly easier method. (note: run the command gcc -v to check your version to use in the above command)

8. Now cd into the ns-allinone-2.34 directory and do ./install , hopefully everything will go smoothly and you ns-2 will be installed. But before you can proceed you need to set the environment variables.

gedit ~/.bashrc

copy the following lines at the end of the file, be sure to change /your/path to the path where ns is installed on your system.

# LD_LIBRARY_PATH
OTCL_LIB=/your/path/ns-allinone-2.34/otcl-1.13
NS2_LIB=/your/path/ns-allinone-2.34/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

# TCL_LIBRARY
TCL_LIB=/your/path/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.18/unix:/your/path/ns-allinone-2.34/tk8.4.18/unix
NS=/your/path/ns-allinone-2.34/ns-2.34/
NAM=/your/path/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

for instance on my system i would replace /your/path with /home/z3d

9. source ~/.bashrc to have the changes take effect or you can simply reopen terminal.

10. Now cd into the folder /ns-allinone-2.34/ns-2.34/ and type the command ./validate
it will take a considerably longer time than it did to install and in almost an hour you should get a message all tests successful.

11. Now you can type ns and begin doing your work :)

Ubuntu installation on Virtual Box


There are a lot of people who do not wish to have a dual boot system or there are others who end up having their system screwed up after trying to install Linux on their machines. For all such people: Fear not, virtualization is here to save the day.

There are a lot of virtualization softwares available but over here we will be talking about Virtual box (http://www.virtualbox.org/), for those of you who do not know what virtualization is u can go here http://en.wikipedia.org/wiki/Hardware_virtualization for details. In very short, it is running another computer within your current operating system. So to say a Linux machine running inside your Windows machine and its likes.

You can begin by downloading the software which is free of cost from its website. You would also need an ISO of the Operating system you wish to install, in this case Ubuntu. Before you download Ubuntu you need to make sure that your machine supports 64-bit virtualization, if not or if you are not sure; its always safe to download the 32-bit version from the website.

Ok now you have installed Virtual Box and and have downloaded the ISO file, what to do next. It is definitely a waste of time and resources to burn the ISO on a disc :p. Here is what you do:

1. Click the new button to create a new machine.

2. Select appropriate name, be sure to set the OS type parameters properly. These parameters allow VirtualBox to enable or disable certain OS specific parameters, so you would wish to have them right.

3. On the next screen you should select the amount of RAM you wish to allocate to your virtual machine. You should be very careful here because the value you select here will be acquired by the VM (virtual machine) when it is run and wont be able to your OS. Implying if you have 512 MB RAM and you allot 400 MB to the VM, you will be in trouble, a VM error or a system crash, it depends on the OS you are using.

4. On the next screen select create new hard disk.

5. In the next tab it is recommended that you select the "dynamically expanding storage" and set its size arbitrarily very large, don't worry it would not take up as much space as you have selected, its just an upper limit that could be reached. On the contrary, if you select "fixed-size storage", the amount you specify here will be immediately taken up by the virtual hard disk image file (vdi file), it just has one plus point it performs a little better than the dynamic disk when you are writing to your virtual disk, apart from that the difference in negligible.

6. Now you are done setting up your machine, now you need to map the machines virtual CD ROM to the ISO. You can do this by right clicking on the machine and selecting settings, in the settings menu, select storage. In the right hand pane you would see a CD ROM icon, select it. Now in the extreme right pane click on the folder button. On the screen that appears press add on the top left and browse to the location of ISO file, then click select at the bottom right.

7. Now you are all set up to run the machine for the first time. Select the machine icon on the main menu and click start. You should now be seeing a screen of the OS setup. You can now install your selected OS on your machine.

Sunday, June 6, 2010

All set for the change

For years i have been contemplating moving permanently to the Linux platform. Every time one thing or the other kept me from moving on. Last week i finally found a version of matlab that works on linux :). Now i am already for the change. Here is a check list that you might find convincing
1. Skype works
2. Chrome works
3. VLC works
4. No need for MS office when you have got Open office
5. what else can a kid want more from a PC :P so it means you can also join the big guys :P :D
6. Now dont get thinkin that he is callin me a kid and what about himself, well as for me i have had a dual boot system with fedora for years and lately i have been using Virtual Box to use Linux inside Windows :)

Open source rox, besides in Pk no one really bothers about piracy but if you think of it it is equivalent to stealing, so its better to stop it :)