Vault Notes 🎧Listen

Computer Networks

Subject 1 of 10 · Exact transcription of the original notes, Chapters 1 to 9.

1. Network Basics

1.1 OSI Reference Model

Overview

This content appears to be just a chapter divider page with minimal information. Since there's no substantial technical content to enhance, here's a brief overview of what this chapter covers: Chapter 1: ISO/OSI Stack and LAN Technologies This chapter covers fundamental networking concepts including:

These topics form the foundation for understanding how data moves through networks, from physical transmission to application-level communication. Key focus areas:

OSI Model

The OSI (Open Systems Interconnection) model is a 7-layer framework developed by ISO in 1984 for network communication design. Purpose: Standardizes how different network devices and protocols communicate by dividing complex networking functions into manageable layers. Layer Structure: Each layer provides services to the layer above and uses services from the layer below.

LayerNameFunction
7ApplicationUser interface, network services
6PresentationData formatting, encryption
5SessionConnection management
4TransportReliable data transfer
3NetworkRouting, addressing
2Data LinkFrame formatting, error detection
1PhysicalElectrical signals, hardware
7 · Application6 · Presentation5 · Session4 · Transport3 · Network2 · Data Link1 · Physical
This diagram shows the OSI model as a stack of seven layers. At the top is layer 7, Application, which provides the user interface and network services. Below it is layer 6, Presentation, which handles data formatting and encryption. Below that is layer 5, Session, which manages connections. In the middle is layer 4, Transport, which provides reliable data transfer. Below it is layer 3, Network, which handles routing and addressing. Below that is layer 2, Data Link, which handles frame formatting and error detection. At the bottom is layer 1, Physical, which deals with electrical signals and hardware. The top three layers serve the user, and the bottom four move the data across the network. When sending, data travels down from layer 7 to layer 1; when receiving, it travels up from layer 1 to layer 7. The takeaway is that each layer does one job and serves the layer above it.

Layer Categories:

Key Benefit: Enables interoperability between equipment from different manufacturers by providing common design standards. Remember: Data flows down the stack when sending (7 → 1) and up the stack when receiving (1 → 7).

1.2 Network Topologies

Types of Infrastructure Mode

Wireless networks are classified based on their infrastructure requirements and communication patterns:

Infrastructure-Based Networks
Single-hop Infrastructure
Multi-hop Infrastructure
Ad Hoc Networks
Infrastructure-free Communication

Key characteristics:

Remember: Infrastructure mode = centralized control, Ad hoc = peer-to-peer communication.

2. Physical Layer

2.1 Transmission Media (Guided, Unguided)

Physical Layer

The Physical Layer operates at the lowest level of the OSI model, handling the actual transmission of raw bits across physical media.

Primary Functions:

Key Specifications:

Signal Characteristics:

Physical Media Examples:

Note: The Physical Layer doesn't understand data meaning - it only knows how to push bits from one end to another. Error detection and correction happen at higher layers.

3. Data Link Layer

3.1 Framing

Data Link Layer

The Data Link Layer (Layer 2) manages reliable transmission of data frames between directly connected nodes.

Primary Functions:

Key Responsibilities:

Frame Structure:

Header + Data Payload + Trailer

HeaderMAC + controlData Payloadactual dataTrailerCRC
This diagram shows the structure of a data link layer frame as three boxes in a row. The first box is the Header, which carries the source and destination MAC addresses and control information. The middle box is the Data Payload, which is the actual data being sent. The last box is the Trailer, which typically carries error detection codes such as CRC. The takeaway is that the layer wraps the data with a header at the front and a trailer at the end before sending it to the next directly connected device.

The header contains source/destination MAC addresses and control information. The trailer typically includes error detection codes like CRC. Example: When your computer sends data to a router, the Data Link Layer adds Ethernet headers with MAC addresses, ensuring the frame reaches the correct device on the local network segment. Note: This layer only handles hop-to-hop delivery - getting data from one directly connected device to the next. End-to-end delivery across multiple hops is handled by higher layers.

Framing and Error Detection

The data link layer handles frame transmission through three key steps:

Frame Creation

Break the continuous bit stream from the network layer into discrete frames. Each frame contains:

Error Detection

Compute error-detection codes for each frame using methods like:

Frame Transmission

Send each frame individually across the physical medium. The receiving end:

Example: Ethernet frame structure

Remember: Framing solves the fundamental problem of where one message ends and another begins in a continuous bit stream.

Ethernet (IEEE 802.3)

Ethernet (IEEE 802.3) is a widely used LAN technology that defines both physical and data link layer specifications.

Key Characteristics:

Frame Structure

Ethernet frames follow a standardized format for data transmission:

FieldPreambleSFDDA SA Length/Type Data CRC
Size (bytes)716 6 2 46-1500 4
Content1010...10 shown as "1010...10"10101011
Preamble7 bytesSFD1 byteDA6 bytesSA6 bytesLength/Type2 bytesData46-1500 bytesCRC4 bytes
This diagram shows the layout of an Ethernet frame, read from left to right. It begins with the Preamble, 7 bytes of alternating 1s and 0s that let the receiver synchronize its clock. Next is the Start Frame Delimiter, 1 byte with the pattern 10101011, which marks where the frame actually begins. Then come the Destination MAC address and the Source MAC address, 6 bytes each. After that is a 2-byte Length or Type field, then the Data payload of 46 to 1500 bytes, and finally a 4-byte CRC at the end for error detection. The takeaway is that an Ethernet frame has a fixed order: synchronization first, then who it is for, who it is from, how much data follows, the data itself, and a check code last.

Field descriptions:

Frame Size Limits

Minimum frame size: 64 bytes total

6 + 6 + 2 + 46 + 4 = 64 bytes

Maximum frame size: 1518 bytes total

6 + 6 + 2 + 1500 + 4 = 1518 bytes

The minimum ensures collision detection works properly across maximum cable length.

CSMA/CD Performance

Collision detection timing: Maximum collision detection time equals twice the propagation delay across the network.

Slot time = 2 × Propagation delay

Network utilization depends on the ratio of transmission time to propagation delay:

η = 1 / (1 + 5.44a)

where a = Propagation delay / Transmission delay = (d/v) / (L/B)

Key insight: Longer frames improve efficiency by reducing the relative impact of collision overhead.

Collision Handling

When n stations compete for access, the probability that exactly one station successfully transmits is:

