# CS3205: Introduction to Computer Networks Assignment 1 solution

\$30.00

Original Work ?
Category:

5/5 - (1 vote)

## 1. Ping [35 Marks]

Your task is to ping a set of geo-distributed servers, record their ping responses and analyze the round-trip-times (RTT). You are provided with a text file that contains IP addresses of 20 servers, one in each line. Given the IP address you can check the geographical location of the corresponding server manually using web services like, https://www.lookip.net/ or programmatically using APIs like https://ip-api.com/.

a. Write a script to estimate the distance of each of the servers from your location. For IITM campus, you can use (lat: 12.99, lon: 80.23). If you are using Python you can use the following snippet to compute the distance between two locations A (lat1, lon1) and B (lat2, lon2). This distance is known as the “haversine” distance. Note that, in such a case, Euclidean distance will give you an incorrect distance estimate. [7 marks] from math import radians, cos, sin, asin, sqrt def haversine(lon1, lat1, lon2, lat2): “”” Calculate the great circle distance in kilometers between two points on the earth (specified in decimal degrees) “”” # convert decimal degrees to radians lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2]) # haversine formula dlon = lon2 – lon1 dlat = lat2 – lat1 a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2 c = 2 * asin(sqrt(a)) r = 6371 # Radius of earth in kilometers. return c * r

b. Write a script to automatically ping each server for 10 times and record their RTT responses. Your code should output a log file in the following format. , , , <RTT1, RTT2, … RTT10> …. ….. …… …. , , , <RTT1, RTT2, … RTT10> [15 marks]

c. Show a scatter plot for the RTTs and distance values. Do you observe any specific trend? If these packets travelled at the “speed of light”, how slower are the recorded RTT values (e.g., 2X slower, 10X slower or 20X slower etc.) [7 marks]

d. Explore the network utility program traceroute that is used for tracing the path through which a packet moves through the network from the source host to the remote host. The path is represented by a series of hops (routers) that sequentially forward the packets ultimately reaching the end host. Pick the last IP entry in the file and use the traceroute utility. [6 marks]

i. How many hops do you observe? ii. What is the IP address of the router that forwards the packet to a foreign router (leaves India)? iii. Which country does the packet visit next?

## 2. tcpdump [ 25 Marks]

Explore the tcpdump tool (https://www.tcpdump.org/manpages/tcpdump.1.html) that is used to capture network packets as your host system interacts with the network. The tool can save such packets in a pcap file that can be analyzed using the GUIbased tool – “Wireshark”. Record pcap traces using tcpdump for the following events and answer the associated questions. (For the following questions, to avoid confusion, make sure that there are no other network activities going on – for instance close all browser tabs, use private mode browsing etc.)

a. Send four pings to 139.130.4.5. How many packets were exchanged? Using Wireshark, verify that the time elapsed between an individual ping request and response agree with the reported RTT value. [5 marks]

b. Load the URL https://www.w3.org/TR/PNG/iso_8859-1.txt on your web browser (use incognito/private mode to avoid cache issues). Explore [Menu] “Analyze” -> “Apply as filter” and [Menu] “Statistics” -> “I/O Graphs” in Wireshark. [15 marks] i. How many packets are exchanged in the 1st second, 2nd second, … 5th second? ii. Out of that how many are incoming packets and how many are outgoing packets? Hint: Use a filter “ip.src=youripaddress or “ip.dst=serveripaddress” iii. What are the total sizes of the incoming data and outgoing data?

c. Watch a YouTube video, https://www.youtube.com/watch?v=YLslsZuEaNE. Explore [Menu] “Statistics” -> “TCP Stream Graphs” -> “Throughput” in Wireshark to plot client throughput versus time. [5 marks] Submit the pcap files, related statistics, and plots.

## 3. Hamming Codes [40 Marks]

Consider a self-correcting message that contains data bits encoded with the Hamming code. The message is chucked into 40-bit code blocks, where each block encodes 4-characters or 32-bits of data. The rest of the 8 bits include check bits, extended hamming bit (1) and a padding bit (3).

The extended hamming bit in this case is unused and is always set to zero. The trailing bit or the padding bit is also set to 0. 6 check bits are interleaved with the data bits making (2) of size 38 bits. Please refer to the following figure to understand the block structure.

The entire message will be provided as a string of hex digits where each code block comprises of [40/4] i.e., 10 hex digits. Each block may either be error free or have a single bit flipped. Sample test cases: Text: iitm code word: 264BA7D15A Bit flip idx: 22 Num Blocks: 1 Text: iitm code word: 264BA5D15A Bit flip idx: Not flipped Num blocks: 1 Text: absolute code word: 6E0B8BCDDE6E6355D9CA Bit flip idx: 22 28 Num Blocks: 2 Text: absolute code word: 6E0B89CDDE6E6355D1CA Bit flip idx: Not flipped Num blocks: 2

Test coded message: 044B5281EE2E8BCC8942220109C9D2463BA1D0D0061BBDB1486 A839085726203A5B8E044B31D89E44F2B05C9760A6101855E2F 2181D1504EA981ADD80EFF0DAD660A03D995E44E2901DDE82F1 325AFD206D39C81E83EC3A5C9E8662B97B85C Write a program to recover the original message (ASCII character string) from the received coded message and identify the offset of the flipped bit, if any, for each code block. [Language: C/C++ or Python] Acknowledgement: Shibobrota Das (Head TA)