T. Andrew Yang

Email: yang@uhcl.edu

Web: 

https://sceweb.uhcl.edu/yang/

Tel.:

(281) 2833835 

Last updated:

10/3: Lab 3 revised

10/2/2024: Lab 3 posted

9/24/2024: Lab 2 posted

08/22/2024: Lab 1 posted

 

CSCI 4312 Network Protocols


Lab 1

Lab 2

Lab 3

 

NOTE: When preparing your answers, you are welcome to use any resources, including the text books and the class notes. However, make sure you properly cite the work of other researchers or professionals. Visit https://sceweb.uhcl.edu/yang/citing.htm for more information about cited references. 

Warning: Missing or improper cited references in your answers will result in poor scores.

Note: You may cite the lectures if your answer comes from the lectures.

Note about AI tools: You may use AI tools such as ChatGPT as a starting point while putting together your own answer; however, simply copying the answer produced by ChatGPT (or any AI tool) is considered cheating.


Lab 1

Total: 100 points

1.       (10 pts) Visit the class discussion group in the Canvas. Post a message with your full name as the subject line. In your post, briefly introduce yourself, including your full name, your major, and one or two items that you most desire to learn in this class. Throughout this class, you shall regularly participate in the discussion group to find recent announcements, reminders, and discussions. 

 

2.       Suppose John is using his laptop to send a piece of data (d) to Mary. Below are some assumptions.

Assumptions:

(a)    The IP of John’s laptop is 281.832.005.123, and its MAC address is A4-41-5D-BB-08-C9.

(b)    Mary’s computer’s IP address is 777.555.123.100, and its MAC is B9-5C-D8-66-95-4F.

(c)    The IP of the default gateway/router of John’s laptop is 222.333.444.101, and its MAC is 11-22-33-44-55-AB-C0.

Answer the following questions:

2.1.    (10 pts) How would the Layer-3 header (i.e., IP header) be structured? Hint: Show the source address and the destination address.

2.2.    (10 pts) How would the Layer-2 header be structured? Hint: Show the source address and the destination address.

2.3.    (10 pts) Explain how John’s default router would process the packet sent from John’s computer.

 

3.       Encapsulation vs Tunneling in networking:

3.1.    (10 pts) What does encapsulation mean in networking protocols? Give two examples of encapsulation in networking protocols.

3.2.    (10 pts) What does tunneling mean in networking protocols? Give two examples of tunneling protocols.

 

4.       (10 pts) The sockets abstraction may be implemented as a UDP socket or a TCP socket. Explain the relative pros and cons of UDP sockets and TCP sockets.

 

5.       Both TCP and IP are end-to-end protocols.

5.1.    (10 pts) Explain what end-to-end means in networking.

5.2.    (10 pts) In the TCP, an end is identified by an IP address and a port number; however, in the IP, an end is identified by an IP address. Explain why.

 

6.       The default HTTP protocol is stateless.

6.1.    (5 pts) First, explain what it means that HTTP being stateless.

6.2.    (5 pts) Second, give one example mechanism that could help an HTTP server maintain clients’ states.

 

 

Go to the Index

 

Lab 2

Total: 100 points

 

1.1.    Wireshark and network utilities: The purpose of this lab is to use Wireshark and network utilities to gain deeper understanding of the various network protocols running on your computer.

Hint: To become familiar with the Wireshark, review Wireshark_Intro_v8.1 to learn about the basics.

1.2.    Review the file Wireshark_HTTP_v8.1 and work on the following exercises.

1.2.1.  This exercise is about exercise “1. The Basic HTTP GET/response interaction”. Follow the instructions given in that exercise and then answer the following questions:

a)    (5 pts) What is the IP address of the server gaia.cs.umass.edu? Hint: Use nslookup to find the answer.

To hand in: A screen shot (similar to the one shown below) that shows how you find the IP address.

b)    (5 pts) In Wireshark, verify the mapping between that host name and the IP address.

To hand in: A screen shot similar to the one below that shows both the host name and the destination IP address of the HTTP GET message.

c)    (5 pts) Open a Command Prompt (in Windows) and use the ‘ipconfig /all’ command to find out the following information of the computer you use: (a) its IP addresses (IPv4 and IPv6); (b) its physical (aka MAC) address; (c) its default router’s IP address