P_success = nP(1 - P)^(n-1)

where P is the probability that any given station attempts transmission. Contention period: Average time spent resolving collisions before successful transmission:

Contention period = x × 2 × (d/v)

where x = e (≈ 2.718) represents the expected number of collision slots. Note: Modern Ethernet uses switches and full-duplex operation, eliminating collisions in most deployments. CSMA/CD remains relevant for understanding shared medium behavior and legacy installations.

ARP (Address Resolution Protocol)

Address Resolution Protocol (ARP) maps IP addresses to MAC addresses when devices need to communicate on the same network.

ARP Process

When ARP is needed: A device knows the destination IP address but needs the corresponding MAC address to send frames at the data link layer. ARP Request: Broadcast message containing:

ARP Reply: Unicast response containing:

ARP Caching

Devices store ARP mappings in cache memory for 20-30 minutes to avoid repeated requests for frequently contacted destinations. Cache lookup: Before sending an ARP request, the system first checks its local ARP cache for existing mappings. Benefits: Reduces network traffic since multiple packets to the same destination don't require separate ARP requests.

ARP Encapsulation

ARP packets are encapsulated directly into Ethernet frames with a special type field indicating ARP content (no IP header needed).

ARP Use Cases
  1. Host-to-host (same network): Direct communication between devices on the same subnet
  2. Host-to-host (different networks): Host needs MAC address of default gateway router
  3. Router forwarding: Router needs MAC address of next-hop router from routing table
  4. Router-to-host: Router delivering packet to final destination on directly connected network
Reverse ARP (RARP)

Purpose: Discovers IP address when only MAC address is known (typically for diskless workstations). Process:

Limitation: RARP broadcasts don't cross network boundaries, requiring a RARP server on every subnet. This scalability issue led to RARP being largely replaced by DHCP. Remember: ARP goes from logical (IP) to physical (MAC), while RARP goes from physical (MAC) to logical (IP).

3.2 Stop-and-Wait ARQ

Stop and Wait ARQ

Stop and Wait ARQ sends only one frame at a time, waiting for acknowledgment before transmitting the next frame. This leads to poor link utilization.

Efficiency Formula:

η = 1 / (1 + 2a)

where a = T_propagation / T_transmission is the ratio of propagation delay to transmission time. Derivation:

Key Characteristics:

Performance Impact: When a is large (long distance or high bandwidth), efficiency drops significantly. For satellite links where a is very large , efficiency can be less than 1%. Example: If propagation delay = 10ms and transmission time = 1ms, then a = 10 and η = 1/21 ≈ 4.7% Remember: Stop and Wait is simple but inefficient for high bandwidth-delay product networks.

3.3 Go-Back-N ARQ

Go-Back-N (GBN) ARQ

Go-Back-N (GBN) is a sliding window ARQ protocol where the receiver accepts frames only in order.

Window Sizes:

Efficiency Formula:

Efficiency = (2^k - 1) / (1 + 2a)

where:

Key Constraints:

Protocol Characteristics:

Operation:

  1. Sender transmits frames within window
  2. On timeout/NAK, retransmits from error point onwards
  3. Receiver accepts only in-sequence frames, discards others
  4. ACK confirms highest correctly received frame

Note: Called "conservative" because receiver doesn't buffer out-of-order frames, requiring retransmission of correctly received but out-of-sequence data.

3.4 Selective Repeat ARQ

Selective Repeat (SR)

Selective Repeat (SR) is a sliding window protocol that allows out-of-order packet acceptance for better efficiency.

Window Sizes:

W_S = W_R = N / 2

where N is the maximum sequence number space (2^k for k-bit sequence numbers). Both sender and receiver maintain equal window sizes to prevent sequence number confusion.

Key Features:

Efficiency Formula:

Efficiency = 2^(k-1) × (T_trans / (T_trans + RTT))

This accounts for the maximum usable window size and the ratio of transmission time to total round trip cycle.

Throughput with Piggybacking:

Throughput = (2 × Packet Size) / RTT

Bidirectional communication doubles effective throughput compared to simplex transmission.

Timing Parameters:

Example: With 3-bit sequence numbers (k = 3), N = 8, so W_S = W_R = 4. This prevents the receiver from confusing new packets with retransmissions.

3.5 Sliding Window Protocol

Flow Control

Flow control manages the rate of data transmission between sender and receiver to prevent buffer overflow and ensure reliable communication. Purpose: Prevents fast senders from overwhelming slow receivers by regulating transmission speed.

Two Main Approaches:

1. Stop-and-Wait Protocol
2. Sliding Window Protocol (SWP)

Key difference: Stop-and-wait sends one frame at a time, while sliding window allows multiple outstanding frames, improving channel utilization. Note: Flow control is separate from error control, though they're often implemented together in protocols like ARQ (Automatic Repeat Request).

4. MAC Sublayer

4.1 CSMA/CA

Wireless IEEE 802.11

Wireless Network Components

A wireless network consists of three key elements that enable mobile communication:

Wireless Hosts

Mobile devices (laptops, smartphones, tablets) that run applications and need network connectivity. Unlike wired networks where hosts connect via cables, wireless hosts communicate through radio signals.

Wireless Links

Radio communication channels that connect wireless hosts to the network infrastructure. Two connection types:

Base Station

Central coordination point that manages wireless communication in a coverage area. Functions include:

Example: In IEEE 802.11 networks, the base station is called an Access Point (AP). When your laptop connects to WiFi, it associates with an AP that bridges your wireless traffic to the wired network infrastructure. Remember: Base stations act as translators between the wireless and wired worlds, handling the complexity of radio communication while presenting a standard network interface.

Two Types of Mode

Infrastructure Mode: All network services are provided through a centralized base station (access point). Mobile devices connect to the network infrastructure via this base station, which handles routing, security, and network management. Ad Hoc Mode: Devices communicate directly with each other without requiring a central access point. Each device acts as both client and router, forming a peer-to-peer network.

ModeConnection
InfrastructureVia base station
Ad HocDirect device-to-device

Key Difference: Infrastructure mode requires existing network infrastructure, while ad hoc mode creates temporary networks between devices. Note: Most WiFi networks operate in infrastructure mode for better security and management control.

Types of Adhoc Mode

Ad Hoc Network Modes

Wireless networks can operate without infrastructure in two configurations:

Single-hop, Infrastructure-less: Direct communication between wireless devices without any base station or access point. All nodes communicate directly within transmission range.

