knowledge

Overview

Packets and frames are the fundamental units of data transmission in networks. Packets operate at Layer 3 (Network) of the OSI model and carry IP addressing information for routing, while frames operate at Layer 2 (Data Link) and carry MAC addressing for local delivery. Protocols like TCP and UDP define how packets are constructed, transmitted, and acknowledged across networks.


Terminology

TermDefinition
PacketLayer 3 data unit; contains IP headers for routing across networks
FrameLayer 2 data unit; contains MAC addressing for local network delivery
TTL (Time To Live)Expiry counter on a packet; decremented at each hop; packet discarded at 0
ChecksumValue used to verify the integrity of packet data
Sequence NumberTCP field used to track order of transmitted segments
Acknowledgement NumberTCP field confirming receipt of data up to a specific sequence number
SYNTCP flag used to initiate a connection
ACKTCP flag confirming receipt of data
FINTCP flag used for graceful connection termination
RSTTCP flag for abrupt connection reset
DatagramUDP’s term for a transmitted unit of data

Core Concepts

Packet Structure

Every packet contains headers and a payload.

Header FieldPurpose
TTL (Time To Live)Limits packet lifetime; prevents infinite routing loops
ChecksumVerifies data integrity during transit
Source AddressIP address of the sending device
Destination AddressIP address of the receiving device

TCP (Transmission Control Protocol)

Connection-oriented and stateful — guarantees reliable, ordered data delivery.

Header FieldPurpose
Source Port / Destination PortIdentifies sending and receiving application
Source IP / Destination IPIdentifies sending and receiving device
Sequence NumberTracks order of segments
Acknowledgement NumberConfirms receipt of data
ChecksumVerifies segment integrity
FlagsControls connection state (SYN, ACK, FIN, RST, DATA)
DataThe actual payload

TCP 3-Way Handshake

TCP 3-Way Handshake

Connection establishment:

  1. Client sends SYN with Initial Sequence Number (ISN)
  2. Server replies SYN/ACK with its own ISN
  3. Client sends ACK with ISN + 1

Connection termination: Closing a TCP Connection

  1. Initiating side sends FIN
  2. Receiving side replies FIN/ACK
  3. Initiating side sends final ACK

TCP Flags

FlagPurpose
SYNInitiate connection
SYN/ACKAcknowledge and synchronize
ACKConfirm receipt of data
FINGraceful connection termination
RSTAbrupt connection reset
DATACarries actual payload

UDP (User Datagram Protocol)

Connectionless and stateless — faster than TCP but with no delivery guarantee.

UDP Datagram Structure

Header FieldPurpose
Source Port / Destination PortIdentifies sending and receiving application
Source Address / Destination AddressIdentifies sending and receiving device
TTLLimits datagram lifetime
DataThe actual payload
  • No handshake, no acknowledgements, no sequencing
  • Suitable for applications tolerant to packet loss (e.g., video streaming, DNS, VoIP)

TCP vs UDP

FeatureTCPUDP
ConnectionConnection-orientedConnectionless
ReliabilityGuaranteed deliveryNo guarantee
OrderSequencedNot sequenced
SpeedSlowerFaster
Use CasesWeb, email, file transferStreaming, DNS, VoIP

  • Packet Analysis
  • Packet Sniffing

References / Images

  • TCP 3-Way Handshake
  • Closing a TCP Connection
  • UDP Datagram Structure
  • RFC 793 (TCP), RFC 768 (UDP)
  • Networking textbooks and vendor documentation