In: Computer Science
Hosts A and B are communicating over a TCP connection, and Host B has already received from A all bytes up through byte 126. Suppose Host A then sends two segments to Host B back-to-back. The first and second segments contain 80 and 40 bytes of data, respectively. In the first segment, the sequence number is 127, the source port number is 302, and the destination port number is 80. Host B sends an acknowledgment whenever it receives a segment from Host A.
(a) In the second segment sent from Host A to B, what are the sequence number, source port number, and destination port number?
(b) If the first segment arrives before the second segment, in the acknowledgment of the first arriving segment, what is the acknowledgment number, the source port number, and the destination port number?
Solution:
Given,
=>First segment: size = 80 bytes, sequence number = 127, source port number = 302, destination port number = 80.
=>Second segment: size = 40 bytes
(a)
Explanation:
Calculating second segment sequence number:
=>First segment's last byte sequence number = 127 + 80 - 1
=>First segment's last byte sequence number = 206
=>Second segment's sequence number = 206 + 1
=>Second segment's sequence number = 207
=>Source and destination port number will be same as the first segment number.
=>Hence source port number = 302, destination port number = 80.
(b)
Explanation:
Calculating acknowledgment number of first segment:
=>Acknowledgement number is 1 more than the sequence number of last byte received.
=>Acknowledgement number = 206 + 1
=>Acknowledgement number = 207
=>Now in acknowledgment source will be host B and destination will be host A hence source port number = 80, destination port number = 302.
I have explained each and every part with the help of statements attached to it.