Multi-hop, Infrastructure-less: Nodes relay messages through intermediate devices to reach destinations beyond direct transmission range. No central infrastructure required.

Basic Service Set (BSS)

A BSS consists of wireless stations connected through a central access point (AP). Each wireless station and AP has a unique 6-byte MAC address for identification.

IEEE 802.11 Frequency Bands

StandardFrequency BandNon-overlapping Channels
802.11b2.4 GHz ISM3
802.11g2.4 GHz ISM3
802.11a5 GHz ISM23
802.11n2.4 or 5 GHzVaries by channel width
802.11ac5 GHz only25

WiFi Jungle: Location where a wireless device receives strong signals from multiple APs simultaneously, requiring selection of the best connection.

AP Discovery Methods

Passive Scanning

  1. APs broadcast beacon frames periodically
  2. Host sends association request to selected AP
  3. Selected AP responds with association response

Active Scanning

  1. Host broadcasts probe request frame
  2. All APs in range send probe response frames
  3. Host sends association request to chosen AP
  4. Selected AP responds with association response

Active scanning provides faster discovery but consumes more bandwidth.

802.11 MAC Protocol Features

Collision Avoidance: Uses CSMA/CA instead of collision detection due to wireless medium limitations.

Link-layer ARQ: Implements acknowledgment and retransmission scheme to handle high bit error rates in wireless channels.

Timing Intervals:

Binary Exponential Backoff: Doubles contention window after each collision to reduce network congestion.

Hidden Terminal Solution: RTS (Request to Send) and CTS (Clear to Send) frames prevent collisions from hidden nodes.

802.11 Frame Structure

FieldSizePurpose
Frame Control2 bytesProtocol version, type, and control information
Duration2 bytesChannel reservation time
Address 1-46 bytes eachSource, destination, transmitter, and receiver addresses
Sequence Control2 bytesFragment and sequence numbering
Frame Body0-2312 bytesActual data / payload
FCS4 bytesFrame check sequence for error detection

Frame Control Subfields

FieldBitsFunction
Protocol Version2802.11 version
Type2Management, Control, or Data
Subtype4Specific frame function
To/From DS1 eachDistribution system direction
More Fragments1Additional fragments follow
Retry1Retransmitted frame
Power Management1Station power save mode
More Data1Additional data buffered
WEP1Encryption enabled
Order 1Strict ordering / reserved for future use

4 / Token Ring

Token Ring (IEEE 802.5)

Token Ring (IEEE 802.5) is a deterministic LAN technology using ring topology and token passing for media access control.

Key Characteristics

Token Holding Time (THT)

Maximum time a station can hold the token before releasing it.

Monitor Station

The station with highest MAC address that generates and manages the token.

Responsibilities:

Timing Parameters:

Min TRT = Propagation delay + (Stations x Station delay)

Max TRT = Propagation delay + (Stations x THT)

where TRT = Token Rotation Time

Data Rates and Ring Length

Data RateMinimum Ring Length
4 Mbps1200 meters
16 Mbps300 meters

Higher speeds require shorter rings to maintain signal integrity.

Frame Formats

Data Frame Structure

FieldSDACFCDA
Bytes1112-6
SD1 byteAC1 byteFC1 byteDA2-6 bytesSA2-6 bytesDATAvariableFCS4 bytesED1 byteFS1 byte
Diagram of the Token Ring data frame format, read from left to right. A data frame is a row of fields in a fixed order. First comes SD, the Starting Delimiter, 1 byte, which marks the start of the frame. Next is AC, Access Control, 1 byte, which carries priority and the token bit. Next is FC, Frame Control, 1 byte, which says what type of frame this is. Next is DA, the Destination Address, 2 to 6 bytes. After that come the Source Address, the actual data, the Frame Check Sequence for error checking, the Ending Delimiter, and finally Frame Status, which reports whether the destination recognised and copied the frame. The takeaway is that every Token Ring data frame follows this exact field order, starting with the Starting Delimiter and ending with Frame Status.

Key Fields:

Frame Status Interpretation

A (Address)C (Copied)Meaning
00Destination not present
01Invalid combination
10Destination present, frame not copied
11Destination present, frame copied

Token Frame

FieldSDACED
Bytes111
SD1 byteAC1 byteED1 byte
Diagram of the Token Ring token frame, read from left to right. A token frame is only 3 bytes long and has just three fields. First, SD, the Starting Delimiter, 1 byte. Second, AC, Access Control, 1 byte, whose token bit is set to 0 to show this is a free token and not a data frame. Third, ED, the Ending Delimiter, 1 byte. The takeaway is that a token is the smallest frame on the ring: whichever station captures this 3-byte token gains the right to transmit.

Abort Frame

FieldSDED
Bytes11
SD1 byteED1 byte
Diagram of the Token Ring abort frame, read from left to right. An abort frame is only 2 bytes and has just two fields: SD, the Starting Delimiter, 1 byte, followed immediately by ED, the Ending Delimiter, 1 byte. There is no address, no control information and no data. The takeaway is that a station uses this minimal frame to abort a transmission already in progress.

Ring Latency

Time for a bit to complete one ring traversal:

RL = d/v + Mb/R (seconds) = dR/v + Mb (bits)

where:

Performance Metrics

Data Transfer Rate:

Rate = F / (t_l + t_o + F/B)

where F = Frame length, B = bandwidth, t_l = ring latency, t_o = token observation time

Link Length in Bits:

Link bits = R x (d/v)

Utilization:

U = 1 / (1 + a/N), if a < 1; U = 1 / (a(1 + 1/N)), if a > 1

where a = normalized propagation delay, N = number of stations

Control Frame Types

Control frames use 6-bit type field in Frame Control:

Token Reinsertion Strategies

AspectDelay Token Reinsertion (DTR)
Token ReleaseAfter receiving entire transmitted frame
EfficiencyLower - one frame on ring at a time
ReliabilityHigher - THT enforced (10ms)
UsageLight load conditions
Cycle Timea x b + c x d formula shown as symbol glyphs

where: a = transmission time, b = ring latency, c = token transmission time, d = inter-station delay

Note: ETR allows better ring utilization but requires careful flow control to prevent congestion.

5. Network Layer

5.1 IPv4 Addressing

Network Layer

The Network Layer (Layer 3) handles logical addressing and routing between different networks.

Primary Functions:

Key Responsibilities:

