Anda di halaman 1dari 31

National University of Computer and Emerging Sciences, Lahore Campus

Experiment no 1:
Network Analysis Tools
Make sure your PC has the following softwares\libraries installed

1. Netstat
2. Ping
3. WinPcap library
4. Tracert
5. Telnet
6. Trace route
7. Ethereal
8. Demon.net\extemal

You should write any command(s) specified below in the command prompt.

IPConfig

Give the IP information about the interfaces.

>ipconfig

1. Write down the output of the above statement

Netstat

The netstat command is used to display the TCP/IP network protocol statistics and information.

NETSTAT [-a] [-e] [-n] [-s] [-p proto] [-r] [interval]


-a Displays all connections and listening ports.
-e Displays Ethernet statistics. This may be combined with the -s option.
-n Displays addresses and port numbers in numerical form.
-p proto Shows connections for the protocol specified by proto; proto may be
TCP or UDP. If used with the -s option to display per-protocol statistics, proto
may be TCP, UDP, or IP.
-r Displays the routing table.
-s Displays per-protocol statistics. By default, statistics are shown for TCP, UDP and
IP; the -p option may be used to specify a subset of the default. Interval Redisplays
selected statistics, pausing interval seconds between each display. Press CTRL+C to stop
redisplaying statistics. If omitted, netstat will print the current configuration information
once.

> netstat -a

1. Write down the output of the command?

1 Roll No. ____________________


National University of Computer and Emerging Sciences, Lahore Campus

2. What information is obtained through this command?

Ping

Short for Packet InterNet Groper, ping is a utility used to verify if a network data packet is
capable of being distributed to an address without errors. The ping utility is commonly used to
check for network errors.

Helps in determining TCP/IP Networks IP address as well as determine issues with the
network and assists in resolving them.

Ask one of your fellow-student for his IP address. Now issue the following command

>ping ipaddress

Write the output of the above command

Now Use ping command with different options

>ping -t ipaddress

>ping -n count ipaddress

Tracert
2 Roll No. ____________________
National University of Computer and Emerging Sciences, Lahore Campus

The tracert command is used to visually see a network packet being sent and received and the
amount of hops required for that packet to get to its destination.
>tracert hostname

Example:
169 ms l90 ms l60ms slcl-tc.xmission.com [166.70.1.20]
159ms l60ms l90ms cisco0-tc.xmission.com [166.70.1.1]
165 ms l89 ms l59ms www.computerhope.com [166.70.10.23]

Note:
Min, Max and average hop times are displayed in-order. Systems behind fire-wall cannot use
trace route

Trace route:

Go to traceroute.org and try to find the route to

1. www.nu.edu.pk

2. www.mit.edu.pk

Q1: How do trace-route tools work?

Q2: Produce route trace using the site http://www.net.princeton.edu/traceroute.html for the
following URLs: highway.ns.edu.pk, uet.edu.pk, www.mit.edu. Why is there a sudden increase
in hop time from hop 10 to hop 11 for the first two URLs but not for the last one?

Ethereal

Ethereal is a packet sniffing software which uses the promiscuous mode of LAN cards. It can
receive and pick packets of any protocol. However the details of the packets shown are
dependent on the protocol of the packet

Find the ethereal program and run it

3 Roll No. ____________________


National University of Computer and Emerging Sciences, Lahore Campus

After running the program go to the capture menu and press “interfaces” button

Then press the capture button to start capturing the packets

4 Roll No. ____________________


National University of Computer and Emerging Sciences, Lahore Campus

5 Roll No. ____________________


National University of Computer and Emerging Sciences, Lahore Campus

1. List the names of all protocols captured by Ethereal?

2. Write down acknowledgment no. and sequence number of the first TCP packet?

3. Carefully look at the ARP packets and describe their source address and destination address?
What these addresses are referring?

ARP:
Q1: Why have two sets of machine addresses – at layer 2 (MAC) and layer 3 (IP)?

Q2: How are these addresses related to each other?

Q3: ARP packet structure…

Q4: ARP resolution process

Q5: Reverse resolution?