To hand in: A screen shot similar to the one below that shows the required information.

d)    (5 pts) The ARP (Address Resolution Protocol) command allows the user to find the mapping between an IP address of a computer and that computer’s MAC address. Use the ‘arp –a’ command to find the MAC address of the default router of the computer you use.

To hand in: A screen shot similar to the one below that shows the result.

e)    (5 pts) Use Wireshark to verify that those information you obtained in the steps above are all correct. Hints: MAC address are used at Layer 2; IP addresses are used at Layers 3 and 4. The destination MAC address at Layer 2 should be that of your computer’s default router, and the source IP at layer 3 should be your computer’s IP address.

To hand in: A screen shot similar to the one below that shows relevant information.

f)     Refer to Chapter 2 of the textbook when answering the following questions.

f.1 (5 pts) What is the HTTP Request Line?

f.2 (5 pts) What is the HTTP ‘host’ header line?

 

g)    At the Transport Layer, how are the two ends represented? Hint: At Layer 4, both the IP address and the port number are required.

g.1 (5 pts) How is the HTTP client process represented?

g.2 (5 pts) How is the HTTP server process represented?

 

h)    At the Network Layer, how are the two ends represented?

h.1 (5 pts) How is the computer where the HTTP client process resides represented?

h.2 (5 pts) How is the computer where the HTTP server process resides represented?

i)     (8 pts) The HTTP packet is encapsulated into a TCP packet, which is encapsulated into an IP packet, which is then encapsulated into a Layer 2 packet. Complete the following table by fill in the missing information in each of the headers.

Layer 2 header:

Source =

Destination =

IP header:

Source IP =                

Destination IP =

 

TCP header:

Source IP =                 

Source port =

Destination IP =

Destination port =

 

HTTP packet:

GET ...

...

 

 

2.       Sockets programming is discussed in section 2.7 (Chapter 2) of the textbook.

2.1.    (5 pts) Run the UDP sockets client (UDPClient.py) and server (UDPServer.py) programs. Enter your full name as the input message.

Hint: Use ‘localhost’ to replace ‘servername’ when you run both the client and the server on the same computer.

Hint: When copying programs from web pages, the double quotes and single quotes may need to be re-typed.

To hand in: The screen shots of running the server and the client programs.

 

2.2.    (5 pts) Run the TCP sockets client (TCPClient.py) and server (TCPServer.py) programs. Enter your full name as the input message.

To hand in: The screen shots of running the server and the client programs.

 

2.3.    Revise the TCP sockets client (TCPClient.py) and the TCP socket server (TCPServer.py) programs such that the client and the server behaves as shown below.

To hand in:

(a) (9 pts) The screen shots of running the server and the client programs.

(b) (9 pts) The revised server program.

(c) (9 pts) The revised client program.

 

 

Go to the Index

 

Lab 3

Total: 100 points

-          Python files to be used in this lab:                      serverTCP5.py             clientTCP5.py              testData5.txt (revised)

 

-          Screen shots of running this pair of server and client programs using the provided test data file:

 

1.       (5 pts) First, run the provided client and server programs using the provided test data file.

To hand in: The screenshots of running the programs on a computer.

