School of Computing and Information Systems
COMP30023: Computer Systems
Copyright By PowCoder代写 加微信 powcoder
Tutorial Week 9
TCP and UDP – sockets, services and sliding windows
1. What is the difference between the roles of bind, listen, accept and connect when setting
up a TCP socket? In particular
(a) Which ones are used for a process waiting to be contacted (a passive open) and which
are used for contacting one of those processes?
(b) listen and accept are particularly similar. What is the difference between them?
(c) Which sockets in these calls are “half sockets”, identified by a triple (protocol, local IP,
local TCP port), and which are “full sockets”, identified by a 5-tuple (protocol, local
IP, local TCP port, remote IP, remote TCP port)?
(d) Look up and explain the meanings of the return values of these functions.
2. What flexibility would be lost if there was a single call to bind+listen+accept?
3. Recall that UDP is connectionless. Do you think a UDP socket would be identified by a
3-tuple or a 5-tuple? Use your knowledge of TCP sockets to make a guess, and then check
by looking up the Linux manual (man udp) or other source.
4. Leslie designed a new application layer protocol to run on top of TCP for file system man-
agement. The protocol was going to be very efficient: a message would consist of a single
letter command followed by a filename. Two of the commands are ”C” to copy the file from
the server to the client, and ”D” to delete the file. Leslie wrote the client and got Alex
to write the server. Leslie has three files on the server, called ”ate” and ”BlindDate” and
”Blind”, and wants to download them both. However, the command sequence ”CBlindDate”
and ”Cate” gave an error.
(a) What could the error have been?
(b) Could Alex have made any other interpretation of the protocol that would have given
a different error?
5. TCP’s sliding window is responsible for providing both in-order delivery of data and reliable
(a) Imagine you wanted a service that provided reliable delivery but not in-order delivery
without changing the TCP sender. Could you make the sliding window “better” (e.g.,
send fewer packets, reduce the delay in making data available to the application) with
this weaker service guarantee?
(b) Imagine you wanted in-order delivery only, without guaranteeing reliable delivery.
Could you make the sliding window “better” in this case?
(c) If you can also modify the sender in the second case, what is the most “efficient”
implementation, where “efficiency” is measured in packets sent?
6. Consider a data stream consisting of 1000-byte packets, starting with sequence number 0.
Consider a window of 4000 bytes. Imagine that the packets starting at bytes 0, 3000, 6000
are lost, and that the (first) acknolwedgement of the packet starting at byte 4000 was lost.
Assume that the higher layers read the entire buffer contents once the buffer is full. Draw
a sequence like the one on Slide 19, ”TCP Sliding Window” in the lecture notes, with time
going down, and the flow of packets shown by sloping lines. (For exam practice, repeat this
question with losses of different packets, or with a different sized buffer.)
7. Given a TCP packet in buffer buf, write C functions to:
• return 1 if the SYN flag is set and 0 otherwise;
• return a pointer to the first byte of the TCP payload.
Weekly tutorial participation activity
To obtain a weekly tutorial mark (1% of your overall mark for the subject, totalling to 10% over
the semester), please answer the following questions in Canvas Quiz (called Week 9 Tutorial
Activity). You can have multiple attempts but need to submit the quiz by 11:59 pm AEST on
the day of your tutorial. Only answering all questions correctly will give you the weeks mark.
During the tutorial, your tutor will provide you with the access code that will unlock the quiz for
the corresponding week. The access code is valid only for students in this tutorial. As a result,
we expect you to attend your tutorial class as otherwise the access code you obtain in another
tutorial will not work for you.
If you have a valid reason for not being able to attend your tutorial, please fill in the form accessible
via Canvas by Friday 8pm AEDT of the corresponding week. You will be given an access code
during the next business day. The code will not be provided otherwise, hence, please do not email
the subject coordinator or other staff members including your tutor asking for the code. We will
monitor such requests and may limit the number of times an access code is given to the same
studentthroughout the semester to encourage participation and attendance of the tutorials.
1. Assume a TCP sender sends four packets of size 1024 bytes, carrying bytes 0-4095. If the
second packet is lost, what is the content of the Acknowledgement field sent in response to
the third packet? (If you think that no acknowledgement is sent, for example because the
third packet is out of order, then answer -1.)
2. Which is the following is true about TCP’s byte stream model
(a) Representing data as a byte stream means that the application doesn’t need to be
explicitly told things like “this is the third packet”.
(b) Treating all data as a byte stream like TCP does is the only way for “in order delivery”
to make sense.
(c) If the PUSH feature is used, then the application can know where one packet finishes
and the next starts
(d) Reliable transport means that lost packets are retransmitted, and may be sent to the
higher layers after packets that were received correctly the first time
3. Imagine that a process created a socket, but then hung in an infinite loop. The administrator
started a new process without killing the first one. The new process would be unable to run
properly if the first one had got to at least the stage of:
(a) calling socket
(b) calling bind
(c) calling listen
(d) calling accept
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com