6 Roll No. ____________________


National University of Computer and Emerging Sciences, Lahore Campus

Q6: How to check ARP tables of a host in Windows and Linux?


--Ping to nearest host: make sure it works; use Ethereal to see if address need be
resolved
--Delete ARP entry and ping again; use Ethereal to see address resolution

ICMP:
Q1: What is the difference between ICMP packets sent by ping and the ones sent by tracert?

7 Roll No. ____________________


National University of Computer and Emerging Sciences, Lahore Campus
Experiment no 2:
Telnet and File Transfer Protocol

A severe security problem with the file transfer protocol (FTP) is that the login and password
information are transmitted as plain text (not encrypted). Sometimes malicious users exploit
this by snooping passwords on the network.

Here you learn how easy it is to crack passwords by snooping traffic from FTP and Telnet
sessions.

Note: The use of applications that do not encrypt passwords, such as FTP and Telnet, is
strongly discouraged. On the Internet, you should use protocols such as Secure Shell (ssh)
tools for file transfers and remote login. .

1-a: Snoop Authentication Information from an FTP session

Capture traffic from an FTP session between two hosts.

An FTP server is running on host 172.16.45.33 port 21 alias wsus on your LAN. You will
establish a connection with the server and capture the traffic exchanged during connection
establishment for analysis.

URL for FTP Access is: ftp://wsus

You can remotely login to the server as a client using following authentication information:

User Name: Lab4


Password: 147258

Inspect the payload of packets with FTP payload that is sent from PC1 to PC2. FTP sessions use
TCP connections for data transfer.

In ethereal, there is a simple method to view the payload sent in a TCP connection. Simply
select a packet that contains a TCP segment in the main window of ethereal, and then click on
"Follow TCP Stream" in the "Tools" menu of the ethereal window. This will create a new window
that displays only the payload of the selected TCP connection.

Now save the details of the packets which transmit the login name and password.

As a hint, you can set the display filter in ethereal to show only the desired packet(s). Then

8 Roll No. ____________________


National University of Computer and Emerging Sciences, Lahore Campus
save your data to a file on some local directory by selecting “Print” in the “File” menu of
ethereal, then selecting “Plain Text” and checking “Output to File”. Print your data in the space
given below.

Note: Your experiments will be graded. So be very careful about what to save and what to
ignore in ethereal’s captured traffic dump. .

Lab Report: 1-a

• Using the saved output, identify the port numbers of the FTP client and the FTP server.

• Identify the login name and the password, shown in plain text in the payload of the
packets that you captured. You would need to copy the payload of the required packet(s)
to this document (i.e. Lab Report) and highlight the portion which has the authentication
information in it.

9 Roll No. ____________________


National University of Computer and Emerging Sciences, Lahore Campus
1-b: Snoop Authentication Information from a Telnet session

Repeat the above exercise using telnet to remotely login to a server.

A telnet server is running on host 172.16.204.38 alias pc4-38 on your LAN. You will
establish a telnet connection with the server and capture the traffic exchanged during
connection establishment for analysis.

Command Line: telnet pc4-38


User Name: test
Password: test123

Lab Report: 1-b

Does Telnet have the same security flaws as FTP? Support your answer using extracts from
the saved output.

Computer Communications, Lab Manual 10


National University of Computer and Emerging Sciences, Lahore Campus
Experiment no 3:
Hypertext Transfer Protocol
25 points

In this exercise, we’ll explore several aspects of the HTTP protocol: the basic GET/response
interaction, HTTP message formats, retrieving large HTML files, retrieving HTML files with
embedded objects, and HTTP authentication and security.

Note: For each of the five scenarios given below you have to note down on the manual the
prints of relevant packets dump from ethereal. Refer to the previous question on the
procedure for saving (printing) packets to a text file.

1. The Basic HTTP GET/response interaction

Let’s begin our exploration of HTTP by downloading a very simple HTML file - one that is
very short, and contains no embedded objects. Do the following:

1. Start up your web browser.

