Lab 3 - TCPUDP Protocol
Lab 3 - TCPUDP Protocol
3
Lab
FOR EDUCATIONAL PURPOSE ONLY
TCP/UDP Protocol
Networking
3/2024
For Internal Circulation only
< Posting on the internet in any form is strictly prohibited>
CS4283 – Networking
Lab 3: TCP/UDP Protocol
2
A. GENERAL
1. Objective
▪ Learn how to stream a video over the network with VLC and learn the behavior of the
TCP - UDP protocol.
▪ Use Wireshark to capture packets and analyze characteristics of TCP and UDP packets
via streaming media.
▪ Learn how TCP uses sequence numbers and acknowledgment numbers to transmit data
reliably.
2. Environment
▪ Students need to prepare a Windows/Linux computer/laptop with an Internet connection.
▪ Software:
o Wireshark. (Download the latest version at:
https://www.wireshark.org/download.html)
o VLC media player. (Download the latest version at:
https://www.videolan.org/vlc/index.html)
B. HANDS-ON
1. UDP Protocol
Start capturing packets in Wireshark and then do something that will cause your host to send
and receive several UDP packets. It’s also likely that just by doing nothing (except capturing
packets via Wireshark) that some UDP packets sent by others will appear in your trace. In
particular, the Simple Network Management Protocol (SNMP – see section 5.7 in the text)
sends SNMP messages inside of UDP, so it’s likely that you’ll find some SNMP messages (and
therefore UDP packets) in your trace.
After stopping packet capture, set your packet filter so that Wireshark only displays the UDP
packets sent and received at your host. Pick one of these UDP packets and expand the UDP
fields in the details window. If you are unable to find UDP packets or are unable to run
Wireshark on a live network connection, you can download a packet trace containing some
UDP packets.
CS4283 – Networking
Lab 3: TCP/UDP Protocol
3
Whenever possible, when answering a question below, you should hand in a printout of the
packet(s) within the trace that you used to answer the question asked. Annotate the printout1
to explain your answer. To print a packet, use File->Print, choose Selected packet only, choose
Packet summary line, and select the minimum amount of packet detail that you need to answer
the question.
Task 1:
1. Select one UDP packet from your trace. From this packet, determine how many fields
there are in the UDP header. (You shouldn’t look in the textbook! Answer these
questions directly from what you observe in the packet trace.) Name these fields.
2. By consulting the displayed information in Wireshark’s packet content field for this
packet, determine the length (in bytes) of each of the UDP header fields.
3. The value in the Length field is the length of what? (You can consult the text for this
answer). Verify your claim with your captured UDP packet.
4. What is the maximum number of bytes that can be included in a UDP payload? (Hint:
the answer to this question can be determined by your answer to 2. above)
5. What is the largest possible source port number? (Hint: see the hint in 4.)
6. What is the protocol number for UDP? Give your answer in both hexadecimal and
decimal notation. To answer this question, you’ll need to look into the Protocol field of
the IP datagram containing this UDP segment (see Figure 4.13 in the text, and the
discussion of IP header fields).
7. Examine a pair of UDP packets in which your host sends the first UDP packet and the
second UDP packet is a reply to this first UDP packet. (Hint: for a second packet to be
sent in response to a first packet, the sender of the first packet should be the destination
of the second packet). Describe the relationship between the port numbers in the two
packets.
2. TCP Protocol
a. Capturing a bulk TCP transfer from your computer to a remote server
Before beginning our exploration of TCP, we’ll need to use Wireshark to obtain a packet trace
of the TCP transfer of a file from your computer to a remote server. You’ll do so by accessing a
Web page that will allow you to enter the name of a file stored on your computer (which
contains the ASCII text of Alice in Wonderland), and then transfer the file to a Web server using
the HTTP POST method (see section 2.2.3 in the text). We’re using the POST method rather
than the GET method as we’d like to transfer a large amount of data from your computer to
another computer. Of course, we’ll be running Wireshark during this time to obtain the trace
of the TCP segments sent and received from your computer.
1
What do we mean by “annotate”? If you hand in a paper copy, please highlight where in the printout you’ve found
the answer and add some text (preferably with a colored pen) noting what you found in what you ‘ve highlight. If you
hand in an electronic copy, it would be great if you could also highlight and annotate.
CS4283 – Networking
Lab 3: TCP/UDP Protocol
4
Do the following:
• Start up your web browser. Go the http://gaia.cs.umass.edu/wireshark-labs/alice.txt and
retrieve an ASCII copy of Alice in Wonderland. Store this file somewhere on your
computer.
• Next go to http://gaia.cs.umass.edu/wireshark-labs/TCP-wireshark-file1.html.
• You should see a screen that looks like:
• Use the Browse button in this form to enter the name of the file (full path name) on
your computer containing Alice in Wonderland (or do so manually). Don’t yet press the
“Upload alice.txt file” button.
• Now start up Wireshark and begin packet capture (Capture->Start) and then press OK
on the Wireshark Packet Capture Options screen (we’ll not need to select any options
here).
• Returning to your browser, press the “Upload alice.txt file” button to upload the file to
the gaia.cs.umass.edu server. Once the file has been uploaded, a short congratulations
message will be displayed in your browser window.
• Stop Wireshark packet capture. Your Wireshark window should look similar to the
window shown below.
CS4283 – Networking
Lab 3: TCP/UDP Protocol
5
If you are unable to run Wireshark on a live network connection, you can download a packet
trace file that was captured while following the steps above on one of the author’s computers2.
You may well find it valuable to download this trace even if you’ve captured your own trace
and use it, as well as your own trace, when you explore the questions below
b. A first look at the captured trace
Before analyzing the behavior of the TCP connection in detail, let’s take a high level view of
the trace.
• First, filter the packets displayed in the Wireshark window by entering “tcp”
(lowercase, no quotes, and don’t forget to press return after entering!) into the display
filter specification window towards the top of the Wireshark window.
What you should see is series of TCP and HTTP messages between your computer and
gaia.cs.umass.edu. You should see the initial three-way handshake containing a SYN message.
You should see an HTTP POST message. Depending on the version of Wireshark you are
using, you might see a series of “HTTP Continuation” messages being sent from your
computer to gaia.cs.umass.edu. Recall from our discussion in the earlier HTTP Wireshark lab,
2
Download the zip file http://gaia.cs.umass.edu/wireshark-labs/wireshark-traces.zip and extract the file tcp-ethereal-
trace-1. The traces in this zip file were collected by Wireshark running on one of the author’s computers, while
performing the steps indicated in the Wireshark lab. Once you have downloaded the trace, you can load it into
Wireshark and view the trace using the File pull down menu, choosing Open, and then selecting the tcp-ethereal-trace-
1 trace file.
CS4283 – Networking
Lab 3: TCP/UDP Protocol
6
that is no such thing as an HTTP Continuation message – this is Wireshark’s way of indicating
that there are multiple TCP segments being used to carry a single HTTP message. In more
recent versions of Wireshark, you’ll see “[TCP segment of a reassembled PDU]” in the Info
column of the Wireshark display to indicate that this TCP segment contained data that
belonged to an upper layer protocol message (in our case here, HTTP). You should also see
TCP ACK segments being returned from gaia.cs.umass.edu to your computer.
Task 2: Answer the following questions, by opening the Wireshark captured packet file tcp-
ethereal-trace-1 in http://gaia.cs.umass.edu/wireshark-labs/wireshark-traces.zip (that is download
the trace and open that trace in Wireshark; see footnote 2). Whenever possible, when
answering a question you should hand in a printout of the packet(s) within the trace that you
used to answer the question asked. Annotate the printout3 to explain your answer. To print a
packet, use File->Print, choose Selected packet only, choose Packet summary line, and select the
minimum amount of packet detail that you need to answer the question.
1. What is the IP address and TCP port number used by the client computer (source) that
is transferring the file to gaia.cs.umass.edu? To answer this question, it’s probably
easiest to select an HTTP message and explore the details of the TCP packet used to
carry this HTTP message, using the “details of the selected packet header window”
(refer to Figure 2 in the “Getting Started with Wireshark” Lab if you’re uncertain about
the Wireshark windows.
2. What is the IP address of gaia.cs.umass.edu? On what port number is it sending and
receiving TCP segments for this connection?
If you have been able to create your own trace, answer the following question:
3. What is the IP address and TCP port number used by your client computer (source) to
transfer the file to gaia.cs.umass.edu?
Since this lab is about TCP rather than HTTP, let’s change Wireshark’s “listing of captured
packets” window so that it shows information about the TCP segments containing the HTTP
messages, rather than about the HTTP messages. To have Wireshark do this, select
Analyze->Enabled Protocols. Then uncheck the HTTP box and select OK. You should now see a
Wireshark window that looks like:
3
What do we mean by “annotate”? If you hand in a paper copy, please highlight where in the printout you’ve found
the answer and add some text (preferably with a colored pen) noting what you found in what you ‘ve highlight. If you
hand in an electronic copy, it would be great if you could also highlight and annotate.
CS4283 – Networking
Lab 3: TCP/UDP Protocol
7
This is what we’re looking for - a series of TCP segments sent between your computer and
gaia.cs.umass.edu. We will use the packet trace that you have captured (and/or the packet
trace tcp-ethereal-trace-1 in http://gaia.cs.umass.edu/wireshark-labs/wireshark-traces.zip; see
earlier footnote) to study TCP behavior in the rest of this lab.
c. TCP Basic
Task 3: Answer the following questions for the TCP segments:
4. What is the sequence number of the TCP SYN segment that is used to initiate the TCP
connection between the client computer and gaia.cs.umass.edu? What is it in the
segment that identifies the segment as a SYN segment?
5. What is the sequence number of the SYNACK segment sent by gaia.cs.umass.edu to the
client computer in reply to the SYN? What is the value of the Acknowledgement field
in the SYNACK segment? How did gaia.cs.umass.edu determine that value? What is it
in the segment that identifies the segment as a SYNACK segment?
6. What is the sequence number of the TCP segment containing the HTTP POST
command? Note that in order to find the POST command, you’ll need to dig into the
packet content field at the bottom of the Wireshark window, looking for a segment
with a “POST” within its DATA field.
7. Consider the TCP segment containing the HTTP POST as the first segment in the TCP
connection. What are the sequence numbers of the first six segments in the TCP
CS4283 – Networking
Lab 3: TCP/UDP Protocol
8
connection (including the segment containing the HTTP POST)? At what time was
each segment sent? When was the ACK for each segment received? Given the
difference between when each TCP segment was sent, and when its acknowledgement
was received, what is the RTT value for each of the six segments? What is the
EstimatedRTT value (see Section 3.5.3, page 242 in text) after the receipt of each ACK?
Assume that the value of the EstimatedRTT is equal to the measured RTT for the first
segment, and then is computed using the EstimatedRTT equation on page 242 for all
subsequent segments.
Note: Wireshark has a nice feature that allows you to plot the RTT for each of
the TCP segments sent. Select a TCP segment in the “listing of captured
packets” window that is being sent from the client to the gaia.cs.umass.edu
server. Then select: Statistics->TCP Stream Graph->Round Trip Time Graph.
8. What is the length of each of the first six TCP segments?4
9. What is the minimum amount of available buffer space advertised at the received for
the entire trace? Does the lack of receiver buffer space ever throttle the sender?
10. Are there any retransmitted segments in the trace file? What did you check for (in the
trace) in order to answer this question?
11. How much data does the receiver typically acknowledge in an ACK? Can you identify
cases where the receiver is ACKing every other received segment (see Table 3.2 on page
250 in the text).
12. What is the throughput (bytes transferred per unit time) for the TCP connection?
Explain how you calculated this value.
4
The TCP segments in the tcp-ethereal-trace-1 trace file are all less that 1460 bytes. This is because the computer on
which the trace was gathered has an Ethernet card that limits the length of the maximum IP packet to 1500 bytes (40
bytes of TCP/IP header data and 1460 bytes of TCP payload). This 1500 byte value is the standard maximum length
allowed by Ethernet. If your trace indicates a TCP length greater than 1500 bytes, and your computer is using an
Ethernet connection, then Wireshark is reporting the wrong TCP segment length; it will likely also show only one
large TCP segment rather than multiple smaller segments. Your computer is indeed probably sending multiple smaller
segments, as indicated by the ACKs it receives. This inconsistency in reported segment lengths is due to the
interaction between the Ethernet driver and the Wireshark software. We recommend that if you have this
inconsistency, that you perform this lab using the provided trace file.
CS4283 – Networking
Lab 3: TCP/UDP Protocol
9
Here, each dot represents a TCP segment sent, plotting the sequence number of the
segment versus the time at which it was sent. Note that a set of dots stacked above each
other represents a series of packets that were sent back-to-back by the sender.
CS4283 – Networking
Lab 3: TCP/UDP Protocol
10
Task 4: Answer the following questions for the TCP segments the packet trace tcp-ethereal-
trace-1 in http://gaia.cs.umass.edu/wireshark-labs/wireshark-traces.zip
13. Use the Time-Sequence-Graph(Stevens) plotting tool to view the sequence number versus
time plot of segments being sent from the client to the gaia.cs.umass.edu server. Can
you identify where TCP’s slowstart phase begins and ends, and where congestion
avoidance takes over? Comment on ways in which the measured data differs from the
idealized behavior of TCP that we’ve studied in the text.
14. Answer each of two questions above for the trace that you have gathered when you
transferred a file from your computer to gaia.cs.umass.edu
D. REFERENCES
The lab is based on Wireshark Lab: Getting Started - Supplement to Computer Networking: A
Top-Down Approach, 7th ed., J.F Kurose and K.W Ross.
END!
CS4283 – Networking