Documente Academic
Documente Profesional
Documente Cultură
CHAPTER
PRACTICE SET
Questions
Q3-1.
Q3-2.
Although this can be done for client processes, it is very inefficient, if not
impossible, for the server processes. When a server process starts running on
the server, its number should be advertised by the server to all possible clients
that need to contact that process.
Q3-3.
Although any port number can be used for the client and server and they can
be the same in this private communication, it is recommended to follow the
division specified by ICANN:
a. The client port number should be chosen from the dynamic range, 49,152
to 65,535.
b. The server port number also should be chosen from the dynamic range,
49,152 to 65,535.
c. It is advisable to choose different port numbers for the server and the client
The organization needs to select a port number from the registered range,
1024 to 49,151, and register that port number with ICANN. If the port number
is already in use, ICANN informs the organization to choose another port
number in this range.
Q3-5.
should be the same (1), which means the protocol is Stop-and-Wait, not
Selective-Repeat.
Q3-6.
2
a. The protocol cannot be the Stop-and-Wait because the size of the send win-
dow should be 1.
b. The protocol can be the Go-Back-N with the send window size of 20 and
larger send window size. We can send more packets before waiting for their
acknowledgment. The disadvantage of using this protocol is that the
receive window size is only 1. The receiver cannot accept and store the outof-order received packets; they will be discarded. Discarding of the out-oforder packets means resending these packets by the sender, resulting in
congestion of the network and reducing the capacity of the pipe. So the
advantage seen by a larger send window may disappear by filling the network with resent packets.
b. The advantage of using the Selective-Repeat protocol is that the receive
window can be much larger than 1. This allows the receive window to store
the out-of-order packets and avoids resending them to congest the network.
On the other, the send window size of this protocol is half of the Go-BackN, which means that we can send fewer packets before waiting for the
acknowledgment.
c. If the bandwidth-delay product of the network is large, the reliability is
good, and the delay is low, we should choose the Go-Back-N protocol to
use more of the network capacity. On the other hand, if the bandwidthdelay product is small, or the network is not very reliable, or the network
creates long delays, we need to use Selective-Repeat.
Q3-8.
Sequence numbers use modulo 2m arithmetic. This means that if a packet has
the sequence number x, 2m packets need to be passed to see the same sequence
number if each packet uses only one sequence number (not in TCP, where the
sequence number defines the number of the first byte in the packet).
Q3-9.
The networks need to be carefully designed to make the time between the two
wraparounds as long as possible. For example, in a protocol that uses the
sequence number field of size 3 (m 3), every 2m 8 packets have the same
sequence number. If the previous packet with sequence number x (or its accidentally created duplicate) is still wandering in the network arrives at the destination, the receiver may confuse this with the expected new packet, also with
sequence number x.
Q3-10.
Q3-11.
Q3-12.
If a transport layer protocol such as TCP uses a timer and resends some packets that have not arrived at the destination on time, it may happen that both the
original and the resent packet arrive at the destination.
Q3-13.
The rest of the packets (2m 2) are supposed to be in transit, filling the pipe.
The size of the receive window is chosen to be 1 to accept only one packet, the
one expected, and not out-of order packets. The receiver cannot be overwhelmed because it holds only one packet in its window. When the only
packet in the window is consumed by the upper-layer protocol, the receive
window slides to make it possible to receive the next packet in transit. If any
packet in transit arrives before the window slides, it is discarded.
Q3-14.
There can be several packets still in transit. The size of the receive window is
chosen to be the same as the size of the send window to accommodate out-oforder packets until a set of packets all in order arrives. The protocol does not
want to deliver the out-of-order packets to the application-layer protocol.
Q3-15.
The protocol field of the datagram (see Figures 4.24 and 4.25 in Chapter 4)
defines the transport-layer protocol that should receive the transport-layer
packet. If the value is 06, the protocol is TCP; if the value is 17, the protocol is
UDP.
Q3-16.
The following shows the pair of socket addresses; they are used in reverse
order in each direction:
Source
From client to server
122.45.12.7
200.112.45.90
Destination
51000
161
200.112.45.90
122.45.12.7
161
51000
Q3-17.
UDP is preferred because each user datagram can be used for each chunk of
data. However, a better solution is the new transport protocol, SCTP, discussed in Chapter 8.
Q3-18.
UDP or TCP, as defined in the TCP/IP suite, are two protocols (specifications), not pieces of software. Their software implementations can be changed
to accommodate the services required by different APIs.
Q3-19.
The answer is positive. There is nothing in the UDP or TCP protocol that
requires the use of the IP protocol. A UDP user datagram or a TCP segment
can be encapsulated in an Ethernet frame. However, the protocol field of the
Ethernet needs to define which protocol is directly used in this case.
Q3-20.
The answer is positive. UDP and TCP are independent protocols that do not to
be associated with the TCP/IP protocol suite. If another suite can create lower
layers that provide services to UDP/TCP and upper layers that use the services
of UDP/TCP, either of these protocols can be used as the end-to-end protocol
in these suites.
Q3-21.
There are two parties involved in a two-way communication. TCP allows each
party to stop sending while the other party is still sending data. This means we
need at least two FIN segments (or data segments in which the FIN bit is set).
Since each FIN segment should be acknowledged, we normally need four segments for connection termination. Sometimes the second FIN segment can be
combined with the ACK segment to reduce the number of segments to three.
Q3-22.
The SYN segment cannot carry data. The SYN + ACK segment cannot carry
data either, but this segment is actually the SYN segment with an additional
ACK bit. Although some people think that the FIN segment may not carry
data, it actually can. The client or the server can send the last bytes of data in a
segment and set the FIN bit.
Q3-23.
The way the sequence number is determined depends on whether the segment
is the first or not.
a. The sequence number of the first segment is the value of ISN, which is nor-
Q3-25.
a. A SYN segment consumes one sequence number.
b. An ACK segment does not consume any sequence numbers.
c. A SYN + ACK segment consumes one sequence number because it is a
SYN segment.
d. A data segment consumes n sequence numbers, where n is the number of
We cannot say. The size of the window field makes the size of the window 216
bytes, but the sequence number is 232. The size of the window is definitely
much smaller (actually 2 16 times smaller) than half of the range of the
sequence numbers. The requirement of each protocol, Go-Back-N and Selective-Repeat, is satisfied. However, as we mentioned in the text, TCP is closer
to Selective-Repeat in other aspects.
Q3-28.
The window size field of the TCP header is only 16 bits. A number with 16
bits can define a decimal number between 0 and 65,535.
Q3-29.
a. The maximum size of the TCP header is 60 bytes (20 bytes of header and a
A SYN segment opens the connection in only one direction. For a communication using TCP, two SYN segments are needed, one for each direction.
Q3-31.
A FIN segment closes the connection in only one direction. The party that
issues a FIN segment cannot send data to the other party, but needs to
acknowledge the data received from the other party. The other party can still
send data and acknowledgments. To completely close the connection, two FIN
segments are required, one in each direction. Of course, the FIN and ACK
segments can always be combined.
Q3-32.
A segment carrying an RST flag can close the communication in both directions immediately. The segment carrying an RST flag should not even be
acknowledged.
Q3-33.
For example, the SYN and the RST flags cannot be set in a segment. One of
them requests the starting of a connection; the other requests that the connection be aborted. Another example is the combination of SYN and FIN.
Q3-34.
The server needs to immediately send a segment with the RST flag set to show
that the connection cannot be established. As we see in Chapter 4, if the network layer knows about the availability, it can also send an ICMP packet.
Q3-35.
Q3-36.
A connection identifier in this case needs to include the identifier for two end
points. In this case, a unique identifier for each end is defined by a socket
address. The connection identifier should therefore be a pair of socket
addresses: the source socket address and the destination socket address.
Q3-37.
Q3-38.
In this case, Bob has made a passive open connection when he publicly
announced his telephone number or privately gave her telephone number to
Alice. Alice makes an active open when she dials Bobs telephone number.
Q3-39.
The sender window in TCP is originally the same size as the receiver window,
but as the congestion builds up in the network, it can become smaller than the
receiver window. It can never become larger than the receiver window. The
size of the sender window is the smaller of the window size either dictated by
the congestion or determined by the receiver.
Q3-40.
Q3-41.
The acknowledgment identifies the sequence number of the next segment that
is expected to arrive.
Q3-43.
The use of checksum in UDP is optional. If the sender does not use the checksum, it fills the checksum field with sixteen 0s. The use of the checksum in
TCP, on the other hand, is mandatory. The sender should calculate the checksum; otherwise, the checksum calculation at the receiver fails and the segment
is dropped.
Q3-44.
The TCP server has received a segment whose sequence number is higher
than expected. The TCP server should store the out-of-order segment and send
an ACK with acknowledgment number 2001 to lead to the generation of a
duplicate acknowledgment and possibly the fast retransmission of the missing
segment (Rule 4 in ACK generation).
Q3-45.
The received segment is a duplicate. The TCP client needs to discard the segment and immediately send an ACK with acknowledgment number 2001.
This reaction helps the server to update itself if the previous ACK with
acknowledgment number 2001 is somehow lost (Rule 6 in ACK generation).
Q3-46.
The server needs to store the bytes in the buffer and sends an ACK with
sequence number 2401. This reaction helps the client to purge the corresponding segment from its queue (Rule 5 in ACK generation).
Q3-47.
The server needs to store the new bytes and immediately send an ACK with
acknowledgment number 2901. This reaction prevents the retransmission of
the previous segment by the client (Rule 3 in ACK generation).
Q3-48.
The client needs to store the new bytes, but delay the acknowledgment until
receiving the next segment or wait a period of 500 ms. This reduces the number of ACKs in the network. (Rule 2 in ACK generation).
Q3-49.
The server needs to store the new bytes, but send a segment with sequence
number 4001 and acknowledgment number 8001 (piggybacking). This saves
bandwidth because the data needs to go in the other direction, and it is better
to acknowledge the received bytes in the same packet (Rule 1 in ACK generation).
Q3-50.
Figures 3.59 and 3.60 define the FSMs for unidirectional communication. The
first rule of ACK generation is for bidirectional communication. It is the interaction between the sender and receiver TCP at each end. The rule should be
implemented in the software.
Q3-51.
The six rules we mentioned for ACK generation are related to flow and error
control and are applicable during the data transmission phase, not during the
connection establishment phase. In this case, a SYN needs to be acknowledged by a (SYN + ACK) segment if the server accepts the connection or by
an RST segment otherwise.
Q3-52.
The six rules we mentioned for ACK generation are related to flow and error
control and are applicable during the data transmission phase, not the connection establishment phase. In this case, if the client accepts the connection, it
needs to send an ACK segment immediately or a data segment that acknowledges the SYN + ACK segment. Otherwise, it needs to send an RST segment
and abort the connection.
Q3-53.
The six rules we mentioned for ACK generation are related to flow and error
control and are applicable during the data transmission phase, not the connection termination phase. In this case, the FIN segment should be acknowledged
immediately if there is no data to send or acknowledged in the next data segment.
Problems
P3-1.
P3-2.
Since port numbers have local jurisdiction and can be repeated, the division
distinguishes between client processes and server processes to avoid confusion when a host runs client and server processes at the same time. For example, assume host A is running a client process with the port number x, which
has sent out a request and is waiting for a response from the corresponding
server. Host B sends a request to a server process with the port number x,
which is received by host A. Host A erroneously passes the request to the client process with port number x, assuming that this is the response that the client process is waiting for. If client and server were using different port
numbers, x and y for example, the request received by host A would be
dropped because no server with port number y was running. ICANN has also
divided the server port numbers into two groups. The well-known port numbers are recognized through the whole Internet society; the registered port
numbers are those that do not have a universal jurisdiction yet.
P3-3.
The sequence number of any packet can be found using the following relation:
seqNo = (starting segNo + packet number 1) mod 2m
in which m is the number of bits used to define the sequence number. The
sequence number in this case is
seqNo (0 100 1) mod 25 99 mod 32 3
P3-4.
sequence number.
b. In the Go-Back-N protocol with m 8, every 2m = 256 packets have the
9
c. In the Selective-Repeat protocol with m 8, every 2m = 256 packets have
Go-Back-N:
P3-6.
Event 1
Action 1
Start
Event 2
None
Event 3
Action 2
B
Event 4
None
C
Dead state
P3-7.
The following shows the states and events. The sender needs two states: ready
and blocking. The receiver also needs these two states. To send a packet, the
sender should be in the ready state and receives data from the application
layer. The sender cannot send a packet when it is in the blocking state. The
receiver accepts a packet from the sender when it is in the ready state. It cannot accept a packet when it is in the blocking state. When the receiver
becomes ready, it sends an ACK packet and moves to the ready state.
A packet arrived.
Inform the application layer.
Blocking
Ready
Start
An ACK arrived.
Do nothing.
Sender
P3-8.
Blocking
Ready
Receiver
The following shows the states and events. The sender needs two states: ready
and blocking. The receiver also needs two states. To send a packet, the sender
should be in the ready state and receives data from the application layer. The
sender cannot send a packet when it is in the blocking state. When in the
blocking state, if the sender gets a NAK, it resends the packet and remains in
10
the blocking state. When the sender receives an ACK, it moves to the ready
state and waits until data comes from the application layer. When the receiver
is in the ready state, it can accept a packet. If the packet is corrupted, it sends a
NAK and remains in that state. If the packet is not corrupted, it informs the
application layer and waits until the packet is consumed. At this moment, it
sends an ACK and moves to the ready state.
Sender
A NAK arrived.
Resend the packet.
Blocking
Ready
Start
An ACK arrived.
Do nothing.
A noncorrupted packet arrived.
Inform the application layer.
Start
A corrupted packet arrived.
Receiver
Blocking
Ready
P3-9.
The following shows the case. It happens when an ACK is delayed and the
time-out occurs. The sender resends the packet that is already acknowledged
by the receiver. The receiver discards the duplicate packet, but resends the
previous ACK to inform the sender that there is a delay in the network.
Sender
Transport
layer
Start
Packe
t0
Time-out
Packe
t0
Transport
layer
ACK
Stop
ACK
Discards
(it is duplicate)
Duplicate
ACKs received
(maybe time-out
occured too soon)
Time
Receiver
Time
11
Receiving a duplicate ACK may alert the sender to increase the time-out to
prevent resending the packets prematurely. Note that if the receiver ignores
the duplicate packet and does not send the second ACK, the sender believes
that the first packet is lost and the first ACK is actually acknowledging the
packet that is resent. Duplicate ACKs give the clue about what is happening.
P3-10.
Two changes need to be made in Figure 3.21, one in the FSM for the sender
and another one in the FSM for the receiver. In the senders FSM, we change
the time-out event. In the receivers FSM, we change the event when a corrupted packet arrives. Both changes are shown in the following figure. The
figure shows only changes, the rest of the Figure 3.21 remain the same. An
example follows the changes.
Time-out occured or a
NAK with nakNo = S arrived.
Resend the packet in the window.
Restart the timer.
Ready
Blocking
Start
Sender
Receiver
Transport
layer
Transport
layer
Packet 0
ACK 1
Stop
Start
Packet 1
Corrupted; discard
NAK 1
Stop
Start
Packet 1
ACK 0
Stop
Time
P3-11.
Time
The figure on the next page shows the outline. Note that since the simple protocol provides no error control, if a packet is lost, the receiving process is
responsible for finding a solution. The transport layer is not even aware that
this has happened. The packets may also be delivered out of order to the
receiving process. The responsibility again is on the receiving process to reorder the packets.
12
Sender
Receiver
Transport
layer
Transport
layer
Req
Packet 0
Req
Packet 1
pArr
Req
Packet 2
pArr
Req
Packe
t3
Packet 4
Req
Lost
pArr
pArr
Time
Time
P3-12.
Start
Req
Stop
Start
Start
Timeout;
restart
Stop
Req
T-Out
Packet 0 (1
st packet)
Packet 1 (2
nd
0 1 0 1 0 1
packet)
pArr
ACK 0
aArr
0 1 0 1 0 1
0 1 0 1 0 1
Pa
cke
t
Pac
ket
0 1 0 1 0 1
0 1 0 1 0 1
pArr
ACK 1
aArr
0 1 0 1 0 1
0 1 0 1 0 1
Stop
Receiver
Transport
layer
0 1 0 1 0 1
0 1 0 1 0 1
Req
Sender
Transport
layer
0(
thi
rd
pac
ket
)
0 (t
hi
Res rd pac
ket)
ent
aArr
ACK 1
pArr
pArr
ACK is discarded
Time
ACK 1
Time
0 1 0 1 0 1
Packet 0
discarded
(a duplicate)
13
P3-13.
Sender
Transport
layer
Start
Req
Receiver
Transport
layer
Packet 0
0 1 0 1 0 1
pArr
ACK 1
Timeout;
restart
T-Out
0 1 0 1 0 1
Stop
Start
Packet 0 (res
ent)
0 1 0 1 0 1
Req
ACK 1
aArr
0 1 0 1 0 1
pArr Packet 0
discarded
(a duplicate)
Packet 1
0 1 0 1 0 1
Lost
Timeout;
restart
T-Out
Packet 1 (resent)
0 1 0 1 0 1
Stop
0 1 0 1 0 1
pArr
ACK 0
aArr
Time
P3-14.
0 1 0 1 0 1
Time
Events:
Req: Request from process
pArr: Packet arrival
aArr: ACK arrival
T-Out: Time out occurs
Start
Stop
Sf
Sn
Initial 0 1 2 3 4 5 6
Sf
Sn
Req
0 1 2 3 4 5 6
Req
Sf
Sn
Req
Sf
0 1 2 3 4 5 6
Sn
Req
Sf
Start
Sf
Sn
3 4 5 6 7 0 1
Sn
3 4 5 6 7 0 1
Sn
Stop
4 5 6 7 0 1 2
Sf
Sn
Start
4 5 6 7 0 1 2
T-Out
Sf
Sf
Stop
5 6 7 0 1 2 3
Rn
Packet 0
Rn
pArr
1
Packet 1
Rn
pArr
2
Packet 2
Rn
pArr
3
ACK 3
aArr
Packet 3
pArr
ACK 4
aArr
Rn
4
Packet 4
Lost
Sn
4 5 6 7 0 1 2
Sn
Receiver
Transport
layer
Initial 0
0 1 2 3 4 5 6
Sf
Time-out:
restart
Sender
Transport
layer
Packet 4
Rn
pArr
aArr
Time
ACK 5
Time
14
P3-15.
Events:
Req: Request from process
pArr: Packet arrival
Sender
aArr: ACK arrival
Transport
T-Out: time out
layer
Sf Sn
Initial 0 1 2 3 4 5 6 7 0
Start
Stop
Start
Stop
Start
Sf
Req
Packet 0
Req
Sf
Sn
0 1 2 3 4 5 6 7 0
pArr
Data delivered
to application
pArr
Rn
0 1 2 3 4 5 6 7 0
Data delivered
to application
pArr
ACK 2
Sf Sn
aArr
0 1 2 3 4 5 6 7 0
Rn
0 1 2 3 4 5 6 7 0
Rn
Packet 2
0 1 2 3 4 5 6 7 0
Data delivered
to application
Req
Sf
Sn
0 1 2 3 4 5 6 7 0
Pa
Req
Sf
Sn
0 1 2 3 4 5 6 7 0
Packet 4
ck
et
3
ACK 4
Restart
Sn
Sf
aArr
0 1 2 3 4 5 6 7 0
Sf Sn
aArr
0 1 2 3 4 5 6 7 0
ACK 3
Stop
Time
P3-16.
Rn
Initial 0 1 2 3 4 5 6 7 0
ACK 0
Sf Sn
aArr
0 1 2 3 4 5 6 7 0
Sf
Sn
Req
Packet 1
0 1 2 3 4 5 6 7 0
ACK 1
Sf Sn
aArr
0 1 2 3 4 5 6 7 0
Stop
Start
Sn
0 1 2 3 4 5 6 7 0
Receiver
Transport
layer
Rn
pArr
0 1 2 3 4 5 6 7 0
Rn
pArr
Time
0 1 2 3 4 5 6 7 0
Data delivered
to application
with ackNo = 1.
d. Discard the packet, and send an ACK with ackNo = 1.
P3-17.
15
e. Sf = 18 and Sn = 21. Next state = ready.
f. Rn = 17. Action: message is delivered and an ACK with ackNo = 17 is sent.
P3-18.
In each case we first define the bandwidth-delay product (BDP) in bits and
then find it in the number of packets:
a. BDP 1 Mbps 20 ms 20,000 bits 20 packets
b. BDP 10 Mbps 20 ms 200,000 bits 100 packets
c. BDP 1 Gbps 4 ms 4,000,000 bits 400 packets
P3-20.
We first calculate the average round-trip time (RTT) and the number of packets in the pipe before finding the sizes of the windows, the value of m, and the
time-out value.
a. Average RTT 2 (10,000 Km) (2 108) = 100 ms.
b. The bandwidth-delay product 100 Mbps 100 ms 10,000,000 bits.
c. The bandwidth-delay product 10,000,000 bits 100,000 bits 100 pack-
ets.
d. The maximum send window size should be 100 to allow not more than 100
We first calculate the average round-trip time (RTT) and the number of packets in the pipe before finding the sizes of the windows, the value of m, and the
time-out value.
a. Average RTT 2 (5,000 Km) (2 108) = 50 ms.
b. The bandwidth-delay product 1 Gbps 50 ms 50,000,000 bits.
16
c. The bandwidth-delay product 50,000,000 bits 50,000 bits 1000 pack-
ets.
d. The maximum send window size should be 1000 to allow not more than
order data packets, acknowledgments are cumulative, which means that the
receiver does not have to acknowledge any single data packet received.
Several packets can be acknowledged at a time, saving in the number of
ACK packets. In this system, a single acknowledgment number defines the
next packet that the receiver expects to receive to allow the sender to purge
the whole range of packets whose sequence number is less than the
acknowledgment number. For example, if the acknowledgment number is
ackNo 27, the sender can purge all of the outstanding packets whose
sequence number is less than 27. The acknowledgment number clearly
defines the first slot in the sender window after sliding.
b. In the Selective-Repeat protocol, the receiver can accept out-of-order pack-
ets and store them until the missing packets arrive. In this protocol, the
acknowledgment number cannot be cumulative, because several packets
before the one received may not have been received yet. Nor cant the
acknowledgment define the next packet expected, because the next packet
may be a packet with sequence number before or after the one received.
The acknowledgment number exactly defines the sequence number of the
packet received.
P3-23.
Sf
62
Sn
63
64
65
Sender
66
Rn
67
68
64
Receiver
a. If the receiver expects a packet with sequence number 64 and packets with
17
b. If the sender expects the acknowledgment for packet 62, but the value of Rn
64, it means that the ACK packets with acknowledgment numbers 62 and
63 are in transit from the receiver to the sender.
P3-24.
Sf
62
Sn
63
64
65
66
67
Rn
68
69
64
Sender window
65
66
67
68
69
70
71
Receive window
a. The sender has sent packets 62 to 66; the receiver is expecting only packet
64 in this set (packets 62 and 63 have already been received and acknowledged). This means there is only one pending packet, packet 64.
b. The receiver has sent ACKs 62, 63, 65 and 66, but the sender has received
only ACK 65. This means ACKs 62, 63, and 66 are pending.
P3-25.
a. The minimum size is 8 bytes (header without payload).
b. Although the theoretical maximum size is 65,535 bytes, since a user data-
gram needs to be encapsulated in a single IP datagram (UDP is a connectionless protocol) and the maximum payload of an IP datagram is 65,515
bytes (see Figure 4.24 in Chapter 4), we should say the maximum size of a
UDP datagram is only 65,515 bytes.
c. The minimum size of the application-layer payload is zero bytes.
d. The maximum size of the application-layer payload is 65,507 bytes
(65,515 8).
P3-26.
The data is 16 bytes; the total UDP user datagram size is 16 8 24 bytes.
Efficiency (16) / (24) 0.666 66.6 percent.
P3-27.
a. The source port number is the first 16 bits or (0045)16 = 69.
b. The destination port number is the second 16 bits (DF00)16 = 57,088.
c. The total length of the datagram is the third 16 bits (0058)16 = 88 bytes.
d. The length of the data is 88 8 = 80 bytes.
e. The message is from a server with a small (well-known) port number to a
18
g. The sender has not calculated the checksum for this packet because the
UDP TCP
Purpose
Checksum
Total Length
Sequence Number
Acknowledgment Number
Header Length
Control Bits
Urgent Pointer
Note that the only field that exists in UDP but is missing in TCP is the total
length field. The designer of TCP did not feel that this field was needed
because the size of the TCP segment can be determined from the size of the IP
datagram that carries it.
P3-29.
The number (0111)2 in decimal is 7. The total length of the header is then (7
4) = 28. The base header is 20 bytes. The segment has 28 20 = 8 bytes of
options.
P3-30.
a. None of the control bits are set. The segment is part of a data transmission
tion.
c. The ACK and the FIN bits are set. This is a FIN + ACK segment.
d. The RST bit is set. This is a reset segment (request for resetting).
e. The SYN bit is set. This is a SYN segment.
f. The ACK and the SYN bits are set. This is a SYN + ACK segment.
19
P3-31.
The following are eight out of 64 possible combinations that are normally
used:
000000
110000
010000
000010
A SYN segment
011000
000001
A FIN segment
010010
000100
An RST segment
P3-32.
a. The source port number is (E293)16 or 58,003 in decimal.
b. The destination port number is (0017)16 or 23 in decimal.
c. The sequence number is (00000001)16 or 1 in decimal.
d. The acknowledgment number is (00000000)16 or 0 in decimal.
e. The HLEN = 5. The header is 5 4 = 20 bytes long.
f. The combination of the reserved field and the control field is (002)16 or
(000000000010)2. The rightmost 6 bits are 000010, which means only the
SYN bit is set. This is the SYN segment used for connection establishment.
g. The window size field is (07FF)16 or 2047 in decimal. The window size is
2047 bytes.
P3-33.
Even with three letters exchanged between Alice and Bob, there is no guarantee that both know where and when they should meet. However, more and
more communication raises the probability that both parties know about the
meeting. Experts believe that three communications between the two parties
are adequate assurance that they can come to the meeting. Let us go through
each event:
a. Alice cannot go to the meeting because she is not sure that Bob has
received the letter. The letter may have been lost and Bob knows nothing
about the meeting. This is similar to sending a SYN segment from the client to the server. The client (Alice) sets the scenario.
20
b. Bob cannot go to the meeting because he does know if Alice has received
his confirmation. This is similar to the SYN + ACK. The server (Bob) confirms Alices request.
c. Alice cannot go to the meeting with total assurance that Bob will be there
because she does not know if Bob has received her letter and knows that
she knows that the meeting is confirmed. This is similar to the last ACK.
The client (Alice) confirms that she has received the confirmation from the
server (Bob).
P3-34.
P3-35.
a. The sequence number in the SYN segment is 2171. The SYN segment con-
sumes one sequence number; the next sequence number to be used is 2172.
b. The sequence number in the data segment is 2172 (which represents the
sequence number of the first byte). The bytes in the packets are numbered
2172 to 3171. Note that the client sends the data with the second packet (no
separate ACK segment).
c. The sequence number in the FIN segment is 3172. Note that the FIN seg-
P3-36.
The window size is min(3000, 5000) = 3000. Since 2000 bytes is already sent,
only 3000 2000 = 1000 more bytes can be sent.
P3-37.
The data section is only 16 bytes. The TCP header is 20 bytes. The efficiency
is
(16) (16 20) 0.444 44.4%
P3-38.
The largest number in the sequence number field is 232 1. If we start at 7000,
it takes [(232 1) 7000] / 1,000,000 = 4295 seconds or almost 72 minutes.
21
P3-39.
The following shows the three segments exchanged during the connection
establishment:
Client
Server
SYN Segment
59,100
80
14,534
785
0 00 0 10
Checksum
ACK Segment
80
59,100
3
5
Time
P3-40.
14534
14,535
785
21,733
0 10 0 00
Checksum
4000
Time
The following shows the segments exchanged during the data-transfer phase:
Server
Client
Data Segment
80
59,100
1
14,535
785
21,733
0 10 0 0 0
Checksum
4000
5
Time
21,733
785
14,635
0 10 0 0 0
Checksum
59,100
4900
Time
22
P3-41.
The following shows the connection termination phase. We assume a threehandshake connection termination because the server has no more data to
send.
Client
Server
FIN + ACK Segment
59,100
80
14,635
785
22,933
0
01 0 0 01
Checksum
ACK Segment
59,100
3
5
Time
80
14534
14,636
785
22,934
0 10 0 00
Checksum
0
Time
P3-42.
P3-43.
CLOSED
CLOSED
Passive open / _
Time-out /
close / FIN
LAST-ACK
LAST-ACK
LISTEN
LISTEN
SNY-SENT
SNY-SENT
FIN-WAIT-1
FIN-WAIT-1
ACK /
TIME-WAIT
TIME-WAIT
CLOSECLOSE-WAIT
WAIT
ACK /
ESTABLISHED
ESTABLISHED
Client States
ESTABLISHED
ESTABLISHED
Server States
FIN /
23
Note that the FIN-WAIT-2 state is not used in this case. Note also that there
are changes in the server side that are not shown in Figure 3.51 (in the text)
because this is somewhat of an implementation issue. In this case, the server
sends FIN + ACK before going to the LAST-ACK state.
P3-44.
If Bob, the server, always uses a different ISN (Initial Sequence Number), Eve
cannot create such a connection easily. Let us go through the three hand-shake
events:
a. Eve sends a SYN segment using Alices IP address as the source IP
address.
b. Bob (the server) sends the SYN + ACK segment to Alice (not to Eve)
Bob, the server, sends the response to Alices IP address; the destination IP
address is the source IP address in the request message. Since Alice has not
requested this response, the response is dropped and lost. Eve can receive the
response only if she can intercept the message.
P3-46.
The probability of this mistake is very low. In TCP, an ISN (Initial Sequence
Number) for a connection always has a high probability of being unique.
When Alice sends the new SYN, its sequence number is different from the
sequence number of the wandering SYN. Assume the sequence number of the
old SYN is x and the sequence number of the new SYN is y. The SYN + ACK
segment sent by Bob in response to the old SYN has the acknowledgment
number (x + 1); Alice is expecting the acknowledgment number of (y + 1) for
the new SYN. Alice immediately sends an RST (reset) segment and aborts the
connection. Alice then needs to start a new connection.
P3-47.
The probability of this mistake is very low because the initial sequence number (ISN) has a high probability of being unique. Assume Alice and Bob were
using ISNs x and y, respectively in the previous connection, but z and t in this
connection. The old ACK segment (third segment) has the acknowledgment
number (y + 1); the new ACK segment should have the acknowledgment (t +
1). Bobs server immediately recognizes the problem and sends an RST segment to abort the connection. Alice then needs to start a new connection.
24
The sending TCP allocates a fixed-size buffer, although the size of the sender
window is changed continuously, controlled by the receiver window and the
congestion window. The buffer is filled by the bytes written by the application
and emptied by the bytes acknowledged by the sender. When the buffer is not
full, TCP accepts data from the application; when the buffer is full, TCP
rejects data from the application program. The following shows a simple
example of how the buffer status will change. We have shown both linear and
circular representation of the buffer. The latter better shows the position of the
data written by the application.
Note:
Red arrow shows
where the byte is
written to the buffer
0% full
25% full
50% full
25% full
100% full
50% full
Flow control
feedback
P3-48.
25
The receiving TCP allocates a fixed-size buffer (the same size as the buffer
allocated by the sending site). The application program at the receiver site
pulls data from the buffer, which means there is no flow control from the
receiving TCP toward the application program. Data received from the sending TCP are stored in the buffer until they are consumed by the application
program. The part of the buffer that is still empty is advertised as the value of
rwnd to the sending TCP (flow control). The following shows a simple example how the buffer status will change. We have shown both linear and circular
representation of the buffer. The latter better shows the position of the data
read by the application.
Note:
Red arrow shows
where the next byte
is read from the buffer
(rwnd = 0)
100% full
P3-49.
26
P3-50.
The following shows the time line for each segment. Note that a mild version
of the silly window syndrome actually exists here. We have six segments of
which two each carry 10 bytes of data and the other four each carry 20 bytes
of data. No segment carries the MSS. The reason is that acknowledgments are
not delayed by the receiver: each segment is acknowledged immediately.
Client
Server
TCP
Process
t: 10 ms
t: 20 ms
Bytes 01-10
Bytes 21-30
t: 40 ms
Bytes 31-40
t: 50 ms
Bytes 41-50
t: 60 ms
Bytes 51-60
t: 80 ms
t: 90 ms
Process
Bytes 0
1-10
Bytes 11-20
t: 30 ms
t: 70 ms
TCP
Bytes 01-10
ACK
Bytes 1
1-30
Bytes 11-30
t: 20 ms
t: 40 ms
ACK
Bytes 3
1-50
Bytes 31-50
ACK
Bytes 61-70
Bytes 5
1-70
Bytes 71-80
t: 60 ms
Bytes 51-70
t: 80 ms
Bytes 71-90
t: 100 ms
ACK
Bytes 81-90
Bytes 7
1-90
Bytes 9
1-100
Bytes 91-100
ACK
Time
Time
Time
Time
t: 120 ms
27
P3-51.
The following shows the time line for each segment. Note that the situation is
improved from the previous situation. Both of Nagles rules are applied. Some
segments are sent with the maximum segment size; others in response to an
ACK. The improvement is because the receiver delays acknowledgments.
Client
Server
TCP
Process
Bytes 01-10
t: 10 ms
TCP
Bytes 0
1-10
Bytes 01-10
Bytes 11-20
t: 20 ms
t: 30 ms
Bytes 21-30
t: 40 ms
Bytes 31-40
t: 50 ms
Bytes 41-50
t: 60 ms
Bytes 51-60
Bytes 61-70
t: 70 ms
Process
Bytes 1
1-40 (M
SS)
t: 20 ms
Bytes 11-40
ACK
Bytes 4
1-6
t: 50 ms
Bytes 41-60
t: 70 ms
Bytes 71-80
t: 80 ms
t: 90 ms
Bytes 81-90
t: 100 ms
Bytes 91-100
Bytes 6
1-90 (M
SS)
Bytes 61-90
ACK
5
t: 100 ms
Bytes 9
1-100
Bytes 91-100
t: 110 ms
60 ms
ACK
Time
P3-52.
Time
Time
Time
We separately show which aspects are similar to Go-Back-N and which ones
are similar to Selective-Repeat.
a. TCP is similar to the Go-Back-N protocol when we consider the cumula-
can store the out-of-order packets received; they are not discarded, but not
delivered out of order to the application layer either. TCP is also similar to
the Selective-Repeat protocol in that the size of the send and receive windows is the same if we ignore the effect of congestion and the congestion
window.
28
P3-53.
that the bytes are received out of order. TCP stores the bytes in the receive
window, but it sends an ACK with the acknowledgment number equal to
Rn to help fast retransmission of the missing bytes. This is a duplicate ACK
because the receiver has already sent an ACK with the acknowledgment
number equal to Rn. The issuing of duplicate ACKs is only a clue to the
sender that some packets have arrived out of order. If three duplicate ACKs
arrive, the sender deploys the fast retransmission and resends the packet
with the sequence number defined by the acknowledgment.
b. When a duplicate segment arrives, the receiver TCP drops the packet and
sends an ACK that defines the segment expected. This is also a duplicate
ACK that gives a clue to the sender that its timer may have timed out prematurely. One might ask how the receiver could know whether the duplicate ACK is for an out-of-order segment or a duplicate segment. To trigger
a fast retransmission, the sender needs to receive three duplicate ACKs
(four ACKs with the same sequence number); a duplicate ACK per se does
not trigger a fast retransmission.
P3-54.
An 8-byte option can show a range of bytes. The first 4 bytes can show the
beginning of the range; the second 4 bytes can show the end of the range.
Combined with the acknowledgment number, they can show that the range is
a duplicate or out of order. If the second sequence number in the option is the
same as the acknowledgment number, the block is a duplicate block. If the
second sequence number in the option is different from the acknowledgment
number, the block is an out-of-order block. The following shows the two
cases:
Header
NAK
Option
ackNo = 1001
ackNo = 801
900
900
1001
1001
P3-55.
The data from the client process, 5400 bytes, can be divided into six chunks
(five chunks of 980 bytes and one chunk of 500 bytes). After adding a header
of 20 bytes, we have six segments (five segments of 1000 bytes and one segment of 520 bytes). The segments and the ACKs are created according to the
rule we mentioned in the text. The size of the congestion window is increased
29
by one MSS for each ACK received. If we follow the growth of the cwnd, we
can see the pattern is exponential, but the base is decreased from 2 to 1.5 (20 =
1, 21 = 2, 1.752 3, 1.603 4, and 1.54 5).
Segment
ACK
Client
Server
500
ms
cwnd = 2000 bytes
500
ms
P3-56.
Time
The following shows the events and the values. The units of windows and
ssthresh are MSS. We use abbreviations for states such as slow start (SS) and
congestion avoidance (CA). The leftmost state shows the current state, the
rightmost one shows the new state.
State
Event
ssthresh
cwnd
State
SS
ACK arrived
4+15
SS
SS
ACK arrived
5+16
CA
CA
ACK arrived
6 + 1/6 6.17
CA
CA
ACK arrived
CA
CA
Time-out
SS
SS
ACK arrived
112
SS
SS
ACK arrived
213
CA
CA
ACK arrived
3 1/3 3.33
CA
30
P3-57.
The following shows the events and the values. The units of windows and
ssthresh are MSS. We use abbreviations for states such as slow start (SS), congestion avoidance (CA), and fast recovery (FR). The leftmost state shows the
current state, the rightmost one shows the new state.
State
P3-58.
Event
ssthresh
cwnd
State
SS
ACK arrived
516
SS
SS
ACK arrived
617
SS
SS
ACK arrived
718
CA
CA
3 dup-ACKs
437
FR
FR
dup-ACK
7 1/7 7.14
FR
FR
dup-ACK
FR
FR
ACK arrived
CA
CA
ACK arrived
4 1/4 4.25
CA
CA
Time-out
SS
2.12
The throughput is the average of window sizes divided by the round-trip time.
In this case, the average window size is 45,000 bytes or 360,000 bits. This
number of bits can be transmitted in one round-trip time.
throughput 360,000 bits 30 ms 12,000,000 bps = 12 Mbps
P3-59.
P3-60.