2. Start up the Ethereal packet sniffer, as described in the Introductory lab (but don’t yet
begin packet capture). Enter “http” (just the letters, not the quotation marks) in the
display-filter-specification window, so that only captured HTTP messages will be displayed
later in the packet-listing window. (We’re only interested in the HTTP protocol here, and
don’t want to see the clutter of all captured packets).

3. Wait a bit more than one minute (we’ll see why shortly), and then begin Ethereal packet
capture.

4. Enter the following to your browser


http://gaia.cs.umass.edu/ethereal-labs/HTTP-ethereal-file1.html
Your browser should display the very simple, one-line HTML file.

5. Stop Ethereal packet capture.

Your Ethereal window should look similar to the window shown in Figure 1.

Computer Communications, Lab Manual 11


National University of Computer and Emerging Sciences, Lahore Campus

The example in Figure 1 shows in the packet-listing window that two HTTP messages were
captured: the GET message (from your browser to the gaia.cs.umass.edu web server) and
the response message from the server to your browser. The packet-contents window shows
details of the selected message (in this case the HTTP GET message, which is highlighted in
the packet-listing window). Recall that since the HTTP message was carried inside a TCP
segment, which was carried inside an IP datagram, which was carried within an Ethernet
frame, Ethereal displays the Frame, Ethernet, IP, and TCP packet information as well. We
want to minimize the amount of non-HTTP data displayed (we’re interested in HTTP here,
and will be investigating these other protocols is later labs), so make sure the boxes at the
far left of the Frame, Ethernet, IP and TCP information have a right-pointing arrowhead
(which means there is hidden, undisplayed information), and the HTTP line has a down-
pointing arrowhead (which means that all information about the HTTP message is
displayed).

(Note: You should ignore any HTTP GET and response for favicon.ico. If you see a reference to this file, it is your
browser automatically asking the server if it (the server) has a small icon file that should be displayed next to the
displayed URL in your browser. We’ll ignore references to this pesky file in this lab.).

By looking at the information in the HTTP GET and response messages, answer the following
questions. When answering the following questions, you should print out the GET and
response messages (see the introductory Ethereal lab for an explanation of how to do this)

Computer Communications, Lab Manual 12


National University of Computer and Emerging Sciences, Lahore Campus
and indicate where in the message you’ve found the information that answers the following
questions.

1. Is your browser running HTTP version 1.0 or 1.1? What version of HTTP is the server
running? (2 points)

2. What languages (if any) does your browser indicate that it can accept to the server? (1
point)

3. What is the IP address of your computer? Of the gaia.cs.umass.edu server? (2 points)

4. What is the status code returned from the server to your browser? (1 point)

5. When was the HTML file that you are retrieving last modified at the server? (1 point)

6. How many bytes of content are being returned to your browser? (1 point)

7. By inspecting the raw data in the packet content window, do you see any headers within
the data that are not displayed in the packet-listing window? If so, name one. (1 point)

2. The HTTP CONDITIONAL GET/response interaction

Most web browsers perform object caching and thus perform a conditional GET when
retrieving an HTTP object. Before performing the steps below, make sure your browser’s
cache is empty. (To do this under Netscape 7.0, select Edit->Preferences->Advanced-
>Cache and clear the memory and disk cache. For Internet Explorer, select Tools->Internet
Options->Delete File; these actions will remove cached files from your browser’s cache.)
Now do the following:

• Start up your web browser, and make sure your browser’s cache is cleared, as discussed
above.

• Start up the Ethereal packet sniffer

• Enter the following URL into your browser


http://gaia.cs.umass.edu/ethereal-labs/HTTP-ethereal-file2.html
Your browser should display a very simple five-line HTML file.

• Quickly enter the same URL into your browser again (or simply select the refresh button
on your browser)

• Stop Ethereal packet capture, and enter “http” in the display-filter-specification window, so

Computer Communications, Lab Manual 13


National University of Computer and Emerging Sciences, Lahore Campus
that only captured HTTP messages will be displayed later in the packet-listing window.
Now answer the following questions:

8. Inspect the contents of the first HTTP GET request from your browser to the server. Do
you see an “IF-MODIFIED-SINCE” line in the HTTP GET? (1 point)

