Lab-1 CS F303
Lab-1 CS F303
Lab-1 CS F303
Objectives
● It is an exercise in learning by doing and thinking.
● Do NOT consult a book, website, or a senior – if you do so, you are not learning..
● However, you are encouraged to consult/discuss/argue with other students in your class.
● The lab sheet material has been adapted from the lab exercises provided by the textbook
publisher.
One's understanding of network protocols can often be greatly deepened by "seeing protocols in action"
and by "playing around with protocols" – observing the sequence of messages exchanged between two
protocol entities, delving down into the details of protocol operation, and causing protocols to perform
certain actions and then observing these actions and their consequences. This can be done in simulated
scenarios or a "real" network environment like the Internet. In the Wireshark labs you'll be doing in this
course, you'll run various network applications in different scenarios using your computer. You'll observe
the network protocols in your computer "in action," interacting and exchanging messages with protocol
entities executing elsewhere on the Internet. Thus, you and your computer will be integral to these "live"
labs. You'll observe, and you'll learn by doing.
A packet sniffer is the basic tool for observing the messages exchanged between executing protocol entities.
As the name suggests, a packet sniffer captures ("sniffs") messages being sent/received from/by your
computer; it will also typically store and/or display the contents of the various protocol fields in these
captured messages. A packet sniffer itself is passive. It observes messages sent and received by applications
and protocols running on your computer but never sends packets. Similarly, received packets are never
explicitly addressed to the packet sniffer. Instead, a packet sniffer gets a copy of packets sent/received
from/by application and protocols executing on your machine.
Figure 1 shows the structure of a packet sniffer. At the right of Figure 1 are the protocols (in this case,
Internet protocols) and applications (such as a web browser or FTP client) that normally run on your
computer. The packet sniffer, shown within the dashed rectangle in Figure 1, is an addition to the usual
software in your computer and consists of two parts. The packet capture library receives a copy of every
link-layer frame sent from or received by your computer. You know that messages exchanged by higher
layer protocols such as HTTP, FTP, TCP, UDP, DNS, or IP are eventually encapsulated in link-layer frames
transmitted over physical media such as an Ethernet cable. In Figure 1, the assumed physical media is an
Ethernet, so all upper-layer protocols are eventually encapsulated within an Ethernet frame. Capturing all
link-layer frames thus gives you all messages sent/received from/by all protocols and applications executing
on your computer.
1|Page
Department of Computer Science & Information Systems
packet sniffer
operating
system Transport (TCP/UDP)
packet Network (IP)
capture copy of all Ethernet
Link (Ethernet)
frames sent/received
(pcap)
Physical
The second component of a packet sniffer is the packet analyzer, which displays the contents of all fields
within a protocol message. The packet analyzer must "understand" the structure of all messages exchanged
by protocols. For example, suppose we are interested in displaying the various fields in messages exchanged
by the HTTP protocol in Figure 1. The packet analyzer understands the format of Ethernet frames and can
identify the IP datagram within an Ethernet frame. It also understands the IP datagram format to extract the
TCP segment (as HTTP uses TCP as the underlying transport layer protocol) within the IP datagram.
Finally, it understands the TCP segment structure to extract the HTTP message contained in the TCP
segment. Finally, it understands the HTTP protocol.
Many packet sniffers are available, for example, Wireshark packet sniffer, Ethereal Network Analyzer,
Snoop Analyzer Standard, Network Probe, etc. We will use the Wireshark packet sniffer
[https://www.wireshark.org/] for these labs, allowing us to display the contents of messages being
sent/received from/by protocols at different levels of the protocol stack. (Technically speaking, Wireshark
is a packet analyzer that uses a packet capture library in your computer). Wireshark is a free network
protocol analyzer on Windows, Linux/Unix, and Mac computers. It operates in computers using Ethernet,
serial (PPP and SLIP), 802.11 wireless LANs, and many other link-layer technologies (if the OS on which
it's running allows Wireshark to do so).
2|Page
Department of Computer Science & Information Systems
Running Wireshark
When you run the Wireshark program, you'll get a startup screen, as shown in Figure-2:
Look at the screen – you'll see an "Interface list." It is the list of network interfaces on your computer. Once
you choose an interface, Wireshark will capture all packets on that interface. The example above has an
Ethernet interface (Gigabit network Connection) and some others. Use it for this lab.
Click on the "Ethernet" interface to start packet capture (i.e., for Wireshark to begin capturing all packets
being sent to/from that interface); a screen like the one shown in Figure 3 will be displayed, showing
information about the packets being captured. Once you start packet capture, you can stop it by using the
Capture pulldown menu and selecting Stop.
3|Page
Department of Computer Science & Information Systems
command
menus
display filter
specification
listing of
captured
packets
details of
selected
packet
header
packet content
in hexadecimal
and ASCII
Figure 3: Wireshark Graphical User Interface, during packet capture and analysis
● The command menus are standard pulldown menus at the top of the window. Of interest to us now
are the File and Capture menus. The File menu allows you to save captured packet data, open a file
containing previously captured packet data, and exit the Wireshark application. The Capture menu
enables you to begin packet capture.
● The packet-listing window displays a one-line summary for each packet captured, including the
packet number (assigned by Wireshark; this is not a packet number contained in any protocol's
header), the time at which the packet was captured, the packet's source and destination addresses,
the protocol type, and protocol-specific information contained in the packet. The packet listing can
be sorted according to these categories by clicking on a column name. The protocol type field lists
the highest-level protocol that sent or received this packet, i.e., the protocol that is the source or
ultimate sink for this packet.
● The packet-header details window provides details about the packet selected (highlighted) in the
packet-listing window. (To select a packet in the packet-listing window, place the cursor over the
packet's one-line summary in the packet-listing window and click the left mouse button.). These
details include information about the Ethernet frame (assuming the packet was sent/received over
an Ethernet interface) and the IP datagram that contains this packet. The amount of Ethernet and
IP-layer detail displayed can be expanded or minimized by clicking on the plus-minus boxes to the
left of the Ethernet frame or IP datagram line in the packet details window. If the packet has been
carried over TCP or UDP, TCP or UDP, details will also be displayed, which can similarly be
4|Page
Department of Computer Science & Information Systems
expanded or minimized. Finally, details about the highest-level protocol that sent or received this
packet are also provided.
● The packet-contents window displays all the captured frame's contents in ASCII and hexadecimal
format.
Towards the top of the Wireshark graphical user interface is the packet display filter field, into which a
protocol name or other information can be entered in order to filter the information displayed in the packet-
listing window (and hence the packet-header and packet-contents windows). In the example below, we'll
use the packet-display filter field to have Wireshark hide (not display) packets except those corresponding
to HTTP messages.
The best way to learn about any new piece of software is to try it out! Do the following
2. Start up the Wireshark software. You will initially see a window similar to that shown in Figure 2.
Wireshark has not yet begun capturing packets. Select the desired network interface. Packet capture
will begin - Wireshark is capturing all packets being sent/received from/by your computer!
3. Once you begin packet capture, a window similar to that shown in Figure 3 will appear. This
window shows the packets being captured. You can stop packet capture by selecting the Capture
pulldown menu and selecting Stop. But don't stop packet capture yet. Let's capture some
interesting packets first. To do so, we'll need to generate some network traffic. Let's do so using a
web browser, which will use the HTTP protocol.
6. Type in "http" (without the quotes and in lower case – all protocol names are in lower case in
Wireshark) into the display filter specification window at the top of the main Wireshark window.
Then select Apply (to the right of where you entered "http"). This will cause only the HTTP message
to be displayed in the packet-listing window.
5|Page
Department of Computer Science & Information Systems
7. Find the HTTP GET message that was sent from your computer to the webserver. When you select
the HTTP GET message, the Ethernet frame, IP datagram, TCP segment, and HTTP message
header information will be displayed in the packet header window. Recall that the HTTP GET
message that is sent to the gaia.cs.umass.edu web server is contained within a TCP segment, which
is contained (encapsulated) in an IP datagram, which is encapsulated in an Ethernet frame. By
clicking on '+' and '-'right-pointing and down-pointing arrowheads to the left side of the packet
details window, minimize the amount of Frame, Ethernet, Internet Protocol, and Transmission
Control Protocol information displayed. Maximize the amount of information displayed about the
HTTP protocol. Your Wireshark display should now look roughly as shown in Figure 4. (Note, in
particular, the minimized amount of protocol information for all protocols except HTTP and the
maximized amount of protocol information for HTTP in the packet-header window).
6|Page
Department of Computer Science & Information Systems
1. Clear browsing history. You can do it using the tools menu of your Brower.
2. Start Wireshark and apply filter "http" (without quotes) as we are interested in HTTP packets.
3. Type the following URL in your web browser and press enter:
4. http://demo.testfire.net/login.jsp
5. Stop capturing packets and observe different HTTP packets. Observe that there are two embedded
images on the web page.
Q1. How many HTTP GET requests are generated?
Q2. What can be concluded from your answer to Q1 above?
Q3. What is the status code returned in all HTTP response packets?
Q4. When were the objects embedded in the web page last modified at the server?
Q5. How many bytes of content are being returned to your browser in each HTTP response
packet?
6. Now, start Wireshark packet capture again and refresh the webpage, i.e., enter the URL:
http://demo.testfire.net/login.jsp
Stop capturing packets and observe different HTTP packets again.
Q1. What are the date header and Last Modified values in HTTP response packets?
Q2. Were two embedded images fetched from the server or locally cached? How to verify your
answer? Justify the answer to yourself.
In all the above experiments, see whether a response from the server was in one single packet or multiple
packets. You will have to observe TCP packets for it in each case.
The Traceroute program, written by Van. It lets us see the route that IP datagrams follow from one host to
another.
Although there are no guarantees that two consecutive IP datagrams from the same source to the same
destination follow the same route, most of the time, they do.
Traceroute uses ICMP (don't worry if you do not understand the ICMP protocols) and the TTL field in the
IP header. The TTL field (time-to-live) is an 8-bit field that the sender initializes to some value. The sender
7|Page
Department of Computer Science & Information Systems
initializes to some value. Each router that handles the packet (datagram) must decrement the TTL by either.
The purpose of the TTL field is to prevent datagrams from ending up in infinite loops, which can occur
during routing transients.
When a router gets an IP datagram whose TTL is 0 or 1, it must not forward it. (A destination host that
receives a datagram like this can deliver it to the application since it does not have to be routed. No system
should normally receive a datagram with a TTL of 0.) Instead, the router throws away the datagram and
sends an ICMP "time exceeded" message back to the originating host. The key to Traceroute is that the
IP datagram containing this ICMP message has the router's IP address as the source address.
We can now guess the operation of the Traceroute. It sends an IP datagram with a TTL of 1 to the destination
host. The first router to handle the datagram decrements the TTL, discards the datagram, and sends back
the ICMP time exceeded. It identifies the first router in the path. Traceroute then sends a datagram with a
TTL of 2, and we find the IP address of the second router. It continues until the datagram reaches the
destination host. But even though the arriving IP datagram has a TTL of 1, the destination host won't throw
it away and generate the ICMP time exceeded since the datagram has reached its final destination. How
can we determine when we've got the destination?
Traceroute sends UDP datagrams to the destination host. Still, it chooses the destination UDP port number
to be an unlikely value (larger than 30,000), making it improbable that an application at the destination is
using that port. It causes the destination host's UDP module to generates an ICMP "port unreachable" error
when the datagram arrives. All Traceroute needs to do is differentiate between the received ICMP
messages-time exceeded versus port unreachable to know when it's done.
We're now ready to run the traceroute and see the output. To perform the experiment, We will use a
Traceroute available online at https://www.ultratools.com/tools/traceRoute, or you can visit
http://www.traceroute.org/ and choose a traceroute service.
Following is our output when we performed the traceroute for "google.com." You can directly write the
domain name (like google.com) or the IP address of that domain to run the Traceroute program.
8|Page
Department of Computer Science & Information Systems
Lab Exercise-6: Once you run the Traceroute from your computer, the output you receive may not be the
same as above. (Note: It is suggested that you try it yourself.)
Now, try to answer the following.
1. Explain the meaning of the first line of the output.
2. The next two lines in the output begin with the TTL, followed by the name of the host or router, its
IP address, and three different time values. What do these time values signify?
3. How can we calculate the per-hop time value?
Repeat the above experiment for the BITS Pilani website and iitd.ac.in and observe the output.
Lab Exercise-7:
Answer the following:
1. Did you observe the character * in a few output lines for any traceroute? If yes, then what does it
mean?
2. Did you see the last hop in your output as the destination you are looking for? If not, then what
could be the reason for this?
*****
9|Page