TCP & UDP Operations Notes

Transportation Layer Protocols

  • Three main Layer 4 protocols in TCP/IP:
    • TCP (Transmission Control Protocol):
    • Connection-oriented and reliable.
    • UDP (User Datagram Protocol):
    • Connectionless and not reliable.
    • SCTP (Stream Control Transmission Protocol):
    • New protocol designed for reliable transmission over a connectionless network.

TCP Overview

  • Reliable host-to-host connection:
    • Controls for initiation, flow control, and termination.
  • Various revisions exist:
    • Slow Start, Reno, Tahoe, Vegas, Compound TCP, BIC/CUBIC.

TCP Header Format

  • Structure of TCP header:
    • Source Port, Destination Port
    • Sequence number, Acknowledgement number
    • Data offset, Checksum, Options
    • Window, Urgent Pointer

IP Header Overview

  • Key Fields:
    • IHL, Version, Type of Service (TOS), Total Length.
    • Identification, Fragment Offset, Time to Live (TTL), Protocol.
    • Source Address, Destination Address.
    • Important Flags: Do Not Fragment (D), More Fragments (M).

Well-Known Port Numbers (IANA)

  • Selected protocols and their corresponding ports:
    • UDP:
    • Port 53 for DNS
    • Port 67 for DHCP
    • TCP:
    • Port 80 for HTTP
    • Port 25 for SMTP
    • Port 21 for FTP

TCP Header Fields

  • Main fields:
    • Sequence Number: Identifier for transmitted segment.
    • Acknowledgement Number: Next sequence number expected.
    • Data Offset: Where the payload begins.
  • Control Flags (1 bit each):
    • URG, ACK, PSH, RST, SYN, FIN.
  • Window: Number of bytes that can be accepted.
  • Checksum: Validates integrity of the segment.

TCP Connection Establishment

  • Steps in Establishing a Connection:
    • 1. SYN: Request to establish a connection.
    • 2. SYN+ACK: Server acknowledges request.
    • 3. ACK: Client acknowledges to complete the process.

Terminating a TCP Connection

  • Steps in Termination:
    • 1. FIN: Client requests to close.
    • 2. ACK: Server acknowledges the request.
    • 3. FIN: Server requests to close, and the process concludes with ACK.

TCP State Machine

  • States involved in TCP connection management:
    • CLOSED, LISTEN, SYNRCVD, SYNSENT, ESTABLISHED, FINWAIT1, FINWAIT2, CLOSEWAIT, LASTACK, TIME_WAIT.

UDP Overview

  • Characteristics:
    • Minimal delivery capabilities, not reliable.
    • Lacks robust features such as error checking and flow control.

UDP Header Format

  • Key structure:
    • 16-bit Source Port, Destination Port.
    • 16-bit Length of the segment, 16-bit Checksum.

Review Points

  • Understand basic features of both TCP and UDP, especially why TCP is reliable.
  • Familiarize with TCP and UDP headers, their functions, and the differences between their operations.
  • Know the reasoning behind the existence of both protocols and their comparison in different applications.