9. Inspect the contents of the server response. Did the server explicitly return the contents
of the file? How can you tell? (1 point)

10. Now inspect the contents of the second HTTP GET request from your browser to the
server. Do you see an “IF-MODIFIED-SINCE:” line in the HTTP GET? If so, what information
follows the “IF-MODIFIED-SINCE:” header? (1 point)

11. What is the HTTP status code and phrase returned from the server in response to this
second HTTP GET? Did the server explicitly return the contents of the file? Explain. (2
points)

3. Retrieving Long Documents

In our examples thus far, the documents retrieved have been simple and short HTML files.
Let’s next see what happens when we download a long HTML file. Do the following:

• Start up your web browser, and make sure your browser’s cache is cleared, as discussed
above.

• Start up the Ethereal packet sniffer

• Enter the following URL into your browser


http://gaia.cs.umass.edu/ethereal-labs/HTTP-ethereal-file3.html
Your browser should display the rather lengthy US Bill of Rights.

• Stop Ethereal packet capture, and enter “http” in the display-filter-specification window, so
that only captured HTTP messages will be displayed.

In the packet-listing window, you should see your HTTP GET message, followed by a
multiple-packet response to your HTTP GET request. This multiple-packet response deserves
a bit of explanation. Recall from Section 2.2 (see Figure 2.9 in the text) that the HTTP
response message consists of a status line, followed by header lines, followed by a blank
line, followed by the entity body. In the case of our HTTP GET, the entity body in the
response is the entire requested HTML file. In our case here, the HTML file is rather long,
and at 4500 bytes is too large to fit in one TCP packet. The single HTTP response message is
thus broken into several pieces by TCP, with each piece being contained within a separate

Computer Communications, Lab Manual 14


National University of Computer and Emerging Sciences, Lahore Campus
TCP segment (see Figure 1.22 in the text). Each TCP segment is recorded as a separate
packet by Ethereal, and the fact that the single HTTP response was fragmented across
multiple TCP packets is indicated by the “Continuation” phrase displayed by Ethereal. We
stress here that there is no “Continuation” message in HTTP!

Now answer the following questions:

12. How many HTTP GET request messages were sent by your browser? (1 point)

13. How many data-containing TCP segments were needed to carry the single HTTP
response? (1 point)

14. What is the status code and phrase associated with the response to the HTTP GET
request? (1 point)

15. Are there any HTTP status lines in the transmitted data associated with a TCPinduced
“Continuation”? (1 point)

4. HTML Documents with Embedded Objects

Now that we’ve seen how Ethereal displays the captured packet traffic for large HTML files,
we can look at what happens when your browser downloads a file with embedded objects,
i.e., a file that includes other objects (in the example below, image files) that are stored on
another server(s). Do the following:

• Start up your web browser, and make sure your browser’s cache is cleared, as discussed
above.

• Start up the Ethereal packet sniffer

• Enter the following URL into your browser


http://gaia.cs.umass.edu/ethereal-labs/HTTP-ethereal-file4.html

Your browser should display a short HTML file with two images. These two images are
referenced in the base HTML file. That is, the images themselves are not contained in the
HTML; instead the URLs for the images are contained in the downloaded HTML file. As
discussed in the textbook, your browser will have to retrieve these logos from the indicated
web sites. Our publisher’s logo is retrieved from the www.awl.com web site. The image of
our book’s cover is stored at the manic.cs.umass.edu server.

• Stop Ethereal packet capture, and enter “http” in the display-filter-specification window, so
that only captured HTTP messages will be displayed.

Computer Communications, Lab Manual 15


National University of Computer and Emerging Sciences, Lahore Campus

Now answer the following questions:


16. How many HTTP GET request messages were sent by your browser? To which Internet
addresses were these GET requests sent? (3 points)

17. Can you tell whether your browser downloaded the two images serially, or whether they
were downloaded from the two web sites in parallel? Explain. (2 points)

2.5 HTTP Authentication

