Title: User Datagram Protocol
1User Datagram Protocol
- Unreliable, connectionless delivery (e.g. USPS)
- Same best effort semantics as IP
- No ack, no sequence, no flow control
- Subject to loss, duplication, delay,
out-of-order, or loss of connection - Fast, low overhead
- Suit for reliable, local network
- RTP
2UDP Header and Pseudoheader
Optional16bit xor 1s complement
optional
Cover data and pseudo-header
In reality, many UDP apps are designed for lt 512
3UDP Checksum and Pseudo-Header
- Checksum is optional (0) why?
- Checksum calculation
- Compose pseudo header
- Temporarily prepended to UDP message
- Pad data to 16-bits multiple
- 16-bit 1s complement sum of pseudo-header, UDP
header and user data - what if calculated CS0?
- Guarantees that message arrived at correct
destination - Note pseudo header is not sent across Internet
- To verify the checksum, the receiver must extract
these fields from the IP header first - How is it implemented?
- Is there a layering violation?
4Specify an Application ProgramSocket IPaddr
Port
- Port -- ultimate destination point
- OS binds port to app
- Well-known port
- Ephemeral port
- TCP or UDP?
5TransmissionControlProtocol
- Transport layer (Layer 4)
- Stream-oriented buffered data transfer
(unstructured, multi-segment) - Reliable, virtual circuit connection, end-to-end
service (using ack, retransmit to deal with lost,
delayed, duplicate, or mis-ordered packets) - Efficient flow control
- Full-duplex
6TCP Connection
- A virtual circuit
- A pair of sockets one client and one server
- Sockets (ip address port number)
- Servers use well-known port numbers (lt 1K) for
standardized services (Listen) - FTP (21), FTP-Data (20), Telnet (23), SMTP (25),
HTTP (80), HTTPS(443) - Client ask operating system to assign an unused,
unreserved port number (gt48K) ephemeral port,
before making a connection (Connect) - Client and Server is usually a multi-to-one
mapping - Chance of collision is almost zero
7TCP Connection Establishment3-way handshake
8listen
connect
simultaneous open
9TCP Header Pseudo Header
URG Urgent pointer field is valid ACK
Acknowledgement field is valid PSH Force
delivery RST Reset the connection SYN Synchronize
sequence numbers FIN
First Sending byte index
Next Receiving byte index(forward
acknowledgement)
Receiving buffer size
out-of-band control info location
With Pseudo header, REQUIRED
MaxSegSize, default 536, typical 1024
10Some Header Fields
- Urgent out-of-band control (ctl-c), or
data-mark interpretation - Segment contains pointer to last octet of urgent
data - Urgent data can be retransmitted
- Receiving TCP should deliver urgent data to
application immediately upon receipt - Push send it now, both tx and rx
- Reset abort
- MSS Maximum Segment Size
- MSS gt MTU fragmentation
- MSS small overhead
- MSS min(MTU)
- Path MTU is not easily known to TCP app
- Dynamic route change
- Lower-level options (e.g. IP header options)
- Initial Sequence Number
- Randomly determined at the connection setup time
by each machine - Guessable ISN is a security vulnerability
11Reliable Data Transfer
- PAR - Positive Acknowledgement and Retransmission
- sends one packet, starts a timer, and waits for
an acknowledgment before sending a new packet - stop and wait protocol, one packet at a time
- Fixed Size Sliding Window
- usually in packet level
- Efficiency (compare to PAR)
Efficiency issue
12TCP Sliding Window efficient transmission and
flow control
Who controls the flow?
- Variable Size Sliding Window
- Byte level end to end control (4 sliding windows
per connection) - Allow sending multiple packets before an ack
- Receiver specifies the current window size
(available empty buffers) in every packet
window advertisement - Initial window sizes are indicated at connection
setup, but might vary throughout the data
transfer to provide flow control. For example, a
window size of zero means send no data
Offered window (advertised by receiver)
sent ack
Sent, no ack
ok2sent
wait
13Piggyback Tx/Rx buffer pointers
Client Tx
Server Rx
SYN with CTxSeq (7)
CTxSeq
SYN with STxSeq (25)ACK with CTxSeq1 (8)
Server Tx
ACKwith STxSeq1 (26)
Client Rx
STxSeq
All sequence numbers have been established. Both
sides are ready for data transfers.
14TCP Connection Termination
15listen
connect
app close
half close
app close
simultaneous close
half close
16Comparison Of UDP and TCP
- TCP
- between apps. and IP
- packet called segments
- reliable
- checksum required
- connection-oriented
- stream interface
- useful over WAN or LAN
- flow control
- 1-to-1
- unicast only
- UDP
- between apps. and IP
- packets called datagrams
- unreliable
- checksum optional
- connectionless
- record boundaries
- intended for LAN
- no flow control
- 1-to-1, 1-many, many-1
- allows unicast, multicast or broadcast
- Around 95 of all bytes and around 85-95 of all
packets on the Internet are transmitted using TCP.