Address Translation:

Converts logical addresses (IP addresses) to physical addresses (MAC addresses) using protocols like ARP (Address Resolution Protocol).

Example: When sending data from 192.168.1.10 to 203.0.113.89 :

  1. Network layer determines routing path through intermediate routers
  2. Each router forwards packet based on destination IP
  3. Final router delivers packet to destination network

Abstraction: Shields upper layers from physical network details - applications don't need to know the actual path data takes through the internet.

Note: This layer enables internetworking - connecting different types of networks (Ethernet, Wi-Fi, etc.) into one logical network.

IP Address

IP addresses provide globally unique identification for devices on the internet. Each device needs a distinct address to enable proper routing and communication across networks.

IP Versions

The Internet Protocol has evolved through two main versions:

IPv4 (Internet Protocol version 4)

IPv6 (Internet Protocol version 6)

IPv4 Addressing Methods

IPv4 addressing has evolved from simple class-based systems to flexible routing schemes:

Classful Addressing

Traditional method dividing addresses into fixed classes:

Limitation: Wasteful allocation - many addresses remained unused within assigned classes.

Classless Inter-Domain Routing (CIDR)

Modern approach allowing flexible network size allocation:

CIDR Techniques

Subnetting

Dividing a large network into smaller subnetworks:

Example: Network 192.168.1.0/24 can be split into:

Supernetting

Combining multiple smaller networks into one larger network:

Example: Networks 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, 192.168.3.0/24 can be summarized as 192.168.0.0/22

Remember: CIDR enables efficient address allocation by removing the constraints of traditional class boundaries.

IPv4 Address

IPv4 addresses use a 32-bit format divided into four 8-bit octets (e.g., 192.168.1.1) for better readability. Each address contains two parts: Network ID (identifies the network) and Host ID (identifies the specific device).

Classful Addressing

IPv4 addresses are categorized into classes based on their first octet value:

ClassRangeBinary PatternPurpose
A0-1270xxxxxxxLarge networks
B128-19110xxxxxxMedium networks
C192-223110xxxxxSmall networks
D224-2391110xxxxMulticast
E240-2551111xxxxExperimental / reserved

Read as: Class determines how many octets are used for Network ID vs Host ID identification.

Address Calculations

Class A: 7 network bits, 24 host bits

Class B: 14 network bits, 16 host bits

Class C: 21 network bits, 8 host bits

Note: Subtract 2 from host count because all-zeroes (network address) and all-ones (broadcast address) are reserved.

Special Purpose Addresses

Network Address: Host bits set to 0, identifies the network itself.

Example: 192.168.1.0 for network 192.168.1.0/24

Broadcast Address: Host bits set to 1, sends packets to all devices in the network.

Example: 192.168.1.255 for network 192.168.1.0/24

Loopback (127.0.0.x): Tests local TCP/IP stack and enables inter-process communication. Range 127.0.0.0 to 127.255.255.254 (excluding network and broadcast addresses)

Default Route (0.0.0.0): Used in routing tables when destination network is unknown. Forwards packets to a default gateway.

Direct Broadcast: Sends packets to all hosts in a remote network.

Limited Broadcast (255.255.255.255): Sends packets to all hosts in the local network only.

Private Address Ranges

These addresses are not routable on the Internet, only within private networks:

Router Deployment Rules

  1. Different Networks: Each router interface must belong to a different network
  2. LAN Separation: Interconnected LANs must use different network addresses
  3. Interface Matching: Router's ethernet interface and connected LAN must share the same network
  4. Shared Links: Routers on the same physical link must belong to the same network

Subnetting vs Supernetting

AspectSubnettingSupernetting
PurposeDivide one network into smaller subnetworks Combine multiple networks into one larger network
Bit BorrowingFrom host bitsFrom network bits
ApplicationSingle large networkMultiple small networks
Subnet MaskMore 1s than default mask Fewer 1s than default mask
Routing ImpactIncreases table entries Decreases table entries
Network RequirementOne networkMultiple networks

Remember: Classful addressing has limitations including inflexibility, no built-in security, and addresses not permanently tied to systems. Modern solutions include CIDR (Supernetting), VLSM (Subnetting), and NAT.

5.2 IPv4 Header Format

IPv4

IPv4 is a best-effort, connectionless network protocol. Packets are delivered without guarantees of delivery, order, or error correction.

IP Datagram Structure

An IP datagram consists of:

IPv4 Header Format

FieldSizeFieldSize
Version4 bitsHeader Length (IHL) 4 bits
Type of Service8 bitsTotal Length 16 bits
Identification16 bitsFlags 3 bits
Fragment Offset13 bitsTTL 8 bits
Protocol8 bitsHeader Checksum 16 bits
Source IP Address32 bits
Destination IP Address32 bits
Options + PaddingVariable
Version4 bitsHeader Length4 bitsType of Service8 bitsTotal Length16 bitsIdentification16 bitsFlags3 bitsFragment Offset13 bitsTTL8 bitsProtocol8 bitsHeader Checksum16 bitsSource IP Address32 bitsDestination IP Address32 bitsOptions + Paddingvariable
Diagram of the IPv4 header format, read in reading order, field by field. The header starts with Version, 4 bits, which is always 4 for IPv4, and Header Length, 4 bits, which gives the header size in 32-bit words. Then Type of Service, 8 bits, and Total Length, 16 bits, the length of the whole datagram. Then Identification, 16 bits, used to group fragments of one packet, Flags, 3 bits, which control fragmentation, and Fragment Offset, 13 bits, which gives a fragment's position in the original packet. Then TTL, Time To Live, 8 bits, the maximum number of hops before the packet is discarded, Protocol, 8 bits, which names the next layer protocol, such as TCP or UDP, and Header Checksum, 16 bits. Finally come the Source IP Address, 32 bits, the Destination IP Address, 32 bits, and the optional Options and Padding field of variable size. The takeaway is that the fixed part of the IPv4 header is 20 bytes, growing to at most 60 bytes when options are present.

Key Fields:

IPv6 Header Format