Finally, let’s try visiting a web site that is password-protected and examine the sequence of
HTTP message exchanged for such a site. The URL http://gaia.cs.umass.edu/ethereal-
labs/protected_pages/HTTP-ethereal-file5.html is password protected. The username is
“eth-students” (without the quotes), and the password is “networks” (again, without the
quotes). So let’s access this “secure” password-protected site. Do the following:

• Make sure your browser’s cache is cleared, as discussed above, and close down your
browser. Then, start up your browser.

• Start up the Ethereal packet sniffer

• Enter the following URL into your browser


http://gaia.cs.umass.edu/ethereal-labs/protected_pages/HTTP-ethereal-file5.html
Type the requested user name and password into the pop up box..

• Stop Ethereal packet capture, and enter “http” in the display-filter-specification window, so
that only captured HTTP messages will be displayed later in the packet-listing window.

Now answer the following questions:

18. What is the server’s response (status code and phrase) in response to the initial HTTP
GET message from your browser? (1 point)

19. When your browser’s sends the HTTP GET message for the second time, what new field
is included in the HTTP GET message? (1 point)

The username (eth-students) and password (network) that you entered are encoded in the
string of characters (ZXRoLXN0dWRlbnRzOm5ldHdvcmtz) following the “Authorization:
Basic” header in the client’s HTTP GET message. While it may appear that your username
and password are encrypted, they are simply encoded in a format known as Base64 format.
The username and password are not encrypted! To see this, go to
http://www.securitystats.com/tools/base64.php and enter the base64-encoded string

Computer Communications, Lab Manual 16


National University of Computer and Emerging Sciences, Lahore Campus

ZXRoLXN0dWRlbnRzOm5ldHdvcmtz and press decode. Voila! You have translated from


Base64 encoding to ASCII encoding, and thus should see both your username and
password! Since anyone can download a tool like Ethereal and sniff packets (not just their
own) passing by their network adaptor, and anyone can translate from Base64 to ASCII
(you just did it!), it should be clear to you that simple passwords on WWW sites are not
secure unless additional measures are taken.

Fear not! As we will see sometime later, there are ways to make WWW access more secure.
However, we’ll clearly need something that goes beyond the basic HTTP authentication
framework!

Source:

Ethereal Lab: HTTP


Version: 1.1 (Feb. 2005)
© 2005 J.F. Kurose, K.W. Ross. All Rights Reserved

Computer Communications, Lab Manual 17


National University of Computer and Emerging Sciences, Lahore Campus
Experiment no 4:
Introduction to ns-2

1. Describe three features of real-life computer networks:

2. Describe three features of network simulators:

3. What advantages do simulators have over actual networks?

4. How can ns-2 be downloaded and installed over a Windows machine?

5. Why does ns-2 use two programming languages?

6. Under what extension are Tcl scripts saved? How are these scripts executed?

7. The following questions deal with variable declaration and initialization in Tcl.

(a) Write the command for declaring a variable named ‘int’ initialized by an integer value of
5.

(b) Write the command for declaring a variable named ‘str’ initialized by a string “Hello Tcl”.

(c) Write the command for printing the string “I just declared the variables ‘5’ and ‘Hello
Tcl’”.

(d) Modify the above command to print the same string using the variables ‘int’ and str’.

Computer Communications, Lab Manual 18


National University of Computer and Emerging Sciences, Lahore Campus
(e) Write the command for evaluating the expression “int + 2*int” and assigning the result
to the variable ‘int2’.

(e) Write the command for testing whether a given number is greater than another or not.

(f) Declare a list of five natural numbers.

(g) Declare a list of positive integers containing the above list (not its elements).

(h) Write the command for printing the length of the list above.

(i) Write the command for appending the integers 33 and 67 to the above list.

(j) Write the command for resetting an element of the list at a given index of 4.

(k) Given the declaration “set lst "1 2 3 4"”, what is the difference in the outputs of “puts
[lindex $lst 2]”, “puts “lindex $lst 2”” and “puts {lindex $lst 2}”.

8. The following questions deal with control and loop structures in Tcl.
(a) Write the command for squaring a list of integers using the foreach command..

