TCP Networking Overview and Concepts
TCP Networking Overview and Concepts
Chapter 1- TCP
Types of Networks
LAN (Local Area Network): A network that connects devices within a limited area such as a home,
school, or office building.
Home / Office
Desktop PC Wired
Printer Wired
WAN (Wide Area Network): A network that covers a broad area (e.g., any network whose
communications links cross metropolitan, regional, or national boundaries over a long distance).
MAN (Metropolitan Area Network): A network that connects users in a geographic area or region
larger than that covered by even a large local area network (LAN) but smaller than the area covered
by a wide area network (WAN).
Hadi Hijazi
City Fiber Ring
Hospital
PAN (Personal Area Network): A network for interconnecting devices centered around an individual
person's workspace.
Smartphone
Network Topologies
Star Topology: All devices are connected to a central hub.
Central Hub
Bus Topology: All devices are connected to a single central cable, called the bus or backbone.
Hadi Hijazi
Backbone_Cable
Device 1
Ring Topology: Each device is connected to two other devices, forming a circular data path.
Device B Device C
Device A Device D
Mesh Topology: Every device is connected to every other device in the network.
Node A
Node B
Node C
Node D
Hadi Hijazi
Star_Segment
Device 1 Device 2
Hub
Bridge
Ring_Segment
Node A
Node B
Node C
Network Devices
Router: A device that forwards data packets between computer networks, creating an overlay
internetwork.
Switch: A device that filters and forwards packets between LAN segments.
Hub: A basic networking device that connects multiple Ethernet devices, making them act as a single
network segment.
Modem: A device that modulates and demodulates signals for data transmission over telephone
lines.
Access Point: A device that allows wireless devices to connect to a wired network using Wi-Fi or
related standards.
Hadi Hijazi
others...
Network Layers
Physical Layer: Deals with the physical connection between devices and the transmission of binary
data over physical media.
Data Link Layer: Responsible for node-to-node data transfer and error detection/correction.
Network Layer: Manages device addressing, tracks the location of devices on the network, and
determines the best way to move data.
Transport Layer: Provides reliable data transfer services to the upper layers.
Session Layer: Manages sessions between applications.
Presentation Layer: Translates data between the application layer and the network format.
Application Layer: Provides network services directly to end-user applications.
Hadi Hijazi
Models & Layers Comparison
OSI Model
TCP/IP Model
7. Application
5. Session
2. Data Link
1. Physical
Encapsulation
Data encapsulation is the process of wrapping data with protocol information at each layer of the OSI or
TCP/IP model.
Hadi Hijazi
Layers
Application
Encapsulates
Transport
Encapsulates
Network
Encapsulates
Data Link
Encapsulates
Physical
Congestion Control
Congestion control ensures the sender does not overwhelm the network. It uses a Congestion Window
(cwnd).
TCP Phases
Slow Start: Exponential growth (CWND doubles every RTT). Starts at 1 MSS.
Congestion Avoidance: Linear growth (CWND + 1 MSS per RTT). Happens after reaching the threshold
(ssthresh).
Congestion Detection:
TCP Tahoe (The "Panic" Approach): On any loss (Timeout OR 3 Dup ACKs), it resets cwnd to 1 and enters
Slow Start.
Hadi Hijazi
TCP Reno (The "Smart" Approach):
On 3 Dup ACKs (Fast Recovery): Halves the cwnd (cwnd = cwnd / 2) and enters Congestion Avoidance
immediately. It skips Slow Start.
11
10
8
CWND Size (MSS)
1 2 3 4 5 6 7 8 9 10 11 12
Hadi Hijazi
TCP RENO GRAPH (FAST RECOVERY)
11
10
8
CWND Size (MSS)
1 2 3 4 5 6 7 8 9 10 11 12
Note: At Round 6, "3 Duplicate ACKs" occur. Reno cuts CWND in half (to 5) and grows linearly (Congestion
Avoidance), avoiding the slow start restart.
KEY DIFFERENCES
Response to 3 Dup Reset cwnd to 1 (Slow Fast Recovery: cwnd = cwnd / 2 , then
ACKs Start) linear growth
Assumes all loss is severe Distinguishes between severe loss (Timeout) and
Philosophy
congestion. sporadic loss (Dup ACKs).
3-Way Handshake
The TCP 3-way handshake is used to establish a reliable connection between a client and server.
1. SYN: The client sends a SYN (synchronize) packet to the server to initiate a connection.
2. SYN-ACK: The server responds with a SYN-ACK (synchronize-acknowledge) packet to acknowledge
the client's request and synchronize its own sequence number.
Hadi Hijazi
3. ACK: The client sends an ACK (acknowledge) packet back to the server to confirm the connection is
established.
Client Server
State: CLOSED
SYN (Seq=x)
State: SYN_SENT
State: ESTABLISHED
ACK (y+1)
State: ESTABLISHED
Client Server
An "ACK" isn't a separate packet type; it's just a segment with the ACK Flag set to 1 and a value in the
Acknowledgement Number field.
Piggybacking: The ACK for received data is often "piggybacked" onto an outgoing data segment to
save bandwidth.
Cumulative: The ACK number is always the Next Expected Byte. If you receive byte 100, you send
ACK = 101 .
Scenario A: The "Happy Path" (Normal Connection)
Hadi Hijazi
2. Server: Sends SYN=1 , ACK=1 .
Seq=x+1 .
Ack=y+1 (Confirming server's SYN).
Note: This 3rd packet can carry application data (e.g., the HTTP request).
What happens if the Client sends a SYN to a port where no application is listening (e.g., port 8080 is
closed)?
Server Response: It does not ignore the packet. It replies with a RST (Reset) segment.
Meaning: "No one is home. Stop trying." The client immediately aborts; no teardown is needed.
Lost SYN: Client gets no response. It assumes the packet was lost and retransmits the SYN after a
timeout.
Lost SYN-ACK:
Prevention of "Old" Packet Confusion: If a connection closes and immediately reopens, a stray
packet from the old connection (delayed in the network) might arrive with Seq=100 . If the new
connection also started at 0 and is currently at 100, that old packet would be accepted as valid data,
corrupting the file.
Anti-Spoofing / Hijacking: If ISNs were predictable (e.g., always 0), an attacker could easily spoof a
connection by guessing the sequence numbers. Randomness makes this much harder.
Hadi Hijazi
Scenario E: SYN Flood Attack (Denial of Service)
Attack: Attacker sends thousands of SYN packets with fake (spoofed) IP addresses.
Result: Server replies with SYN-ACK and allocates memory (buffers) for every request, waiting for
the final ACK that never comes.
Impact: Server runs out of memory/resources and crashes or stops accepting legitimate connections.
Defense: SYN Cookies (Server doesn't allocate memory immediately; instead, it encodes the state
into the Initial Sequence Number itself).
Types: Propagation (distance), Serialization (link speed), Processing (router CPU), Queuing
(congestion).
Hadi Hijazi
Feature IntServ (Integrated Services) DiffServ (Differentiated Services)
Reservation (Hard QoS). Signals the Categorization (Soft QoS). Classifies packets
Philosophy
network to reserve bandwidth per flow. into groups and treats groups differently.
Low. Core routers must maintain state for High. Core routers only look at the class (DSCP
Scalability
every flow. Good for small networks. mark), not individual flows.
IntServ Model
RSVP Resv
RSVP Resv RSVP Resv
Routers maintain STATE for
every flow
IntServ Components
RSVP: The signaling protocol.
PATH Message: Sender Receiver (Carries TSpec: Traffic Specification).
RESV Message: Receiver Sender (Carries RSpec: Reservation Specification).
Services:
Guaranteed Service: Hard bound on delay (for real-time apps).
Controlled Load: Emulates a lightly loaded network (best effort but "better").
PHB (Per-Hop Behavior): The treatment a packet gets based on its mark.
EF (Expedited Forwarding): Low latency, low jitter, guaranteed bandwidth (e.g., Voice).
Formula: AFxy where x = Class (Priority) and y = Drop Probability (High y = High drop
chance).
Example: AF41 is better than AF11 (Higher Priority). AF13 is dropped before AF11 (Higher Drop Prob).
Hadi Hijazi
CS (Class Selector): Backward compatible with old IP Precedence.
Both control traffic rates, but they handle "excess" traffic differently.
Concept: Tokens fill the bucket at rate r . To send a packet, you need a token. If the bucket is full,
tokens overflow (waste). If the bucket is empty, you wait (shape) or drop (police).
Bucket Logic
Traffic In
Congestion Avoidance
Tail Drop: The default. When the queue is full, drop new packets. Bad: Causes "TCP Global
Synchronization" (all streams slow down at once).
Hadi Hijazi
RED (Random Early Detection): Randomly drops packets before the queue is full to signal TCP to
slow down gracefully.
IPv6
Why IPv6? Developed because IPv4 addresses are running out. With the rise of IoT and internet-
connected devices, the 32-bit space of IPv4 is insufficient. IPv6 solves this with a massive 128-bit
address space.
Addressing Format:
Notation Rules:
Address Types:
Unicast: One-to-One.
Multicast: One-to-Many.
Anycast: One-to-Nearest (assigned to multiple devices; routed to the closest one).
Key Features:
Simpler Header: Fixed 40 bytes (vs. IPv4's variable 20+ bytes) for faster processing.
Autoconfiguration: Supports SLAAC (Stateless) and DHCPv6 (Stateful).
Security: Built-in IPSec support.
Hadi Hijazi
Chapter 3- Network Function Virtualization (NFV)
1. The Concept
NFV replaces dedicated hardware appliances (proprietary "middleboxes") with software-based Virtual
Network Functions (VNFs) running on standard commodity servers (COTS - Commercial Off-The-Shelf).
Traditional: One physical node per role (Router, Firewall, DPI). Hard to scale, expensive.
Virtualized: Generic hardware runs multiple functions as software. Flexible, scalable.
NFV Orchestrator (NFVO): Manages the lifecycle of Network Services (chains of VNFs). Global
view.
VNF Manager (VNFM): Manages the lifecycle of individual VNFs (start, stop, scale).
VIM (Virtualized Infrastructure Manager): Controls the hardware/resources (e.g., OpenStack).
Hadi Hijazi
OSS/BSS (Business Support)
Network Service
NFV Infrastructure VNF Layer
Virtualization Layer
Hardware Resources
Hypervisor / Container
Compute Storage Network VNF: FireWall VNF: Router Element Manager
Engine
Another View:
Component Breakdown
NFVI (NFV Infrastructure): The foundation that hosts the virtual machines.
Hardware Resources: The physical Compute (CPU), Storage, and Network [switches].
Virtualization Layer: The Hypervisor (like KVM or ESXi) or Container Engine (like Docker) that
abstracts the hardware, allowing multiple VMs to share the same physical server.
VNF (Virtualized Network Function): The software application that performs the network function.
Hadi Hijazi
Examples: vRouter, vFirewall, vLoadBalancer.
Element Manager (EM): A small management agent specifically for the VNF [handles
configuration and alarms for that specific app].
MANO (Management and Orchestration): The "brain of the operation," responsible for managing the
lifecycle of resources and services. It has three sub-components:
NFV Orchestrator (NFVO): The "Boss." It manages Network Services (chains of VNFs). It speaks
to the OSS/BSS and decides when to create a new service.
VNF Manager (VNFM): The "Supervisor." It manages the lifecycle of individual VNFs
(instantiating, scaling, updating, and terminating them).
VIM (Virtualized Infrastructure Manager): The "Resource Controller." It controls the NFVI
(hardware/hypervisor). It allocates CPU, memory, and storage to the VMs. (Common example:
OpenStack).
5. Use Cases
5G Core: Running 5G functions (UPF, SMF) as software.
vCPE (Virtual Customer Premise Equipment): Replacing the box in your house/office with a virtual
one in the cloud.
IoT: Dynamic resource management for billions of devices.
Core Concept: "Software Defined" = Programmable. SDN exposes the control of the underlying
system to upper-layer developers through an API.
Hadi Hijazi
Runs proprietary implementations of standard protocols (IP, OSPF, BGP) in proprietary OS (e.g.,
Cisco IOS).
Control is distributed on a per-router basis.
Router Components:
Input Ports: Line termination, data link protocols (Ethernet), lookup/forwarding (decentralized
switching).
Switching Fabric: Transfers packets from input to output buffers. Types: Memory, Bus, Crossbar.
Output Ports: Buffers packets, scheduling disciplines to choose next packet for transmission.
Traditional Forwarding:
Why SDN?
Hadi Hijazi
2. SDN Architecture (The 3 Layers)
Application Layer
(Network Apps)
Firewall App Load Balancer App Routing App
Control Layer
Northbound API
REST
SDN Controller
e.g., ONOS, OpenDaylight
Southbound API
OpenFlow
Forwarding: Moving packets from router's input to appropriate output (Data Plane).
Hadi Hijazi
Routing: Determining end-to-end path from source to destination (Control Plane).
Switches use Flow Tables (Match + Action) instead of simple routing tables.
Protocol: OpenFlow is the first and most widely adopted southbound API for SDN.
1. Pattern (Match): Header fields to match (MAC, IP, TCP/UDP ports, VLAN, etc.).
2. Actions: What to do with matching packets (forward, drop, modify).
3. Priority: Used when multiple patterns match.
4. Counters: Statistics (bytes, packets matched).
OpenFlow is the standard southbound API for SDN communication between controller and switches.
Message Types
Controller-to-Switch:
Asynchronous (Switch-to-Controller):
Packet-In: Sent when a packet doesn't match any flow entry. Switch asks controller "What should I
do?"
Flow Removed: Notification when a flow entry expires or is deleted.
Port Status: Notify controller of port changes (link up/down).
Hadi Hijazi
Switch Controller
Compute path
Switch Controller
APIs
Southbound Interface:
Northbound Interface:
Hadi Hijazi
Benefit: Abstraction. The Firewall app doesn't need to know if the switch is Cisco or Juniper.
Popular SDN Controllers
Hadi Hijazi
Link Failure at S1
Hadi Hijazi
7. Flow Table Example
Overview
Key Features
Core Concepts
Ref erence_Bandwidth
Metric: Cost = Interf ace_Bandwidth
. (Default ref is 108 ).
Example: 100 Mbps link has Cost 1. 10 Mbps link has Cost 10.
Administrative Distance: 110 (Trusted more than RIP).
Hadi Hijazi
3. LSR (Link State Request): "I need more info on this route."
4. LSU (Link State Update): Sending the actual route info (contains LSAs).
5. LSAck: Acknowledgment.
Hadi Hijazi
2-Way is mostly for
Down DROthers. Full is for
DR/BDR.
Send Hello
Init
2-Way
Master/Slave Election
ExStart
Exchange DBDs
Exchange
Request Details
Loading
Sync Complete
Full State
Hadi Hijazi
Full State
Solution: All routers sync only with the DR and BDR (Backup).
Election: Highest Priority wins. Tie-breaker: Highest Router ID.
Hierarchical OSPF (Two-Level Hierarchy)
Structure:
LSA Scope:
Router Types:
Area Border Router Connects areas. Summarizes distances to networks in its area and advertises to
(ABR) other ABRs.
Backbone Router Runs OSPF routing limited to the backbone area (Area 0).
Boundary Router
Connects to other Autonomous Systems (inter-AS gateway).
(ASBR)
Hadi Hijazi
Area 1
Area 2
Backbone Area 0
Backbone Router
Overview
Goal: Allows a subnet to advertise its existence to the rest of the Internet.
BGP Sessions
Transport: Pairs of routers (BGP peers) exchange routing information over semi-permanent TCP
connections (Port 179).
Two Types:
Hadi Hijazi
AS 200
Router 4
AS 100
eBGP AS 300
Router 1
iBGP (TCP) Router 2 iBGP Router 3 eBGP Router 5
Key Attributes:
Attribute Description
List of ASs through which the prefix advertisement has passed. Used to detect
AS-PATH
loops and measure path length.
NEXT-HOP IP address of the specific internal-AS router to reach the next-hop AS.
MED (Multi-Exit
Suggests to external ASs which entry point to use. Lower is better.
Discriminator)
When multiple routes exist for the same prefix, BGP selects based on this priority list:
Hadi Hijazi
Multiple Routes Available
Highest LOCAL_PREF?
Yes Tie
Yes Tie
Yes Tie
Hadi Hijazi
Select Route Additional Tie-Breakers
Policy-Based Routing
Import Policies: Gateway routers can accept or decline a path based on policy.
Provider-Customer Relationships:
Transit Rules:
A customer connected to two providers should not provide transit between those providers.
Provider A (ISP)
Customer (Dual-Homed)
Provider B (ISP)
ISP B Router
Reason: The customer would become a free transit path between two ISPs, wasting bandwidth without
compensation.
Hadi Hijazi
Intra-AS vs. Inter-AS Routing
Scale Single administrative domain Hierarchical; saves table size, reduces update traffic
Trust Single admin; all routers trusted Multiple admins; trust boundaries
Overview
This chapter explains why HTTP evolved from HTTP/1.1 to HTTP/2 and HTTP/3, and how QUIC improves
performance and security.
Introduced persistent TCP connections (reuse the same TCP connection for multiple requests).
Problem: Head-of-the-Line (HOL) blocking at the HTTP level.
One slow object at the front of the queue prevents all others behind it from being transmitted.
HTTP/2
Hadi Hijazi
If a single TCP segment is lost, all HTTP streams stall until TCP retransmits (transport-layer
HOL).
HTTP/3
Hadi Hijazi
HTTP/1.1 Persistent TCP
HTTP/2 Multiplexed
streams over TCP
Solution: Independent
streams + faster handshake
Key Features
Connection Establishment: Combines the transport (connect) and security (TLS) handshakes into a
single exchange.
Hadi Hijazi
Result: Setup can be reduced to 1 RTT.
Error and Congestion Control: Provides reliability and congestion control similar to TCP, optimized
for modern web traffic.
No HOL Blocking (Across Streams): A lost packet in one stream does not block data in other
streams.
Connection Migration: Uses a Connection ID rather than the classic IP/Port 4-tuple.
Session can stay active even if the user changes networks (Wi-Fi → 4G).
Client Server
Client Server
Different objects (images, scripts, CSS) can be requested and received independently.
Security by Default: QUIC integrates TLS 1.3 directly into the protocol.
Reduced Latency: By eliminating the multi-step TCP+TLS handshake and avoiding transport-layer
HOL blocking, HTTP/3 improves page load times, especially on lossy networks.
Hadi Hijazi
All streams stalled
HTTP/2 over TCP TCP loss
(retransmit needed)
Multiple Objects-
Page Load
HTML/CSS/JS/Images
Hadi Hijazi