CSE422 – Computer Networks Spring 2020 Programming Lab Assignment 1
Given: Tuesday, Feb 4, 2020
Due: Wednesday, Feb 12, 2020 (MIDNIGHT 11:59PM)
Submission Instructions
1. Submit your report as a DOC or PDF file in Crowdmark. No hard copy or emailed copies will be accepted!!
1 of 6
Ns-3 Installation
To get started with ns-3, independently on your OS (Linux, Mac OS X, Windows), you will have to go through the following steps:
1. Download the Ubuntu image files provided at the following links into a single folder on your computer
https://www.dropbox.com/s/twz0elwylx5xn24/Ubuntu%2014.04%2064-bit%20Networks.nvram?dl=0 https://www.dropbox.com/s/cm4rnfwxjuqvpo0/Ubuntu%2014.04%2064-bit%20Networks.vmsd?dl=0 https://www.dropbox.com/s/oxx1cl3het29ti8/Ubuntu%2014.04%2064-bit%20Networks.vmx?dl=0 https://www.dropbox.com/s/4t5qyx11zscbb6t/Ubuntu%2014.04%2064-bit%20Networks.vmxf?dl=0 https://www.dropbox.com/s/ma652qxb9i2p2vt/Ubuntu%2014.04%2064-bit%20Networks.vmdk?dl=0 https://www.dropbox.com/s/i0zg64oxcg15tus/Ubuntu%2014.04%2064-bit%20Networks-s001.vmdk?dl=0 https://www.dropbox.com/s/4aufiaun3mm3o38/Ubuntu%2014.04%2064-bit%20Networks-s002.vmdk?dl=0 https://www.dropbox.com/s/vig26cnzd2rh4lo/Ubuntu%2014.04%2064-bit%20Networks-s003.vmdk?dl=0 https://www.dropbox.com/s/j4gqrqtwtq6uiyb/Ubuntu%2014.04%2064-bit%20Networks-s004.vmdk?dl=0 https://www.dropbox.com/s/jim5j4qq43vw0sf/Ubuntu%2014.04%2064-bit%20Networks-s005.vmdk?dl=0 https://www.dropbox.com/s/x0g45etbjrrghxf/Ubuntu%2014.04%2064-bit%20Networks-s006.vmdk?dl=0 https://www.dropbox.com/s/8264ugkiaj3f2oq/Ubuntu%2014.04%2064-bit%20Networks-s007.vmdk?dl=0 https://www.dropbox.com/s/g91n74yyctxm6g2/Ubuntu%2014.04%2064-bit%20Networks-s008.vmdk?dl=0 https://www.dropbox.com/s/xdvspas5e31xclz/Ubuntu%2014.04%2064-bit%20Networks-s009.vmdk?dl=0 https://www.dropbox.com/s/ap6813ix5ft2n5k/Ubuntu%2014.04%2064-bit%20Networks-s010.vmdk?dl=0 https://www.dropbox.com/s/8l9r0y6fhn42z1x/Ubuntu%2014.04%2064-bit%20Networks-s011.vmdk?dl=0
2. Download and install the Oracle Virtual Box Application (VirtualBox platform packages) for your OS at the following link https://www.virtualbox.org/wiki/Downloads
3. Run the Oracle Virtual Box Application and mount the Ubuntu 14.04 64-bit Networks image
a. Click on Machine ¨ New…
b. Provide a name you want (e.g., Ubuntu64Networks)
c. Choose Linux as Type
d. Choose Ubuntu (64-bit) as Version
e. Assign an adequate memory size (I suggest 4 GB if you have at least
8GB on your computer. Otherwise around half of your installed RAM
would work)
f. Select ¡°Use and existing virtual hard disk file¡± and click on the folder
and select from the drop down file system viewer the file: ¡°Ubuntu 14.04 64-bit Networks.vmdk¡± contained in the folder where you have all the downloaded image files
2 of 6
g. Double-click on the machine that you created in the Virtual Box list. Once the machine is up and running, you will see the Ubuntu login screen. Username: Networks, Password: net
4. Build the complete ns-3 installation and test it
a. Open the terminal (e.g., click on the upper left icon to search, and
search for Terminal)
b. cd ns-allinone-3.21/
c. ./build.py –enable-examples –enable-tests
You should see something like the following:
That means that everything is working fine, and you can start with the assignment
3 of 6
Writing a Program Code (Part 1)
You will be writing, building and executing your programs in the scratch folder. This folder is usually located at /ns-allinone-3.21/ns-3.21/scratch.
It is always suggested to start building your program from an already written code you can find in the examples folder ns-allinone-3.21/ns-3.21/examples.
Simply copy the code file you want to start with into the scratch folder and rename it.
Make the modifications you want to implement in your program.
1. Building the Program
You will use the waf builder provided within the ns-3 installation.
Go to the parent folder of the scratch folder (where your program code should be):
cd .. cd ..
Build your program by running waf:
./waf
2. Running the program
Run the program using the command:
./waf –run
3. Modify the program (50)
Copy the first.cc file from examples to scratch folder, rename to myfirst.cc: cp examples/tutorial/first.cc scratch/myfirst.cc
Modify the IP to 10.0.xxx.1 (xxx means any number from 0-255).
Send 3 packets of size 1024 bytes from client to server every 3 seconds. Run the program by using waf.
Screenshot your output here.
4 of 6
Wireshark lab (Part 2)
Wireshark is a free open-source network protocol analyzer. It is used for network troubleshooting and communication protocol analysis. Wireshark captures network packets in real time and display them in human-readable format. It provides many advanced features including live capture and offline analysis, three-pane packet browser, coloring rules for analysis.
Download WireShark
In this first Wireshark lab, you will obtain and install a copy of Wireshark Download link:
https://www.wireshark.org/ – download
Modify program (50)
1 Make another copy for your myfirst.cc file, rename it to something like myTcp.cc
Paste the code from the attached file ¡®MyApp.cc¡¯ into your program, right before the main function starts:
MyApp.cc
(The code is from the fifth.cc example file, it creates an app for TCP connections)
2. In this assignment, we will be creating a TCP connection instead of a UDP connection.
So, you should remove the section that starts from
UdpEchoServerHelper echoServer (9);
.. up to …
clientApps.Stop (Seconds (10.0));
because we will not be testing udp applications.
3. Add the code from the file ¡®tcp_setup.cc¡¯ to create a TCP application at the client and at the server(sink). Please take a look at the file before copy- pasting, you don¡¯t need to understand all the code, but it is useful to understand what each line is doing. I have added comments.
tcp_setup.cc
Notice that there is a line pointToPoint.EnablePcapAll(“Lab1”);
5 of 6
This will save the point-to-point communication details between the nodes into Lab1*.pcap files in your ¡°ns-3.21¡± folder.
4. Your final task is to open the pcap files from Step 3, in WireShark and take a snapshot of the captured communication.
Briefly describe what you see, (for example; things like the SYN and ACK signals).
What is the total time taken to complete the transaction?
Useful Links
Official Tutorial: https://www.nsnam.org/docs/release/3.24/tutorial/ns-3- tutorial.pdf
Page 3 (including section 1.1 in page 4), Page 23 to Page 49 except ASCII tracing.
To understand CSMA (complete understanding is not required): 51 to 59 (excluding section 6.2)
Writing and building a script: http://www.nsnam.org/support/faq/writing-scripts/ Documentation (for all the modules, classes, files): www.nsnam.org/doxygen/
Note:
The purpose of the lab assignments is not to make you good at coding but to let you apply some of the concepts learned in class within the ns-3 environment.
Tip:
When facing compile time issues, sometimes it is difficult to debug your code by relying only on the error messages received from the compiler. To better figure out which part of your code is causing the error, you can comment out the entire code and progressively uncomment blocks of code to find errors.
Recommended Preparation
Please read the tutorial before you start the questions.
Open the folder ns-3.21/examples/tutorial/, you will see some program samples.
Read the tutorial carefully and try to understand the program files first.cc and second.cc.
Here is another useful link to a short video:
https://www.youtube.com/watch?v=nBVxIWmW0u4&list=PLRAV69dS1uWQEbcH nKbLldvzrjdOcOIdY&index=4
6 of 6