Home > Experiential Learning > Understanding Transport Layer Basics – Experiential Learning Series

Understanding Transport Layer Basics – Experiential Learning Series

Experiential Exercises

 
All the example programs as described in these exercises can be downloaded from [8]. To carry out these experimental exercises, four simple Python programs are used which are listed below and accessible at [8].

i. udp_client.py
ii. udp_server.py
iii. tcp_client.py
iv. tcp_server.py

One does not need to understand Python in detail to use these programs. Python is very readable, and even a cursory reading of these programs will provide insight into their functionality. If these programs are downloaded on a Linux (e.g., Ubuntu) machine, give them execute permissions in the terminal window (i.e., chmod +x *.py) so that they can be invoked directly as ./udp_client.py, etc. Use the option -h to understand the usage syntax (e.g., ./udp_client.py –h). By default, both the TCP and UDP server programs listen on port number 9999 the use the IP addresses that have been assigned to the server host. The server program reads the data in the buffer size of 20 bytes (default value) and reads data from socket without any delay and displays the same. The client program by default connects to the server on port 9999, but requires the server’s IP address to be specified as a command line argument with the -s option. The client uses a buffer size of 50 bytes (default value) and sends 10 messages (default) at interval of 5 seconds (default) each. All these values are configurable and can be changed when running the program to enable experimentation with various permutations and combinations. The options for these programs are:

for

All the exercises use the network setup as shown in Figure 1. The programs are invoked in the terminal command windows.

Note: When using Wireshark capture on the client, use the capture filter as “host 10.1.1.1” (where 10.1.1.1 is server’s IP address – replace this value as per your experimental setup). Similarly, when running Wireshark capture on the server host, use the capture filter as “host 10.1.1.3” where 10.1.1.3 is the IP address of the client machine.

Exercise 1

Topic: UDP Message Oriented Delivery

a. Run the UDP server program on server host Hs (./udp_server.py).

b. Run the UDP Client program on client host Hc (./udp_client.py). This will start sending message of 50 bytes size, 1st message containing letter ‘A’, 2nd message containing all ‘B’s, and so on. The client program also displays the data that is being sent.

c. Study the data displayed on server application terminal command window. It will display 20 letters of ‘A’ immediately after client program is invoked, and then the after the lapse of client delay time will display 20 letters of ‘B’, and so on.

d. Even though client has sent 50 number of ‘A’ (data), the server application has received only 20 and displays only 20 bytes of message. This demonstrates message oriented service delivery of UDP protocol.

e. Run the Wireshark capture on server and analyze the actual amount of data received. It will be equal to what client has sent.

f. Rerun the client and server programs with different buffer size, number of counts etc. and analyze UDP behavior.

Note: For, both the client and server program, use the buffer size more than 1500 bytes and analyze Wireshark capture to see the UDP message being fragmented at the IP layer. Observe that UDP will continue to deliver the entire message in one go to the application.

Exercise 2

Topic: UDP Packet Loss

a. Repeat the above exercise (Exercise 1) with client sending 10 messages at intervals of 5 seconds.

b. Server should display first message as ‘A’, and so on.

c. Break the link between switch S1 and S2 at 16th seconds and restore this link at 32nd second. To break
the link, just remove the Ethernet wire connecting 2 switches.

d. Analyze the server response displayed on the screen. It should display first 4 messages at interval of 5s,
and then there should not be any display for next 20 seconds i.e. it should not display any message from
5th to 7th and then it should display 8th, 9th and 10th message again at the interval of 5s.

e. Using wireshark, analyze the packet sent by client as well as those received by server. Identify which
packets are received and which are lost. The capture at client should show transmission of all the 10
packets, but capture at server should show 7 packets received implying 3 packets are lost.

f. The program demonstrates the unreliability of UDP protocol and that any lost packets are not retransmitted by UDP protocol.

Exercise 3

Topic: UDP Integrity Check.

a. To understand UDP checksum i.e. Integrity check and be able to modify the data, we will use nc tool for both client and server.

b. On the server machine, in the terminal window, run ‘nc –u –l 8192’. This will run UDP server on port number 8192.