FieldSize
Version4 bits
Traffic Class8 bits
Flow Label20 bits
Payload Length16 bits
Next Header8 bits
Hop Limit8 bits
Source Address 128 bits
Destination Address 128 bits
Version · 4 bitsTraffic Class · 8 bitsFlow Label · 20 bitsPayload Length · 16 bitsNext Header · 8 bitsHop Limit · 8 bitsSource Address · 128 bitsDestination Address · 128 bits
Diagram of the IPv6 header format, read in order from top to bottom. Version, 4 bits, which is 6 for IPv6. Traffic Class, 8 bits, used for priority and quality of service. Flow Label, 20 bits, which identifies a flow of packets. Payload Length, 16 bits. Next Header, 8 bits, which names the header or protocol that follows. Hop Limit, 8 bits, the IPv6 equivalent of TTL. Then the Source Address, 128 bits, and the Destination Address, 128 bits. The takeaway, stated in the note right after this table, is the simplified design: a fixed 40-byte header, no fragmentation at routers, and no checksum, which makes IPv6 headers faster for routers to process than IPv4 headers.

Simplified Design: Fixed 40-byte header, no fragmentation at routers, no checksum

Header Length Encoding

IPv4 Header Length Field:

Example: 24-byte header -> Header Length = 6 -> Receiver calculates 6 x 4 = 24 bytes

Fragmentation Rules

When a packet exceeds Maximum Transmission Unit (MTU):

Example: 1500-byte packet fragmented into 800 + 700 bytes:

Remember: The constant factor 8 ensures efficient reassembly at the destination.

Options

IPv4 headers contain an optional variable section (0-40 bytes) after the fixed 20-byte header. These options enable network testing, debugging, and specialised routing control.

Common Option Types

End of Option (Type 0)

No Operation (Type 1)

Record Route (Type 7)

Strict Source Route (Type 9)

Loose Source Route (Type 3)

Timestamp (Type 4)

Note: Options increase header size and processing overhead. Most modern networks rely on other protocols (MPLS, SDN) for advanced routing control.

5.2 IPv6 Basics section number

IPv6

IPv6 uses a modular packet structure with a fixed header followed by optional extension headers.