(b) Perform the same operation as above using for command for first-half of list elements.

(c) For two variables ‘a’ and ‘b’ of arbitrary values, write the command for printing “HIGH”
if a > b and “LOW” otherwise.

(d) For a given numeric variable ‘a’, write the command for printing “POSITIVE” if a > 0,
“NEGATIVE” if a < 0 and “ZERO” if a = 0.

9. The following questions deal with declaring procedures in Tcl.


(a) Write a procedure called ‘simple’ that prints “Get Lost!”

(b) Write a procedure that calculates the area of a circle of radius given as argument.

Computer Communications, Lab Manual 19


National University of Computer and Emerging Sciences, Lahore Campus

(c) Write a procedure that iteratively adds up the contents of an arguments list.

CHALLENGE: Write a recursive procedure that calculates the Fibonacci sequence up to an


argument index.

10. The following questions deal with declaring classes and objects in OTcl.
(a) Create a class called NewWorld with the following procedures:
--continents: returns the lists of continents (at least three)
-- oceans: stores the lists of all oceans; returns the number of oceans (at least three)
--land{continent}: returns the area of a given continent

(b) Create an instance of the class NewWorld and print its number of continents and oceans.

Computer Communications, Lab Manual 20


National University of Computer and Emerging Sciences, Lahore Campus
11. Write down the given Tcl script for simulation and describe the purpose of each
statement.

References:
[1] http://www-net.cs.umass.edu/cs653/notes/simulation.pdf
[2] www.isi.edu/div7/publication_files/advances_in_network.pdf
[3] http://www.isi.edu/nsnam/ns
[4] http://www.isi.edu/nsnam/ns/tutorial/index.html

Computer Communications, Lab Manual 21


National University of Computer and Emerging Sciences, Lahore Campus
Experiment no 5:
Local Area Networks

Scenario 1: Gratuitous ARP — Resolving IP address conflict

1. Note down the ARP cache and the routing tables on both PCs.
2. Connect two PCs with a switch. Write down the IP addresses and MAC address (of
physical interfaces) of both machines, and the switch model below:

Machine A:
Machine B:
Switch model:

3. Check the ARP cache and the routing tables on both PCs.

4. What are the differences between the caches and tables checked in steps 1 and 4? Why?

5. Run Ethereal. Start capture on a physical (not virtual) interface. Now change your IP
address to some other address in the same subnet.

6. Using Machine A, ping Machine B. Note down the ARP cache contents.

7. Ethereal should display that some of the packets captured belong to the protocol
“Gratuitous ARP”.

8. Note down the header contents of the Gratuitous ARP packet below:
Ethernet II, Src: ___________________________ Dst: __________________________
Address Resolution Protocol ________________________________________________
Hardware type: _________________________________________________________
Protocol type: __________________________________________________________
Hardware size: _________________________________________________________
Protocol size: __________________________________________________________
Opcode: _______________________________________________________________
Sender MAC address: ___________________________________________________
Sender IP address: _____________________________________________________
Target MAC address: ___________________________________________________
Target IP address: ______________________________________________________

9. Stop capture. Use the Internet to find two specific and distinct uses of the Gratuitous
ARP.

10. Would there be any error reported in case the two machines use different subnet
masks? Why or why not? You may actually try this out by changing the mask of one of the
machines.

Computer Communications, Lab Manual 22


National University of Computer and Emerging Sciences, Lahore Campus

You will now try to create an IP address conflict in the following way.

11. Start Ethereal capture. Try assigning the same IP addresses to both machines. Note
down any messages that the operating system gives. Ping one of the machines.

12. Note down the ARP contents of both machines. Give reason for the presence/absence of
any content.
Machine

13. Stop capture. Fill the required information below for all of the Gratuitous ARP packets.
Sr.# Time Source Destination Protocol Information

14. Is the IP address of both machines the same? Why or why not?

15. How was Gratuitous ARP used in the conflict above? Your answer should include: which
machine sends this ARP, what kind of reply it receives and what does this machine infer
from the reply.