c. On the client machine, in the terminal window, run ‘nc –u 10.1.1.1 8192’, where 10.1.1.1 is the server’s IP address. Use the appropriate IP address as applicable in your experimental setup.

d. Run wireshark capture on client and/or server machine.

e. Enter some text e.g. “Hello” (and press enter to send) on client machine where nc is running. Server nc window should show this text message. Note down the UDP Checksum value in the wireshark capture. It is the 4th and last field in UDP header.

f. On the client terminal running ‘nc’, now enter “UQUQUQHello” and send it to server.

g. Analyze the UDP Checksum for this message sent to server. This should have same checksum value as
corresponding to “Hello”.

h. On the client terminal, enter “llHeo” and send the message.

i. The wireshark capture should still show the same checksum value.

j. This exercise demonstrates that UDP checksum works at a very basic level and any new message can be
constructed to have the same checksum.

Exercise 4
Topic: TCP Streaming
a. Repeat the exercise for UDP message boundary (Exercise 1:) but with TCP Client and TCP server instead of UDP. The client should send 10 messages, each message of 50 bytes, at intervals of 5 seconds

b. The TCP Client program should read 20 bytes of data from the socket at a time (use the option –b 20 indicating buffer size of 20).

c. The server should display the message in chunks of 20bytes (or 10 bytes) but will display the full message content (though in parts) unlike the UDP case where only first 20 bytes are displayed.

d. Server should display all the 10 messages in the same order as sent by the client.

e. Analyze the TCP message transmission using wireshark on client and server.

f. Rerun the server program with buffer size of 5 bytes, and delay of 1s and verify that server still receives
all the messages though messages will be displayed in chunks of 5 bytes at every 1s. Still no message should be lost.

g. Analyze this above behavior using wireshark at what times messages were transmitted and what time
these were received. The message may be received much earlier but display of these message chunks could be much later on account delay introduced in server program.

h. Next, repeat this exercise but this time server program should read 100 bytes at an interval of 10s (by
default it is zero).

i. In two second interval, two message will arrive from the client and thus server should receive all the 100
bytes in one read call i.e. TCP combines the data of two different segments when such data is available.

j. This program demonstrates that TCP provides streaming service for data delivery.

Exercise 5

Topic: TCP Packet Loss, Timeout and Recovery

a. Repeat the above exercise for TCP streaming (Exercise 4:) The TCP client should send 10 messages, each
message of 50 bytes, at intervals of 5 seconds

b. Server should display first message as ‘A’, in the chunks of 20 bytes and so on.

c. Break the link between switch S1 and S2 at 16th seconds and restore this link at 32nd second as before.

d. Analyze the server response displayed on the screen. It should display first 4 messages at interval of 5s,
and then there should not be any display for next 20 seconds. After 32nd second, it should display contents of 5th to 7th message immediately one after the other, and then it should display 8th, 9th and 10th message at the interval of 5s. The messages from 5th to 7th are stored in TCP buffer in client side and would be repeatedly retransmitted at double the time interval (TCP timeout) from its previous transmission.

e. Using wireshark, analyze the packet sent by client as well as those received by server. Analyze how many
TCP Segments are retransmitted. Especially, analyze when the 5th, 6th and 7th message do get transmitted.

f. Analyze at the server, which TCP segment contains the message from 6th to 7th. All of these should be
received by the server in the single segment rather than separately.

g. In the packet capture analyze the time when TCP segments are retransmitted. This time gap should
keep on doubling at each retransmission till an acknowledgement is received and then transmission time
should be restored back to normal.

h. Analyze the acknowledgement of 6th and 7th message. There should be a single acknowledgement
rather than two separate. This indicates that TCP provides cumulative acknowledgement.

i. This exercise demonstrates use of TCP timeout and retransmission to provide reliable delivery of data.
Further, all the data bytes are delivered in-order at the server application implying that TCP always delivers data in order.

Pages ( 4 of 5 ): « Previous123 4 5Next »

Leave a Comment:

Your email address will not be published. Required fields are marked *