Title: Module 14 UDP and TCP Frames
1Module 14UDP and TCP Frames
2- Textbook sections
- LG Section 8.5 Transmission Control Protocol
- BF Chapter 11 UDP Section 11.1 11.4
- BF Chapter 12 TCP Sections 12.1 12.12
- Topics
- User Datagram Protocol (UDP)
- Transmission Control Protocol (TCP)
- TCP Timers
- TCP Operation Scenarios
3BF Figure 12-1 TCP/IP Protocol Suite
41. User Datagram Protocol (UDP)
- User Datagram Protocol (UDP)
- UDP is an unreliable, connectionless transport
layer protocol - Provides only two additional services beyond IP
- Demultiplexing
- IP knows how to deliver packets to a host, but
does not know how to deliver them to the specific
application in the host. UDP adds a mechanism
that distinguishes among multiple applications in
the host (port address) - Error checking on data
- IP checks only the integrity of its header. UDP
can optionally check the integrity of the entire
user datagram (header and data). - For IPv6, the header checksum of IPv4 is
eliminated because the checksum is/can be
provided by upper layer protocols.
5LG Figure 8.16 UDP format
31
16
0
Source Port
Destination Port
UDP Length
UDP Checksum
Data
61. User Datagram Protocol (UDP)
- UDP checksum
- The usage of UDP checksum is an option.
- Checksum field contains all 0s, if a source host
does not want to compute the checksum. - If a host computers the checksum whose result is
0, it will set the checksum to all 1s. - Checksum includes
- Pseudo header from the IP header
- The pseudoheader is part of the header of the IP
packet in which the user datagram is to be
encapsulated for transmission with some fields
filled with 0s. - Routers recalculate the value in the IP checksum
field - UDP header
- Data, padded with zero octets at the end (if
necessary) to make a multiple of two octets.
7BF Figure 11.8 Pseudoheader added to the UDP
datagram
81. User Datagram Protocol (UDP)
- Use of UDP
- Trivial File Transfer Protocol (TFTP)
- TFTP includes flow and error control. It can
easily use UDP. - Simple Network Management Protocol (SNMP)
- Routing Information Protocol (RIP)
- Real-Time Protocol (RTP)
- Domain Name System (DNS)
- Multicasting and broadcasting
- UDP is a suitable transport protocol for
multicasting and broadcasting. Multicasting and
broadcasting capabilities are embedded in the UDP
software but not in the TCP software - In general UDP is suitable for a process that
requires simple request-response communication
and with little concern for flow and error
control. It is not usually used for a process
that needs to send bulk data, such as FTP.
9BF Figure 12-4 TCP segment format
102. Transmission Control Protocol (TCP)
- TCP segment format
- Sequence number field
- 32-bit field defines the number assigned to the
first byte of data contained in this segment - Acknowledge number filed
- 32-bit field defines the byte number that the
source of the segment is expecting to receive
from the other party - Data offset field
- 4 bits field indicate the number of 32 bits
words(in units of 4-bytes word) in the TCP
header. It indicates where the data begins. The
TCP header (even one including options) is an
integral number of 32 bits long. - Window size field
- 16-bit field defines the size of the window, in
bytes, that the other party must maintain - Used for flow control
- The sequence number field, the acknowledge number
field, and the window size field are all involved
in TCPs sliding window algorithms.
112. Transmission Control Protocol (TCP)
- Control field
- BF Figure 12.5 Control field
- Option field
- Figure 12.9 Maximum segment size option
- Figure 12.10 Window scale factor option
- Figure 12.11 Timestamp option
122. Transmission Control Protocol (TCP)
- Checksum field
- The TCP checksum field is used in exactly the
same way as for UDP. - TCP checksum is computed over
- Pseudoheader
- TCP header
- TCP data
- The checksum computation procedure is similar to
IP checksum calculation - Additional features of TCP checksum calculation
- Padding If the length of the segment is not a
multiple of 16 bits, the segment will be padded
with zeros to make it a multiple of 16 bits.
Note, however, the TCP length field is not
modified.
132. Transmission Control Protocol (TCP)
- Pseudoheader
- Pseudoheader is added to the beginning of the
segment when performing the checksum computation - Pseudoheader is created by the source and
destination hosts during the checksum computation
and is not transmitted. - Pseudoheader ensures the receiver that the
segment has indeed reached the correct
destination host and port and that the protocol
type is TCP (which is assigned the value of 6).
At the receiver the IP address information in the
IP packet that contained the segment is used in
the checksum calculation. - The TCP Length field in the Pseudoheader is the
TCP header length plus the data length in bytes.
It does not count the 12 bytes of the
Pseudoheader.
142. Transmission Control Protocol (TCP)
- Pseudoheader A subset of fields from the IP
header that are passed up to transport protocols
TCP and UDP for use in their checksum
calculations. - Part of both TCPs and UDPs checksum calculation
- Not transmitted
- Consists of three fields from IP header protocol
number, source IP address, and destination IP
address, plus TCPs or UDPs total length. - Purpose is to ensure the contents of pseudoheader
fields are transmitted correctly.
15BF Figure 12-12 Pseudoheader Added to the TCP
Datagram
162. Transmission Control Protocol (TCP)
- Urgent pointer field
- A 16-bit field is valid only if the urgent flag
in the control field is set. - Used when the segment contains urgent data.
- Defines the number that must be added to the
sequence number to obtain the number of the last
urgent byte in the data section of the segment. - This facility is a bare bones way of allowing the
sender to signal the receiver without getting TCP
itself involved in the reason for the interrupt - The urgent flag in the control field indicates
that this segment contains urgent data. When
this flag is set, the urgent point field
indicates where the non-urgent data contained in
this segment begins.
172. Transmission Control Protocol (TCP)
BF Figure 12-5 Control Field
182. Transmission Control Protocol (TCP)
- Control field
- URG flag
- Out of sequence number
- TCP is a stream-oriented protocol
- However, if the sending program wants a piece of
data to be read out of order by the receiving
application program, it can do so by setting the
urgent flag and provide value in the urgent
pointer field. - When the receiving TCP receives a segment with
urgent flag set, it extracts the urgent data from
the segment using the value in the urgent
pointer. - The extracted data will be delivered to the
receiving application program as soon as it
arrives, even if it means delivering it before
data with a earlier sequence number.
192. Transmission Control Protocol (TCP)
- Control field
- PSH flag
- Do not wait
- The application program on the sending site can
request a push operation. This means that the
sending TCP should not wait for the window to be
filled. It should create a segment and send it
immediately. The sending TCP should also set the
push bit (PSH). - At the receiving TCP, when the PSH bit is set,
it tells the receiver to pass the data to the
application immediately and do not wait for more
data to come.Otherwise, receiver may choose to
buffer the segment until enough data accumulates
init buffer.
202. Transmission Control Protocol (TCP) Option
Field
BF Figure 12-6 Options
212. Transmission Control Protocol (TCP) Option
Field
BF Figure 12-7 End of Option
222. Transmission Control Protocol (TCP) Option
Field
BF Figure 12-8 No Operation Option
232. Transmission Control Protocol (TCP) Option
Field
BF Figure 12-9 Maximum segment size (MSS) option
- Note It communicates the maximum receive segment
size at the TCP which sends this segment. - This option is used only in the segments that
make the connections. It cannot be used in
segments during data transfer. - The size is determined by the destination of the
segment, not the source. So party 1 defines what
should be the MSS sent by party 2. Party 2
defines what should be the MSS sent by party 1. - It defines the maximum size of the data, not the
maximum size of the segment. - The default value is 536.
242. Transmission Control Protocol (TCP) Option
Field
BF Figure 12-10 Window scale factor option
Note 1. New window size window size defined
in the header 2window scale factor 2. The size
of the window cannot be greater than the maximum
for the sequence number. The largest value of
window scale factor allowed is 16.
252. Transmission Control Protocol (TCP) Option
Field
BF Figure 12-11Timestamp option
- Note
- TCP -gt connection-oriented -gt acknowledgement -gt
necessary retransmission based on round-trip-time
(RTT) -gt one approach is to use TCP time stamp
option to estimate RTT dynamically - Usage of TCP timestamp option
- Source fills timestamp value in the timestamp
field when the segment leaves the source - Destination stores the timestamp value after it
received the segment. - When the destination sends an acknowledgement
for the bytes in the segment received,
destination enters the stored timestamp value in
the timestamp echo reply field. - The source, after received the acknowledgement,
calculates the round-trip-time (RTT) by taking
the difference between the current time and the
value in the timestamp echo reply field.
263. TCP Timers
BF Figure 12-21 TCP Timers
273. TCP Timers
- TCP timer
- Retransmission timer
- If the retransmission timer goes off before the
acknowledgement arrives, the segment is
retransmitted and the timer is reset. - The most common formula used to calculate
retransmission time - Retransmission time 2 round-trip time (RTT)
- Calculation or RTT
- First method Use timestamp option
- Second method TCP sends a segment, starts a
timer, wait for an acknowledgement, and measure
the round-trip time. - RTT alpha previous RTT (1 alpha)
current RTT - where alpha is between 0 and 1, and is usually
set at 0.9 - Karn algorithm
- Do not update the value of RTT until you send a
segment and receive an acknowledgement without
the need for retransmission
283. TCP Timers
- Persistence timer
- Used to correct deadlock caused by the announce
of a window size of zero by the receiving
followed by an acknowledgment lost from the
receiver. - Probe usage
- When the sending TCP receive an acknowledgement
with a window size of zero, it starts a
persistence timer. - When the persistence timer goes off, the sending
TCP sends a special segment called probe. - Keepalive timer
- Used to prevent a long idle connection between
two TCPs - Time-waited timer
- Used during connection termination
294. TCP Operation Scenarios
- Operation scenarios
- Connection establishment
- Three-way handshake - to establish a connection
- Four-way handshake - to terminate a connection
- Data transfer
- Typical
- Pushing data
- Urgent data
- Connection termination
- State transition diagram representation
304. TCP Operation Scenarios
- Three-way handshake
- An algorithm used by TCP to establish a
connection - Involves the exchange of three messages between
the sender and the receiver - Purpose is for two parties to agree on the
starting sequence numbers the two sides plan to
use for their respective byte streams - Algorithm
- Step 1 the sender sends a segment to the
receiver stating the initial sequence number it
plan to use (Flags SYN, sequence number x) - Step 2 the receiver responds with a single
segment that both acknowledges the senders
sequence number (Flag ACK, ack x1) and
states its own beginning sequence (Flag SYN,
sequence number y). Both SYN and ACK bits are
set in the Flags field of the second message. - Step3 the sender responds with a third message
that acknowledges the receivers sequence number
(Flags ACK, acknowledge number y1).
314. TCP Operation Scenarios
BF Figure 12-22 Three-way Handshaking
324. TCP Operation Scenarios
- Four-way handshake
- An algorithm used by TCP to terminate a
connection - Algorithm
- Step 1 First, the sender sends a FIN segment to
the receiver (Flags FIN, sequence number x) - Step 2 the receiver sends the second segment, an
ACK segment, to confirm the receipt of the FIN
segment from the sender. In this segment it uses
the acknowledgement number, which is one plus the
sequence number. (Flags ACK, sequence number
y, acknowledge number x1) - Step 3 The receiver can continue sending data in
the receiver-sender direction. When it does not
have any more data to send, it sends the third
segment. This segment is a FIN segment. (Flags
FIN, sequence number y m, acknowledge number
x1) - Step 4 The sender sends the fourth segment, an
ACK segment, to confirm the receipt of the FIN
segment from the receiver. This segment contains
the acknowledgement number , which is one plus
the sequence number received in the FIN from the
server. (Flags ACK, sequence number x 1,
acknowledge number ym1)
334. TCP Operation Scenarios
BF Figure 12-23 Four-way Handshaking
344. TCP Operation Scenarios
BF Figure 12-24 State Transition Diagram
354. TCP Operation Scenarios
- Notations of Figure 12.24
- Lines
- Dotted lines of the figure represent the server
- Solid lines represent the client
- Thin lines represent unusual situations
- Event/action
- Event can take the machine to a new state
- Event can also make the machine perform some
actions
364. TCP Operation Scenarios - States for TCP
BF Table 12.3 States for TCP
374. TCP Operation Scenarios
- Reading assignments
- BF Chapter 12 TCP Sections 12.9 Connection
- BF Chapter 12 TCP Sections 12.10 State Transition
Diagram
384. TCP Operation Scenarios
394. TCP Operation Scenarios
404. TCP Operation Scenarios
- TIME-WAIT state
- The value of the timer is set to double the
lifetime estimate of a segment of maximum size - Reason for using the timer
- While the client TCP of the connection has sent
an ACK in response to the server TCPs FIN
segment, it does not know that the ACK was
successfully delivered. - As a consequence, the server TCP might retransmit
its FIN segment. - The second FIN segment might by delayed in the
network. - If the connection were allowed to move directly
from the FIN-Wait-2 state to the CLOSED state,
then another pair of application processes might
come along and open the same connection (i.e.,
use the same pair of port numbers), and the
delayed FIN segment from the earlier incarnation
of the connection would immediately initiate the
termination of the later incarnation of that
connection.