ESET315 Lecture TCP Fall24
ESET315 Lecture TCP Fall24
& Security
TCP/UDP
IP
Ethernet,
Wi-Fi,
Cellular,
etc
2
TCP and UDP are end-to-end protocols
• Let’s draw the communication from Host A1 to Host B
using the OSI layers Please submit your drawing in Canvas.
3
Functionality of Transport Layer
Protocols
• Multiplexing
UDP
• Error Checking TCP
• Reliability
• Rate Control (Flow congestion control)
Port
TCP UDP numbers
ICMP
Protocol
IP
Field
ARP RARP
Type
Field
Ethernet
Driver
Incoming
Electronics & 6frame UDP
Data
Telecommunications
TCP X UDP
Internet B
A
End-to-End
TCP UDP
Reliable Unreliable
(acknowledgements and
retransmissions)
Connection-oriented Connectionless
service datagram service
7
UDP Packet Header
Events at A
Events at B
Connect SYN=1, initial sequence number (ISN) = X
3-way
Handshake
Acknowledge SYN=0, initial sequence number (ISN) = X+1,
algorithm
Accept ACK = Y+1
Events at A
Events at B
Close FIN=1, Seq = X
ACK = Y+1
Acknowledge
UDP SYN=0,Electronics
initial sequence number = Y+1
& Telecommunications 12
Socket
Programming
–
TCP Server
Electronics &
…
15 UDP
Telecommunications
TCP Demultiplexing
Application 1 Application 2 Application 3
Port 1 Port 2 Port 3
TCP: Demultiplexing
Based On Port
IP Layer
Electronics &
…
17 UDP
Telecommunications
TCP is a sliding-window ARQ protocol:
Sequence number (SN) – the first byte of data in the TCP segment
TCP numbers each byte with a SN
maximum: 2 32 – 1 (wraps around)
Acknowledgement number – the next sequence number that the sender
of ack expects to receive
Window size – number of bytes that the receiver can accept (buffer space)
UDP
…
Electronics & Telecommunications 18
TCP Header (Code Bits)
0 4 10 16 24 31
SOURCE PORT DESTINATION PORT
SEQUENCE NUMBER
ACKNOWLEDGEMENT NUMBER
HLEN RESERVED CODE BITS WINDOW
CHECKSUM URGENT POINTER
OPTIONS (IF ANY) PADDING
DATA
URG: The urgent pointer is valid
ACK: The acknowledgment number is valid …
PSH: the receiver should pass this data to the
application as soon as possible U A P R S FI
RST: Reset the connection R C S ST Y N
SYN: Synchronize sequence numbers to initiate a
G K H N
connection.
FIN: The sender isUDP
finished sending data.& Telecommunications
Electronics 19
TCP Transmission Example
Window = 16 bytes
DATA, SEQ=64, ACK=28, (16 bytes of data)
16 bytes of data
received
ACK = 80, Window = 8
Window = 8 bytes
DATA, SEQ=80, ACK=28, (8 bytes of data)
8 bytes of data
ACK = 88, Window = 8 received
Layer 4 TCP
HEADER TCP Data Area
20 bytes
Layer 3 IP
HEADER IP DATA AREA
20 bytes 1480 bytes
FRAME
HEADER FRAME DATA AREA CRC
- Peterson, Chapter 5
- Section 5.1 – Simple Demultiplexer (UDP)
- Section 5.2 – Reliable Byte Stream (TCP)
- 5.2.3 – Connection Establishment and Termination (pages
402 to 404