Professional Documents
Culture Documents
TCP and UDP - : Transport Layer Protocols
TCP and UDP - : Transport Layer Protocols
21 – Aaron Balchunas 1
***
All original material copyright © 2012 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
TCP and UDP v1.21 – Aaron Balchunas 2
***
All original material copyright © 2012 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
TCP and UDP v1.21 – Aaron Balchunas 4
(Reference: http://www.tcpipguide.com/free/t_TCPConnectionEstablishmentProcessTheThreeWayHandsh-3.htm)
***
All original material copyright © 2012 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
TCP and UDP v1.21 – Aaron Balchunas 5
***
All original material copyright © 2012 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
TCP and UDP v1.21 – Aaron Balchunas 6
Once the TCP connection is established, the sequence numbers are used to
identify the data within the segment. Using the above example again,
HostA’s first byte of data will be assigned a sequence number 1001. Note
that this is HostB’s acknowledgment number, which essentially identifies
which byte the receiving host is expecting next. HostB’s first byte of data
will be assigned a sequence number of 4501.
Note that each individual byte of data is not assigned a sequence number
and acknowledged independently, as this would introduce massive overhead.
Instead, data is sequenced and acknowledged in groups, dictated by the TCP
window size. The window size can never exceed the maximum segment
size (MSS), which is 536 bytes by default.
The TCP window size is dictating by the receiving host, and informs the
sender how many bytes it is permitted to send, before waiting for an
acknowledgement. This window size can be dynamically changed to provide
a measure of flow control, preventing buffer congestion on the receiving
host.
A window size of 0 would instruct the sender to send no further data, usually
indicating significant congestion on the receiving host.
TCP employs a sliding window mechanism. Bytes in a sliding window fall
into one of four categories:
• Bytes that have already been sent and acknowledged.
• Bytes that have been sent, but not acknowledged.
• Bytes that have not yet been sent, but the receiving host is ready for.
• Bytes that have not yet been sent, and the receiving host is not ready
for.
(Reference: http://www.tcpipguide.com/free/t_TCPSlidingWindowAcknowledgmentSystemForDataTranspo-5.htm;
http://docwiki.cisco.com/wiki/Internet_Protocols#Transmission_Control_Protocol_.28TCP.29)
***
All original material copyright © 2012 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
TCP and UDP v1.21 – Aaron Balchunas 7
Once HostA sends the FIN message, it will enter a FIN-Wait-1 state,
waiting for the FIN to be acknowledged.
HostB responds to the FIN with an ACK message, and enters a Close-Wait
state, allowing the local application to finish its processes. HostA receives
the ACK and enters a FIN-Wait-2 state, waiting for HostB to send a FIN
message of its own, indicating it is safe to close the connection.
HostB sends a FIN message to HostA once the application process is
complete, and enters a Last-ACK state.
HostA receives the FIN message and responds with an ACK message.
HostA then enters a Time-Wait state, allowing time for the ACK to be
received by HostB.
HostB receives the ACK message and enters a Closed state.
HostA’s Time-Wait timer expires, and it also enters a Closed state. The
connection is now gracefully terminated.
(Reference: http://www.tcpipguide.com/free/t_TCPConnectionTermination-2.htm)
***
All original material copyright © 2012 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
TCP and UDP v1.21 – Aaron Balchunas 10
(Reference: http://www.tcpipguide.com/free/t_TCPConnectionManagementandProblemHandlingtheConnec.htm)
***
All original material copyright © 2012 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
TCP and UDP v1.21 – Aaron Balchunas 11
The 16-bit Source Port field identifies the application service on the
sending host. The 16-bit Destination Port field identifies the application
service on the remote host.
The 32-bit Sequence Number field is used both during connection
establishment, and during data transfer. During connection establishment
(SYN message), an initial sequence number is randomly chosen.
Subsequently, sequence numbers are used to identify data bytes in a stream.
The 32-bit Acknowledgement Number field, as its name suggests, is used
to acknowledge a sequence number. During connection setup, this is set to
the sending host’s initial sequence number + 1. During data transfer, this
value is used to acknowledge receipt of a group of data bytes.
The 4-bit Data Offset field indicates where data begins in a TCP segment,
by identifying the number of 32-bit multiples in the TCP header. A TCP
header must end on a 32-bit boundary.
Following the data offset field is the 6-bit Reserved (for future use) field,
which is always set to zeroes.
***
All original material copyright © 2012 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
TCP and UDP v1.21 – Aaron Balchunas 12
***
All original material copyright © 2012 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.