Pages

Wednesday, July 14, 2010

Libpcap

I have written a small sample code to get you started. You can download it here. to compile the code: gcc code.c -lpcap
and then execute the output file as: sudo ./a.out

Here is a code which generates an ICMP packet, you should follow the structure given in this code. Compile and run the code as mentioned above.

Tuesday, July 13, 2010

Configuring network in virtual box

Please download this manual, it will be helpful in revising your previous concepts.
You additionally need to download and print this manual, you need to submit a filled hard copy at the end of the lab.

Here you can additionally find the link to the online tutorial for virtual box, in this section virtual networking is explained http://www.virtualbox.org/manual/ch06.html
And here is another useful link for changing the IP address in Ubuntu, be advised before you make any changes to these files be sure to take backup of this file.

Sunday, July 4, 2010

Tips for socket programming lab2

1. Important point you can only type cast a pointer into another, it implies that you can not type cast an integer to the type void * etc.
2. The last argument of the thread function takes a void pointer as its argument so firstly keep point 1 in mind and secondly either you can declare a pointer or the better option might be to simply pass the variable by reference.
3. If you passed a variable by reference don't forget to dereference it. syntax * referenced_variable
4. When you compile the code, keep in mind that now you need to tell the compiler that it needs to use the lpthread library at link time. So don't forget to make relevant changes to your make file.
5. Enjoy your programming, its never too late to learn :)

Friday, July 2, 2010

iostream buffer issues, cin, cout, cin.get, cin.getline

Here are useful links to iostream buffer related issues.

http://www.cplusplus.com/forum/beginner/7405/
http://www.cs.hmc.edu/~geoff/classes/hmc.cs070.200109/notes/io.html


you may also wish to read the chapter on I/O in the book by Walter Savitch, it is available in the library

In case you are having issues where your code seems to skip cin or cin.getline you can use
std::cin.ignore(std::numeric_limits::max(),'\n');
or, since you have 'using namespace std;', you can add this
cin.ignore(numeric_limits::max(),'\n');

to flush the buffer before you take input you will need to include ios.h and limits.h in order for it to work

sample

# include
# include
# include
# include
using namespace std;

int main()
{

.
.
.
.
.

string string1;
cin.ignore(numeric_limits::max(),'\n');
cin.getline(cin,string1);


}

Thursday, July 1, 2010

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.