2.       (5 pts) Run the client and the server programs on two separate computers connected to the same local area networks. In the client program, use the server computer’s IP address as the value of serverName (line #13). Run the revised programs.

To hand in: The screenshots of running the programs on a computer.

3.       Revise the client program that you used in EX 2 above by measuring the ‘send time’ and the ‘receive time’. NOTE: The sum of ‘send time’ and ‘receive time’ is the Round Trip Time (RTT). Add statements within and outside the loop to calculate the average ‘Disk Access Time (DAT)’, the average ‘Send Time (ST)’, the average ‘Receive Time (RT)’, and the average ‘Round Trip Time (RTT)’.

The output screen generated by the revised client program should look similar to Figure 1.

Server screen output:

Client screen output:

 

C:\sockets>python clienttcp7.py

experiment 0 ----------------------------------------------

Reading data from file

34191 bytes read from the file

>>>>> elapsed time of file read: 0.000000

>>>>>>>>>>>>>>>>>>>> send time = 0.000000

>>>>>>>>>>>>>>>>>>>> 34191  bytes sent to the server.

>>>>>>>>>>>>>>>>>>>> receive time = 0.000000

>>>>>>>>>>>>>>>>>>>> 34191  bytes received from the server.

>>>>> round trip time (RTT) = 0.000000

experiment 1 ----------------------------------------------

Reading data from file

34191 bytes read from the file

>>>>> elapsed time of file read: 0.000000

>>>>>>>>>>>>>>>>>>>> send time = 0.000000

>>>>>>>>>>>>>>>>>>>> 34191  bytes sent to the server.

>>>>>>>>>>>>>>>>>>>> receive time = 0.000000

>>>>>>>>>>>>>>>>>>>> 34191  bytes received from the server.

>>>>> round trip time (RTT) = 0.000000

experiment 2 ----------------------------------------------

Reading data from file

34191 bytes read from the file

>>>>> elapsed time of file read: 0.000000

>>>>>>>>>>>>>>>>>>>> send time = 0.000000

>>>>>>>>>>>>>>>>>>>> 34191  bytes sent to the server.

>>>>>>>>>>>>>>>>>>>> receive time = 0.000000

>>>>>>>>>>>>>>>>>>>> 34191  bytes received from the server.

>>>>> round trip time (RTT) = 0.000000

experiment 3 ----------------------------------------------

Reading data from file

34191 bytes read from the file

>>>>> elapsed time of file read: 0.015595

>>>>>>>>>>>>>>>>>>>> send time = 0.000000

>>>>>>>>>>>>>>>>>>>> 34191  bytes sent to the server.

>>>>>>>>>>>>>>>>>>>> receive time = 0.000000

>>>>>>>>>>>>>>>>>>>> 34191  bytes received from the server.

>>>>> round trip time (RTT) = 0.000000

experiment 4 ----------------------------------------------

Reading data from file

34191 bytes read from the file

>>>>> elapsed time of file read: 0.000000

>>>>>>>>>>>>>>>>>>>> send time = 0.000000

>>>>>>>>>>>>>>>>>>>> 34191  bytes sent to the server.

>>>>>>>>>>>>>>>>>>>> receive time = 0.000000

>>>>>>>>>>>>>>>>>>>> 34191  bytes received from the server.

>>>>> round trip time (RTT) = 0.000000

average DAT = 0.003899.

average ST = 0.000000.

average RT = 0.000000.

average RTT = 0.000000.

 

C:\sockets>

Figure 1. Screen output of the revised client program (showing the ‘send time’ and ‘receive time’ separately).

To hand in:

3.1.    (25 pts) The revised client program.

3.2.    (5 pts) The screenshots of running the programs on a computer.

3.3.    (5 pts) The screenshots of running the programs on two different computers.

3.4.    (10 pts) Explain the discrepancy between the 'send time' and the 'receive time'. That is, why is the 'send time' always zero (even when the client and the server programs are on two different computers)? Hint: Review 'Using a Socket' at https://docs.python.org/3/howto/sockets.html.

4.       As you may have noticed in the above exercise, without proper acknowledgments between the client and the server, the ‘send time’ measured by the client program is always zero.

Revise the method of measuring the 'send time' by waiting until an acknowledgement is sent from the server and received by the client to start measuring the 'send time'.

Similarly, revise the programs such that a more accurate calculation of the 'receive time' is implemented. That is, once the server sends an ACK to the client, it waits for the client to send back another ACK before it starts to send the data back to the client.

NOTE: To implement the acknowledgement mechanism, both the client and the server program must be revised.

A sample screen output that would be generated by the revised programs is shown in Figure 2.

Server output screen:

 

Client output screen:

 

C:\sockets>python clienttcp9localserver.py

experiment 0 ----------------------------------------------

Reading data from file

46513 bytes read from the file

>>>>> elapsed time of file read: 0.000495

Waiting to receive ACK from server ...

ACK: from server: 46513 bytes received.

Sending an ACK back to server ...

>>>>>>>>>>>>>>>>>>>> send time = 0.000501: 46513  bytes sent to the server.

>>>>>>>>>>>>>>>>>>>> receive time = 0.000499: 46513  bytes received from the server.

>>>>> round trip time (RTT) = 0.001503

experiment 1 ----------------------------------------------

Reading data from file

46513 bytes read from the file

>>>>> elapsed time of file read: 0.000502

Waiting to receive ACK from server ...

ACK: from server: 46513 bytes received.

Sending an ACK back to server ...

>>>>>>>>>>>>>>>>>>>> send time = 0.000501: 46513  bytes sent to the server.

>>>>>>>>>>>>>>>>>>>> receive time = 0.001003: 46513  bytes received from the server.

>>>>> round trip time (RTT) = 0.002005

experiment 2 ----------------------------------------------

Reading data from file

46513 bytes read from the file

>>>>> elapsed time of file read: 0.000501

Waiting to receive ACK from server ...

ACK: from server: 46513 bytes received.

Sending an ACK back to server ...

>>>>>>>>>>>>>>>>>>>> send time = 0.002006: 46513  bytes sent to the server.

>>>>>>>>>>>>>>>>>>>> receive time = 0.001004: 46513  bytes received from the server.

>>>>> round trip time (RTT) = 0.003511

experiment 3 ----------------------------------------------

Reading data from file

46513 bytes read from the file

>>>>> elapsed time of file read: 0.000502

Waiting to receive ACK from server ...

ACK: from server: 46513 bytes received.

Sending an ACK back to server ...

>>>>>>>>>>>>>>>>>>>> send time = 0.001003: 46513  bytes sent to the server.

>>>>>>>>>>>>>>>>>>>> receive time = 0.000483: 46513  bytes received from the server.

>>>>> round trip time (RTT) = 0.002505

experiment 4 ----------------------------------------------

Reading data from file

46513 bytes read from the file

>>>>> elapsed time of file read: 0.000501

Waiting to receive ACK from server ...

ACK: from server: 46513 bytes received.

Sending an ACK back to server ...

>>>>>>>>>>>>>>>>>>>> send time = 0.003508: 46513  bytes sent to the server.

>>>>>>>>>>>>>>>>>>>> receive time = 0.001004: 46513  bytes received from the server.

>>>>> round trip time (RTT) = 0.005013

average DAT = 0.000625.

average ST = 0.001880.

average RT = 0.000998.

average RTT = 0.003634.

 

C:\sockets>

Figure 2. Screen output of the revised client and server programs (showing the two ACKs)

To hand in:

4.1.    (35 pts) The revised programs.

4.2.    (5 pts) The screenshots of running the programs on a computer.

4.3.    (5 pts) The screenshots of running the programs on two different computers.

5.       (Bonus project, optional) What would happen if the data sent from the client is larger than the size of the buffer used by the server? What will happen is that the server will only read as many bytes as its buffer size. To witness this problem, reduce the size of the buffer in the server to, say 2048, and see the data loss in action. Read the discussion related to this issue at this page (https://docs.python.org/3/howto/sockets.html#using-a-socket, under 'Using a Socket') to find possible solutions to mitigate the problem.

To do:

(a)    A solution is to have the client, before sending the actual data, first send the number of bytes of the data.

Hint: The size of the data, an int, must be converted to bytes (of hexadecimal values) in order to be sent over the socket. Hint: Use the to_bytes() function. See an example on https://www.geeksforgeeks.org/how-to-convert-int-to-bytes-in-python/. When the bytes are received by the server, they must be converted back to int. Hint: Use the from_bytes() function. See https://www.geeksforgeeks.org/how-to-convert-bytes-to-int-in-python/.

 

(b)    Once the server has received the number of bytes of the data, the server then goes into a loop to read the data, one chunk per iteration, until the size of all the read chunks is the same as the size of the data it expects to receive. Hint: The size of the chunk is the same as the buffer size, except for the last chunk, which is less than the size of the buffer used by the server.

Sample screen outputs from the client (left) and the server (right) are shown in Figure 3.

 

Partial screen output generated by the server:

 

Screen output by the client:

 

Figure 3. Screen outputs respectively generated by the client and the server programs.

 

To hand in:

5.1.    (35 pts) The revised programs.

5.2.    (5 pts) The screenshots of running the programs on a computer.

 

Go to the Index