References:
[1] Behavior of Gratuitous ARP in Windows NT 4.0, http://support.microsoft.com/kb/199773
[2] ARP Q & A, http://www.geocities.com/SiliconValley/Vista/8672/network/arp.html
[3] Gratuitous ARP, http://wiki.ethereal.com/Gratuitous_ARP

Computer Communications, Lab Manual 23


National University of Computer and Emerging Sciences, Lahore Campus
Scenario 2: ARP Poison Routing — Man-in-the-Middle Attack at Layer 2

Computer Communications, Lab Manual 24


National University of Computer and Emerging Sciences, Lahore Campus
Scenario 3: IPerf—Measuring Transport Layer Performance of Ethernet

1. Get IPerf.exe [108 KB] either from an Internet [1] or LAN server. The IPerf
documentation is a useful reference for usage.

2. Your first job is to measure the average bandwidth of the Ethernet cable provided to you.
For this purpose, you will be using the IPerf tool. IPerf essentially creates a connection (for
TCP only) between a client machine and a server machine. Then it sends traffic in the form
of a certain number of either UDP or TCP packets for a certain period of time.

3. How can bandwidth be calculated using the above approach?

4. Connect two machines using a switch. Designate Machine A as the server machine (in the
sense that it listens for and accepts requests for TCP connections) and Machine B as the
client server. Make sure that the machines are connected to each other using the ping
application. Write down the IP addresses and MAC address (of physical interfaces) of both
machines, and the switch model below:

Machine A:
Machine B:
Switch model:

Run the Command Prompt on both machines and enter the directory containing IPerf.exe.
Run Ethereal and start capturing on a physical interface.

5. In the command window of Machine A, run the command: iperf -s

6. In the command window of Machine B, run the command “iperf –c <Machine-A-IP-


address>” – where <Machine-A-IP-address> is the IP address (in decimal-dot notation) of
Machine A.

7. Write down the final outputs at Machines A and B. Is there any difference in the values of
bandwidth? If yes, give a possible reason for the difference.

8. How many TCP packets did Ethereal capture?

9. Using the IPerf documentation, briefly describe the purpose of the commands mentioned
in steps 5 and 6.

10. Exit Ethereal without saving any packet traces. Repeat steps 5 and 6. Write down the
final outputs at Machines A and B. Are there any differences in the values of bandwidth and
the ones in step 7? If yes, give a possible reason for the difference.

Computer Communications, Lab Manual 25


National University of Computer and Emerging Sciences, Lahore Campus

11. TCP uses a variable called “Window” to send (or receive) certain amounts of data in one
go. E.g. if TCP Window is set to be 130KByte, this means that the sum of the sizes of all
packets sent (or received) by a machine at a given time is 130KByte. This variable is
directly proportional to the bandwidth and the latency of physical links that TCP packets
traverse. For optimal performance (i.e. maximum bandwidth), it is necessary to select and
set an appropriate value of the variable.

12. You will now use IPerf to find out the best Window size for Machine B for a fixed Window
size of Machine B. To set, e.g., a Window of size 130KBye, you will repeat step 5 but will run
the command “iperf –c <Machine-A-IP-address> –w 130k” on Machine B.

13. Find the optimal Window size for Machine B by setting its Window from 10-150KByte in
steps of 10KByte, and then fine-tuning to a precise optimal value. State also the default
Window size of Machine A as display on its command window after running the command.

Sr. Window(KB) Measured


# Bandwidth
1 10
2 20
3 30
4 40
5 50
6 60
7 70
8 80
9 90
10 100
11 110
12 120
13 130
14 140
15 150

Window size (Machine A):__________________________________

14. Run the Command Prompt on both machines and enter the directory containing
IPerf.exe. Run Ethereal and start capturing on a physical interface.

15. In the command window of Machine A, run the command: iperf –s –u –i 1

16. In the command window of Machine B, run the command “iperf –c <Machine-A-IP-
address> -u –b 10m” – where <Machine-A-IP-address> is the IP address (in decimal-dot
notation) of Machine A.

