辅导案例-CSE 3461

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
CSE 3461 Computer Networking: Homework 2
Shaileshh Bojja Venkatakrishnan
Due: 01/31/20
1 TCP relay
We’ll build a simple TCP relay in this exercise. A relay is a program that relays data between two other programs,
often inspecting the data it is relaying for security and accounting purposes. A TCP relay works as follows. Let’s
assume there are two TCP end points (A and B), connected as follows:
A <----> B
The double-headed arrow indicates that communication can happen in both directions between A and B: A can send
to B and B can send to A. Now, if we introduce a relay R between A and B, this picture is modified to:
A <----> R <----> B
That is, R takes bytes coming in from A and sends them to B and vice versa. This arrangement is at the heart of
proxying, something you may have heard of. In such an arrangement, R would be called a proxy server. Proxy servers
are used for several reasons. For instance, R could require A to authenticate with R before communicating with B. R
could be used to account for how much traffic A sends out of the network. It could also be used to inspect the traffic
between A and B to ensure it doesn’t contain anything malicious.
For this assignment, R’s work is to simply forward the data coming from client A to server B, and vice versa. The
client A first sends an integer to R, which is forwarded by R to B. At B, the binary representation of the integer is
computed and sent back toR. FinallyR relays the received binary representation back to A. You’ll be required to turn
in three programs, one each for A, B, and R. Note that you cannot connect A and B directly; you have to connect
them through the relay R. We have provided starter code for each of the three components here: the client (A), the
server (B), and the relay (R). Please call the relay, client, and server (in that order) as given below.
$: python3 relay.py
$: python3 client.py
$: python3 server.py
Submit the final version of each of the three programs.
2 UDP pinger
In the last homework, we saw how the ping command can be used to measure round-trip-time (RTT) between a host
and a server. In this question, we will build our own version of a simple ping program. While the standard ping
application measures latencies by sending and receiving ICMP messages, we will use simpler UDP datagrams instead,
for measuring the round-trip delay.
The code for the server is given to you in UDP_ping_server.py. You do not need to modify this code. The server
sits in an infinite loop listening for incoming UDP packets. When a packet comes in, the server simply capitalizes
the encapsulated data and sends it back to the client. Since packet loss is rare or even non-existent in typical campus
networks, for this question we have simulated packet loss artificially within the server itself. Instead of responding to
all incoming packets, the server randomly ignores 40% of the packets. Study this code carefully.
Your task is to implement the client program. The client should send 10 pings to the server. Because UDP is an
unreliable protocol, a packet sent from the client to the server may be lost in the network, or vice versa. For this reason,
the client cannot wait indefinitely for a reply to a ping message. You should get the client wait up to one second for
a reply; if no reply is received within one second, your client program should assume that the packet was lost during
transmission across the network. You will need to look up the Python documentation to find out how to set the timeout
value on a datagram socket.
Specifically, your client program should
1. send the ping message using UDP (note: unlike TCP, you do not need to establish a connection first, since UDP
is a connectionless protocol.)
1
2. print the response message from server, if any
3. calculate and print the RTT, in seconds, of each packet, if server responses
4. otherwise, print “Request timed out”
During development, you should run UDP_ping_server.py on your machine, and test your client by sending packets
to localhost (or, 127.0.0.1). After you have fully debugged your code, you can see how your application communicates
across the network with the ping server and ping client running on different machines.
Message format. The ping messages from the client should be formatted in ASCII characters as follows:
Ping
where starts at 1 and progresses to 10 for each successive ping message sent by the client, and
is the time when the client sends the message. You will hand in the complete client code and
screenshots at the client verifying that your ping program works as required.
3 Wireshark lab: DNS
In this question, we will use the nslookup tool to issue name resolution requests to DNS servers. To run nslookup in
Linux/Unix, you just type the nslookup command on the command line. To run it in Windows, open the Command
Prompt and run nslookup on the command line. In its most basic operation, nslookup tool allows the host running
the tool to query any specified DNS server for a DNS record. The queried DNS server can be a root DNS server, a
top-level-domain DNS server, an authoritative DNS server, or an intermediate DNS server. To accomplish this task,
nslookup sends a DNS query to the specified DNS server, receives a DNS reply from that same DNS server, and
displays the result. The general syntax of the command is nslookup -option host-to-find dns-server.
1. Open Wireshark, enter “dns” into the filter, and start a new capture session. On your command line, run
nslookup www.yahoo.com. Stop the capture session.
(a) What is the IP address of the www.yahoo.com web server returned by nslookup? What is the IP address
of your local DNS server?
(b) Locate the DNS query and response messages in Wireshark. How many messages are there? Are they sent
over TCP or UDP? To what IP address is the DNS query sent? What is the destination port for the DNS
query message? What is the source port for the DNS response message? How long did it take for the entire
lookup to complete?
2. Next, run nslookup -type=NS yahoo.com to obtain a list of authoritative name servers for the domain
yahoo.com. This causes nslookup to send a query to your local DNS server asking for the host names of
the authoritative DNS for yahoo.com. The answer first displays the name and address of the local DNS server,
followed by hostnames for the authoritative servers.
Open Wireshark again, and start a new capture session. Issue the command nslookup yahoo.com
, where is the hostname of any authoritative
server, from the list returned by nslookup in the previous step. Stop the capture session.
(a) How many DNS query/response messages do you see in Wireshark? If you answer is different from the
number of messages you observed in part 1, explain why.
(b) What is the destination IP address of the first DNS query message? What server does this IP address
correspond to?
Note: In case you are repeating this experiment, either (i) use a different authoritative server each time, or (ii)
clear your local DNS cache (e.g., ipconfig /flushdns on Windows) before running the experiment.
2
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468