IPv6 Packet Structure Fixed Header: Always 40 bytes (compared to IPv4's variable 20-60 bytes) Extension Headers: Optional, variable-length headers that provide additional functionality

Payload: Extension headers + upper layer protocol data unit

Next Header Field Values The Next Header field identifies what follows the current header:

ValueProtocol/Header
0Hop-by-Hop Options
6TCP
44Fragment Header
50Encapsulating Security Payload
51Authentication Header
58ICMPv6
59No Next Header
60Destination Options

Goal: an Next Header value indicates the type of header or protocol that follows.

Required Extension Headers All IPv6 implementations must support:

Alignment rule: Extension headers must align on 8-byte boundaries. Variable-length headers include padding to ensure proper alignment.

Recommended Header Order When multiple extension headers are present:

  1. Hop-by-Hop Options
  2. Destination Options (for intermediate nodes)
  3. Routing Header
  4. Fragment Header
  5. Authentication Header
  6. Encapsulating Security Payload
  7. Destination Options (for final destination)

IPv6 Fragmentation When a packet exceeds the path MTU, it splits into two parts:

Unfragmentable Part (processed by intermediate routers):

Fragmentable Part (processed only at destination):

Note: Only the source node can fragment IPv6 packets. Routers cannot fragment, unlike IPv4.

5.4 ICMP Protocol section number

Internet Control Messaging Protocol (ICMP)

ICMP (Internet Control Message Protocol) handles error reporting and network diagnostics. It operates at the network layer alongside IP.

Encapsulation: ICMP messages are wrapped inside IP datagrams with protocol field = 1 Transport: ICMP operates directly over IP, not through TCP/UDP. The ping utility uses ICMP Echo messages.

Message Types

Error Reporting Messages:

Query Messages:

Example: When you ping 192.168.1.1 IP address, your host sends ICMP Echo Request. If reachable, target responds with Echo Reply containing same data.

Note: ICMP errors are never generated for ICMP error messages themselves, preventing infinite loops.

6. Routing Algorithms

6.1 Distance Vector Routing

Routing Algorithms

Routing algorithms determine how packets travel through networks. Each algorithm has specific use cases and trade-offs.

Basic Routing Types

Flooding: Every incoming packet is forwarded to all outgoing interfaces except the arrival interface. Simple but inefficient due to packet duplication.

Broadcast Routing: Sends packets from one host to all other hosts simultaneously. Methods include:

Multicast Routing: Delivers packets to specific host groups rather than all hosts. Uses:

Dynamic Routing Protocol Classification Dynamic routing protocols are organized into two main categories:

Interior Gateway Protocols (IGP) - operate within a single autonomous system:

Exterior Gateway Protocols (EGP) - operate between autonomous systems:

Distance Vector Routing

Routers share routing information only with direct neighbors but maintain knowledge about the entire network. Each router knows the distance and direction to reach destinations.

Key protocols: RIP, IGRP Technique used: Split horizon to prevent routing loops

Common problems:

Solutions:

Link State Routing (OSPF)

Uses Dijkstra's algorithm to build complete network topology. Each router:

  1. Discovers all neighbors and their network addresses
  2. Measures cost to reach each neighbor
  3. Floods link state information to all routers
  4. Builds shortest path tree

OSPF link types:

Path Vector Routing (BGP)

Designed for interdomain routing between autonomous systems. Maintains the complete path (list of autonomous systems) to reach each destination network.

Advantage: Path information prevents routing loops between autonomous systems Use case: Internet backbone routing

Hierarchical Routing

Organizes networks into regions to reduce routing table size and complexity.

Two routing tables maintained:

Benefits: Scales better for large networks by reducing routing overhead.

RIP Protocol Details

Example: If destination requires 8 router hops, RIP metric = 8. If any path exceeds 15 hops, destination is considered unreachable.

7. Transport Layer

The Transport Layer manages reliable data transmission between applications across a network.

Core Functions:

Key Mechanisms:

Reliable Delivery: Ensures all data arrives correctly through acknowledgment and retransmission protocols. Flow Control: Prevents fast senders from overwhelming slow receivers by controlling transmission windows. Error Handling: Detects transmission errors and coordinates recovery without involving upper layers. Connection Management: Establishes, maintains, and terminates communication sessions between applications.

Note: The Transport Layer abstracts network complexities, providing applications with a reliable communication interface regardless of underlying network conditions.

Transmission Control Protocol

TCP is a reliable, connection-oriented transport layer protocol that provides byte-stream delivery between application ports. It guarantees data delivery through acknowledgments and retransmission.

Key Characteristics:

TCP Connection Lifecycle

  1. Connection Establishment - Three-way handshake
  2. Data Transmission - Reliable data transfer with flow control
  3. Connection Termination - Four-way handshake to close connection

TCP Header Structure

FieldSize (bits)Function
Source Port16Identifies the sending port
Destination Port16Identifies the receiving port
Sequence Number32Sequence number of the first data byte in this segment
Acknowledgment Number32Next sequence number the sender expects to receive
Header Length4Length of the TCP header
Reserved6Reserved for future use, must be zero
Control Flags6URG, ACK, PSH, RST, SYN, FIN control bits
Window Size16Size of the receive window
Checksum16Error-checking of header and data
Urgent Pointer16Points to urgent data
OptionsVariableOptional additional fields

Control Flags:

Sequence Numbers TCP uses 32-bit sequence numbers starting from a random initial value for security. When all 2^32 numbers are used, they wrap around and repeat. Collision probability for initial sequence number: 1 / 2^32 = 2.33 x 10^-10 formula

Common TCP Applications

ProtocolPortPurpose
HTTP80Web browsing
FTP Control21File transfer command
Telnet23Remote terminal access
SMTP25Email sending
POP3110 port numberEmail retrieval

Remember: TCP's reliability comes at the cost of overhead - use UDP when speed matters more than guaranteed delivery.

7.2 TCP Congestion Control section number

Congestion Control

Congestion control manages network traffic to prevent or resolve congestion through proactive and reactive mechanisms.

Open-Loop Congestion Control Prevents congestion before it occurs through policies applied at source or destination.

Retransmission Policy

Window Policy

Acknowledgment Policy

Discarding Policy

Admission Policy

Closed-Loop Congestion Control Alleviates congestion after detection through feedback mechanisms.

Backpressure

Choke Packet

Implicit Signaling

Explicit Signaling

Traffic Shaping Converts bursty input traffic into regulated, smooth output flow.

Leaky Bucket Algorithm

Token Bucket Algorithm

C + ρt = Mt formula

where:

TCP Congestion Control

Slow Start and Additive Increase

Multiplicative Decrease

TCP Error Control Uses three mechanisms for reliable data transfer:

Checksum

Acknowledgments

Timeouts

Pseudoheader Purpose

TCP State Transition State diagram represents connection lifecycle phases:

Limitations:

Sockets Software abstraction representing communication endpoints between networked machines.

Key Characteristics:

Communication Process:

  1. Both processes create sockets
  2. Server socket enters listening state
  3. Client attempts connection to server
  4. Bidirectional communication established

Remember: Sockets provide the programming interface between applications and the transport layer protocols.

7.3 UDP Protocol section number

User Datagram Protocol

User Datagram Protocol (UDP) is a connectionless transport protocol that prioritizes speed over reliability.

Key Characteristics:

UDP vs TCP UDP uses an iterative approach compared to TCP's concurrent model:

Common Use Cases Real-time applications where speed matters more than perfect delivery:

Bulk data transfer applications prioritizing speed:

Header Structure UDP has a simple 8-byte header:

Source Port16 bitsDestination Port16 bitsLength16 bitsChecksum16 bitsDatapayload
This diagram shows the layout of the UDP header, which is only 8 bytes long. Reading from the top left, the first field is the Source Port, 16 bits. Next to it on the right is the Destination Port, also 16 bits. On the second row, the left field is Length, 16 bits, and on the right is the Checksum, 16 bits. Below the header fields sits the Data, the payload carried by the UDP packet. The takeaway is that UDP has just four header fields, two ports, a length and a checksum, which is why it is so much simpler and faster than TCP.

Fields explained:

Pseudoheader for Checksum UDP uses the same pseudo-header concept as TCP for checksum calculation:

This ensures the packet reached the correct destination.

Protocols Using UDP

ProtocolPortPurpose
DNS53Domain name resolution
TFTP69Trivial file transfer
SNMP161Network management
RIP520Routing information
NFS2049Network File System

Note: ICMP (ping) operates at the network layer, not transport layer, so it doesn't use UDP port any UDP port.

8. Application Layer

8.1 DNS (Domain Name System)

BOOTP (Bootstrap Protocol)

BOOTP (Bootstrap Protocol) enables network devices to obtain their IP configuration during startup.

Purpose: Maps physical addresses (MAC) to logical addresses (IP) for diskless workstations and network devices that need initial configuration.

Key Characteristics:

Message Flow:

  1. Client broadcasts BOOTP request using:
  1. Server responds with client's assigned IP configuration
  2. Messages encapsulated as: BOOTP -> UDP -> IP

Cross-Network Operation:

Since broadcast packets cannot traverse routers, BOOTP uses relay agents:

Clientbroadcasts requestRelay Agentbroadcast to unicastBOOTP Serverreplies via relay
This diagram explains how BOOTP works across different networks. A client that has just started up broadcasts a BOOTP request on its own local network, because it does not yet have an IP configuration. Broadcast packets cannot cross routers, so a relay agent on the local network picks up the broadcast, converts it into a unicast message, and forwards it to a central BOOTP server on another network. The server sends its response back to the relay agent, and the relay agent passes that response on to the requesting client. The takeaway is that the relay agent is the bridge that lets one central BOOTP server serve clients on many different network segments.

Advantage over RARP:

RARP (Reverse ARP) requires a server on each network segment because ARP broadcasts don't cross routers. BOOTP's relay mechanism allows centralized servers to serve multiple network segments.

Example Scenario:

Diskless workstation boots up -> broadcasts BOOTP request -> relay agent forwards to central BOOTP server -> server provides IP, subnet mask, gateway, and boot file location.

Remember: BOOTP provides static mappings configured by administrators, unlike DHCP's dynamic allocation.

DHCP (Dynamic Host Configuration Protocol)

DHCP (Dynamic Host Configuration Protocol) automates IP address assignment in networks, supporting both static and dynamic allocation methods.

Address Allocation Types

Static Allocation

Dynamic Allocation

Dynamic Features

Lease System:

DHCP uses a lease mechanism for temporary address assignment:

Use Cases for Dynamic Assignment:

Advantages Over BOOTP

FeatureBOOTPDHCP
ConfigurationManual onlyManual and automatic
Address TypeStatic onlyStatic and dynamic
Lease ManagementNoneBuilt-in

Key Improvement: DHCP eliminates the need for manual IP-to-MAC address mapping that BOOTP requires, enabling automatic network configuration.

Remember: DHCP = BOOTP + dynamic allocation + automatic configuration

Domain Name System (DNS)

DNS (Domain Name System) translates human-readable domain names into IP addresses, enabling users to access websites using memorable names instead of numeric addresses.

Primary Functions:

Transport Protocols:

DNS Server Hierarchy:

  1. Root Servers - Top level servers that direct queries to appropriate TLD servers
  2. Top-Level Domain (TLD) Servers - Handle domains like .com, .org, .edu
  3. Authoritative Servers - Store actual DNS records for specific domains
  4. Local DNS Servers - ISP servers that cache responses and forward queries

Core Services:

Query Process Example:

User types "example.com" -> Local DNS checks cache -> Queries root server -> Directed to .com TLD server -> Directed to authoritative server -> Returns IP address

Usertypes example.comLocal DNSchecks cacheRoot Serverrefers to TLD.com TLD Serverrefers onwardAuthoritativeServerholds recordsIP Addressreturned
This diagram walks through a DNS lookup step by step, from left to right. It starts when a user types a domain name, example.com, into their browser. First, the local DNS server checks its own cache to see if it already knows the answer. If it does not, it queries a root server. The root server directs it to the TLD server for dot com. That TLD server directs it onward to the authoritative server that holds the actual records for the domain. Finally, the IP address for example.com is returned to the user. The takeaway is that DNS resolution is a chain of referrals down a hierarchy, root first, then top-level domain, then authoritative, until the exact IP address is found.

Remember: DNS uses distributed storage across multiple servers to ensure reliability and reduce single points of failure.

HTTP Protocol

Application Layer

The Application Layer is the topmost layer of the OSI model that provides network services directly to end-user applications.

Purpose:

Key Functions:

Common Application Layer Protocols

Web and File Services:

Email and Messaging:

Read as: Each layer handles specific types of protocols for different network functions.

LayerPrimary Protocols
ApplicationHTTP, FTP, SMTP, DNS, DHCP
PresentationTLS, SSL, MIME, XDR
SessionNetBIOS, L2TP, PPTP
TransportTCP, UDP, SCTP
NetworkIP, ICMP, IGMP
Data LinkEthernet 802.3, PPP, Frame Relay
PhysicalEthernet, Wi-Fi 802.11, Bluetooth

Remember: Application layer protocols are what users directly interact with - if you can name the service (like "web browsing" or "email"), it likely uses an application layer protocol.

Hyper Text Transfer Protocol (HTTP)

HTTP (Hyper Text Transfer Protocol) is an application layer protocol that enables web communication between clients and servers.

Basic Properties:

Security: HTTPS uses SSL/TLS encryption to secure HTTP communication over port 443.

Primary Function: Retrieval and transfer of web resources (HTML pages, images, files) from web servers.

HTTP Methods:

Connection Types:

TypeBehavior
Non-PersistentNew TCP connection per request
PersistentSingle TCP connection for multiple requests

Non-Persistent: Client opens new TCP connection for each HTTP request, then closes it after receiving response.

Persistent: Client maintains one TCP connection and sends multiple requests through it, reducing connection establishment overhead.

Note: Modern browsers default to persistent connections (HTTP/1.1) for better performance.

FTP (File Transfer Protocol)

File Transfer Protocol (FTP)

File Transfer Protocol (FTP) operates over TCP using two separate connections:

Data Connection: Port 20 | Control Connection: Port 21

Control connection handles commands and responses, while data connection transfers actual files.

Status and Error Codes:

FTP uses standardized response codes:

Operation Modes

Active Mode: Server initiates data connection back to client

Passive Mode: Client initiates both connections

Extended Passive Mode: Enhanced version of passive mode

Access Modes:

ASCII Mode: For text files

Binary Mode: For non-text files

Note: Wrong mode selection can corrupt files during transfer.

Two Modes of Access

FTP vs TFTP Comparison

FeatureFTPTFTP
User AccessAuthorized users only
AuthenticationUsername and password none
OperationsFull upload and download simple upload and download only
Transport ProtocolTCP (ports 20, 21)UDP (port 69)
SecurityMore secure with authentication less secure, no authentication
ReliabilityReliable delivery via TCPno reliable delivery, runs over UDP

FTP (File Transfer Protocol)

TFTP (Trivial File Transfer Protocol)

Use Cases:

SMTP (Email Protocol)

Presentation

The Presentation Layer (Layer 6) handles data format translation and standardization across different systems.

Primary Function: Converts data between application-specific formats and standardized network formats that all OSI layers can process.

Key Responsibilities:

Why it Matters: Different systems use different data formats (Windows vs Unix, Intel vs ARM processors). The presentation layer ensures a file created on one system can be properly interpreted on another.

Example: When sending an email with an image attachment:

Remember: Think of it as a universal translator that makes sure data "looks the same" to both sender and receiver, regardless of their underlying system differences.

Simple Mail Transfer Protocol (SMTP)

SMTP (Simple Mail Transfer Protocol) handles email transmission between mail servers using port 25 over TCP connection.

Core Components

User Agent (UA)

Mail Transfer Agent (MTA)

MIME (Multipurpose Internet Mail Extensions)

Mail Access Protocols (MAP)

ProtocolFull Name
POP3Post Office Protocol v3
IMAP4Internet Message Access Protocol v4

Protocol Differences:

POP3: Downloads messages to local device and typically deletes from server. Good for single-device access.

IMAP4: Synchronizes emails across multiple devices. Messages remain on server for universal access.

Note: SMTP only handles sending emails. Receiving requires POP3 or IMAP4 for the final delivery to user's mailbox.

8.5 POP3 and IMAP

Post Office Protocol Version 3 (POP3)

Post Office Protocol Version 3 (POP3) is an email retrieval protocol that operates as a pull protocol, meaning the client initiates requests to fetch emails from the server.

Protocol Details:

POP3 Operation:

  1. Client connects to mail server on port 110
  2. User authentication (username/password)
  3. Client downloads all new messages
  4. Messages removed from server (default behavior)
  5. Connection terminated

Key Characteristics:

POP3 vs IMAP Comparison:

FeaturePOP3IMAP
StorageLocal deviceServer
Multi-devicePoor supportFull support
Offline accessYesLimited
Server storageMinimalHigh

Current Usage: While POP3 is still supported, IMAP4 (Internet Message Access Protocol version 4) has become the preferred choice for modern email services due to its multi-device synchronization capabilities and server-side email management. Remember: POP3 = Pull protocol, Port 110, Downloads and deletes from server

8.6 SSH

Session Layer

The Session Layer manages communication sessions between applications across a network.

Primary Functions:

Synchronization Services: The layer provides checkpoint mechanisms to handle transmission failures:

CheckpointData StreamCheckpointData StreamCheckpoint
This diagram shows how synchronization works in the Session Layer. Imagine a long stream of data flowing from left to right. At regular intervals along the stream, a checkpoint is inserted, then more data flows, then another checkpoint, and so on, alternating checkpoint, data stream, checkpoint, data stream. The takeaway is that the data stream is divided into sections by checkpoints, so if a transmission fails, only the data sent after the most recent checkpoint needs to be retransmitted, instead of resending the whole session from the beginning.

Example: During a large file transfer, checkpoints are placed every 1MB , if connection drops at 7.3MB , transmission resumes from the 7MB checkpoint, not from the start.

Session Control Types:

Remember: Session layer is about managing the conversation, not the actual data transport.

9. Network Security

9.1 Symmetric Key Encryption (DES, AES)

Cryptography

Cryptography involves transforming readable messages into unreadable form and back again for secure communication.

Key Terms:

Basic Process:

Plaintextreadable messageCiphertextvia EncryptionPlaintextvia Decryption
This diagram shows the basic process of cryptography in three steps, read left to right. It starts with the plaintext, which is the original readable message. An encryption step, using an encryption algorithm and a key, transforms the plaintext into ciphertext, which is the unreadable, scrambled form of the message, shown in the middle. Then a decryption step, which reverses the process, transforms the ciphertext back into the original plaintext, shown on the right. The takeaway is that encryption and decryption are opposite operations: encryption turns readable plaintext into unreadable ciphertext for safe transmission, and decryption restores the ciphertext to the original plaintext at the receiver.

Encryption Algorithm: Converts plaintext into ciphertext using a specific method and key Decryption Algorithm: Reverses the process, converting ciphertext back to original plaintext

Example:

Note: The strength of cryptography depends on the algorithm's complexity and key secrecy, not on hiding the method itself.

Types of Cryptography

Cryptography uses mathematical algorithms to secure data transmission. Two main approaches exist based on key usage.

Symmetric Key Cryptography Uses the same shared key for both encryption and decryption. The sender encrypts with the key, and the receiver decrypts with the same key.

Substitution Ciphers Replace one symbol with another according to a fixed system:

Shift Cipher The simplest substitution where each letter shifts by a fixed number of positions. Example: with shift +1, "A" becomes "B" , "B" becomes "C" .

Transposition Ciphers Characters remain the same but their positions change according to a key pattern. The key defines how to rearrange character positions between plaintext and ciphertext.

Rotation Cipher Input bits rotate left or right by a specified amount:

Decryption uses the same key with opposite rotation direction.

Block Ciphers Divide plaintext into fixed-size blocks and apply the same key to encrypt each block.

Data Encryption Standard (DES)

Triple DES (3DES) Uses three DES operations in sequence:

Two versions exist:

Advanced Encryption Standard (AES) Designed to replace DES due to its small key size. Triple DES was too slow despite larger keys.

Asymmetric Key Cryptography Uses two mathematically related keys: a private key (kept secret) and a public key (shared openly).

RSA Algorithm Named after Rivest, Shamir, and Adleman. Uses numbers e and d as public and private keys.

Key Generation Process:

  1. Choose two large prime numbers p and q
  2. Calculate modulus: n = p × q
  3. Compute: φ(n) = (p - 1)(q - 1)
  4. Select random integer e, then find d where d × e ≡ 1 mod φ(n)

Public information: e and n Private information: d and φ(n)

Usage: RSA works best for short messages like symmetric keys or message digests. For long messages, use RSA to exchange symmetric keys, then use symmetric encryption for the actual data. Applications: Digital signatures, authentication, secure key exchange

Diffie-Hellman Key Exchange Designed specifically for establishing shared symmetric keys between parties without prior key exchange. Process: Two parties create a session key k using the mathematical relationship:

K = g^(ab) mod p

where both (g^a mod p)^b mod p and (g^b mod p)^a mod p produce the same result . Vulnerability: Man-in-the-middle attacks where an attacker intercepts and modifies communications. Solution: Authenticate parties before key exchange to prevent interception.

Message Integrity and Authentication Encryption provides confidentiality but not integrity verification.

Message Digest Functions Create fixed-size hash values from variable-length input data. Key properties:

Common Hash Algorithms

AlgorithmDigest SizeNotes
MD2128 bitsMost secure but slowest
MD4128 bitsFast alternative
MD5128 bitsEnhanced MD4
SHA-1160 bitsProcesses 512-bit blocks

SHA-1 Details: Creates 160-bit digest (5 words of 32 bits each) from 512-bit message blocks.

Message Authentication Code (MAC)

MAC provides both integrity checking and sender authentication. Identical MACs confirm message integrity and sender identity.

Digital Signatures Uses asymmetric key pairs for authentication:

Provides: Message integrity, authentication, and non-repudiation (sender cannot deny sending the message). Note: For long messages, symmetric cryptography is much more efficient than asymmetric methods.

Eavesdropping

Eavesdropping is a passive attack where an attacker intercepts and monitors network communications without the sender or receiver knowing.

How it works:

Common targets:

Example: On a shared Ethernet segment, an attacker can use packet sniffing tools to capture all network traffic, including passwords, emails, and file transfers sent in plain text. Vulnerability: Most network protocols transmit data without encryption by default, making eavesdropping trivial with readily available tools. Defense: Use encrypted protocols (HTTPS, SSH, VPN) and secure network infrastructure to prevent unauthorized access to transmission media. Note: Unlike active attacks, eavesdropping leaves no trace since the attacker only observes traffic without modifying it.

9.2 Firewalls

Denial-of-service Attack

A Denial-of-Service (DoS) attack targets system availability by overwhelming resources to prevent legitimate users from accessing services.

Attack mechanism:

Distributed DoS (DDoS):

Common attack vectors:

Example: A botnet of 1000 machines each sending 100 requests/second can generate 100,000 requests/second, overwhelming most web servers.

Defense strategies:

Note: Unlike other security attacks that aim to steal data, DoS attacks focus purely on disrupting service availability.