17. Write down all the non-zero values, if any, of the number of packets lost as well as jitter
and their corresponding intervals.

Computer Communications, Lab Manual 26


National University of Computer and Emerging Sciences, Lahore Campus

18. How many UDP packets did Ethereal capture?

19. Using the IPerf documentation, briefly describe the purpose of the commands
mentioned in steps 15 and 16.

20. Exit Ethereal without saving any packet traces. Repeat steps 15 and 16. Note the final
outputs at Machines A and B. Are there any differences in the number of packets lost here
and the number in step 17? If yes, give a possible reason for the difference.

References:
[1] http://dast.nlanr.net/Projects/Iperf

Computer Communications, Lab Manual 27


National University of Computer and Emerging Sciences, Lahore Campus
Experiment no 5:
Protocol Implementation in ns-2

Figure 1

The figure above models a part of the FAST-NUCES Lahore Campus network topology. The
networks labeled Lab-4 and Lab-3 are Ethernet-based Local Area Networks, constituting two
different broadcast domains. Both LAN are connected through various network devices
(shown in the figure) finally to the Internet backbone that connects all of Pakistan. The PIE
router, in Lahore, is connected via FDDI to a gateway router in Karachi (not shown in the
figure).

It has been proposed that the gateway router be connected, via FDDI, to a gateway router
in Amsterdam. You are part of a network design and analysis team in FAST interested in
gauging the effects of the new link on the campus network performance (throughput, delay
etc.). Your first job is to create a simple but fairly accurate model of the new network
topology in the simulator ns-2 while abiding by the following constraints:

• All nodes in any given LAN must be created using for loop(s) in the ns script.

• The LAN topology must be created using the method newLan of the Simulator class.

• The bandwidths and propagation delays must be carefully specified for each link.

Computer Communications, Lab Manual 28


National University of Computer and Emerging Sciences, Lahore Campus
• An FTP server in the Internet (specified in the model as a node connected to the
gateway router) is connected to one FTP client in Lab-3 and one in Lab-4.

Useful data:

Distance between Lahore and Karachi: 1000km


Distance between Karachi and Amsterdam: 5000km
Speed of Light: 300, 000, 000 m/s

Computer Communications, Lab Manual 29


National University of Computer and Emerging Sciences, Lahore Campus
Due to uncertain conditions, the bit error rate along Karachi-Lahore Optical Fiber link has
suddenly increased leading to performance complaints from ISPs around the country.

One proposal to improve performance is to replace the whole link, but it is deemed too
costly. Another proposal is to use an Automatic-Repeat-Request-based link layer protocol.
As an internee in the Pakistan Internet Exchange (PIE), you suddenly find yourself
responsible for analyzing the performance of a “pipelined” Stop-and-Wait (SAW) ARQ
protocol through simulation using a topology model similar to the one built in Q2. Your first
job is to create a non-pipelined version of the protocol in ns-2.

The protocol specifications are as follows:

• Any SAW packet may be the ACK (acknowledgement) of a data-carrying packet. A


header field is used to indicate whether or not the packet is an ACK. [1 point]

• Every packet carries a sequence number, which indicates the amount of data
transmitted by the protocol agent. It is calculated by adding the current sequence
number to the size (in characters or bytes) of the data to be sent. The ACK of such a
packet will also contain the same sequence number to indicate the data
acknowledged. [1+2+1 points]

• No data will be sent by a sender agent until one ACK for the previous data packet
has been received. [5 points]

• OPTIONAL: If an ACK has not been received for 1 second, the corresponding data
packet is sent again. [10 bonus points]

You are required to write the header, C++ and Tcl files for this protocol.

Computer Communications, Lab Manual 30


National University of Computer and Emerging Sciences, Lahore Campus
Experiment no 6:
Socket Programming in MS Windows

Design a full-duplex client-server chatting application by extending the sockets program


discussed in the lab. You should find out how can multithreading be used to help you
implement a full-duplex protocol.
As a home assignment, you should find out an alternative to multithreading that can be
used to implement full-duplex protocols (Hint: It is a different type of socket).

Computer Communications, Lab Manual 31