Network

Fundamentals of Computer Networks

Introduction to Data Communications

Data Communications is the exchange of data between two devices via a transmission medium like wire cable.

Four fundamental characteristics for an effective data communications system:

  • Delivery: Data must be delivered to the correct destination, received by the intended user and only by that user.
  • Accuracy: Data must be delivered accurately; altered data is unusable if uncorrected.
  • Timeliness: Data must be delivered in a timely manner, as late data is useless.
  • Jitter: Refers to the variation in packet arrival time.

Components in Data Communications

  • Message: The information (data) to be communicated.
  • Sender: The device that sends the data message.
  • Receiver: The device that receives the message.
  • Transmission Medium: The physical path by which a message travels from sender to receiver.
  • Protocol: A set of rules that govern data communications, representing an agreement between communicating devices. Without a protocol, devices may be connected but unable to communicate.
    • Promo qn: A network protocol provides a set of rules and conventions that govern the communication and data exchange between devices or system within a computer network
    • enabling communication and data transfer across different networks and devices, ensuring that data is transmitted accurately, efficiently and reliably

Network

  • A network consists of two or more computers/devices connected together for communication.
  • A device not connected to a network is called a stand-alone.
  • Devices can be hosts (e.g., laptop, cellular phone) or connecting devices (e.g., router, switch).

(+ve) Advantages of using Networks

  • File sharing: Users can share files.
  • Hardware sharing: Sharing hardware like printers.
  • Communication: Users can communicate via email, chat, or video.
  • Roaming access: Users can sign in to any computer on the network and access their files.
  • Centralized maintenance and updates: Software updates can be applied across the network.
  • Centralized security: Implementation of anti-virus software and firewalls protects files.
  • User monitoring: Ability to monitor user activities.
  • Different access levels for users: Restrict user access to certain files.

Disadvantages of using Networks

  • Cost: Additional equipment is needed.
  • Additional resources to manage the network.
  • Spread of malware: Viruses and malware can easily spread on an improperly secured network.
  • Hacking: Data may be accessed without permission on connected devices.

Network Types

  • Local Area Network (LAN): Geographically confined to one building or site (e.g., small businesses, homes).
  • Wide Area Network (WAN): Spread over a wide geographical area, covering multiple sites, countries, or even the world.
  • Internetwork/internet*: When two or more networks (LAN or WAN) are connected (*internetwork is a private internet with a lowercase ‘i’).
  • Internet: The global system of interconnected computer networks using the Internet Protocol Suite (TCP/IP) for communication. It’s a network of networks, including private, public, academic, business, and government networks.
  • Intranet: A private computer network used within an organization for internal communication, collaboration, and accessing company resources, restricted to authorized users.

OSI Model (Open System Interconnection Reference Model)

OSI Reference Model Layers and Functions (7 Layers)

  • Host layers (end devices, hosts, servers, computers):
    • 7. Application Layer: Interfaces directly with end-user applications, providing network services like email, file transfer, and web access. Protocol Data Unit (PDU): Data.
    • 6. Presentation Layer: Translates data formats between systems; handles encryption, compression, and encoding. PDU: Data.
    • 5. Session Layer: Establishes, manages, and terminates sessions between applications. PDU: Data.
    • 4. Transport Layer: Provides end-to-end communication, error recovery, and flow control. PDU: Segment / Datagram.
  • Media layers (network devices, routers, switches, Network Interface Card (NIC)):
    • Switch vs router:
    • 3. Network Layer: Manages routing of data packets between devices across different networks. PDU: Packet.
    • 2. Data Link Layer: Ensures reliable data transfer across the physical link; handles framing, error detection, and MAC addressing. PDU: Frame.
    • 1. Physical Layer: Transmission and reception of bitstream over a transmission medium (physical medium). PDU: Bits.

The purpose of each layer is to provide services to the layer above it while shielding the upper level from what happens below. Higher layers do not need to know how data got there or what happened at lower layers.

Detailed Layer Functions

Please Do Not Touch Sausage Pizza Again

OSI Model


Protocol Data Unit


TCP/IP Protocol Suite


Function

Application Layer


Data


HTTP, SMTP


  • Defines the services presented at the user-end.

  • Main functions include:

    • Identification of services provided to the user.

    • Defining QoS (Quality of Service) parameters.

    • Defining security mechanisms (access control, authentication).

    • Synchronization of communication applications (for connection-oriented services).

Presentation Layer


  • Responsible for** how data is presented to the application.**

  • Negotiates the** transfer syntax** (form of data) at the start of communication.

  • Can provide additional services like **compression, encryption, and translation, **chosen by the application.

Session Layer


  • Provides the ability for presentation entities to organize communication for multiple sessions concurrently.

  • Session initiation and teardown: Responsible for starting and releasing communication sessions.

  • Token management: Controls which entity owns the token (license to transmit) in communication modes where only one entity can transmit at a time (e.g., half-duplex).

  • Session-connection to transport-connection mapping: Maps transport layer connections to current sessions in connection-oriented transfers.

Transport Layer


Segments


TCP, UDP


  • Responsible for process-to-process delivery of the entire message.

  • Ensures the whole message arrives intact and in order, overseeing error control and flow control at the source-to-destination level.

  • Service-point addressing (or port address): Transport layer header includes a type of address to deliver messages to a specific process (running program) on the destination computer.

  • Segmentation and reassembly: Divides messages into segments with sequence numbers for correct reassembly and identification/replacement of lost packets.

  • Connection control: Can be connectionless (treats each segment independently) or connection-oriented (establishes a connection before data transfer).

  • Flow control: Performed end-to-end (across the entire path). → only dedicates the amount of data the receiver can hold

  • Error control: Performed process-to-process (end-to-end); ensures entire message arrives without error (damage, loss, duplication). Error correction usually via retransmission.

Protocols

  • **User Datagram Protocol (UDP): **

    • used when speed is more important than reliability

    • connectionless - no handshake before communication starts

    • unreliable - no guarantee of delivery or order

    • fast and efficient - minimal 8 byte header

      • source port, destination port, length and checksum
  • **Transmission Control Protocol (TCP): **

    • Connection-oriented: reliable connection must be obtained and acknowledged before any data can be transmitted

    • Reliable delivery - data integrity (no loss or corruption), uses acknowledgements and timeouts

    • Error checking - use checksum to detect error

    • Flow control - prevent overwhelming receiver

    • Congestion control: manage traffic load

    • Ordered delivery: reassembled in correct order with sequence number

    • TCP connection management phases

  1. Connection establishment

  2. Three way handshake process to establish connection

1. Three messages are exchanged that allow each side to agree to form a connection and know the other side has agreed
1. Client sends SYN segment for synchronisation of sequence number - the number is the initial sequence number (ISN) - chosen at random

1. ![[../_assets/image125.png]]
  1. Both sender and receiver agree on connection state

  1. Data transmission

  2. To ensure reliable data transmission:

1. Every byte assigned to a **sequence number** -> receiver can reorder segments and detect missing data
1. Receiver sends an **acknowledgement (ACK)** with the **next expected byte number** -> confirms data was received correctly and in order

1. Retransmission -> sender retransmits data if ACK not received in time

  1. **Retransmission timer** for each sent segment -> lost ACKs or segments are detected and resent

  1. Recovery from packet loss by allowing sender to **retransmit **after receiving **three duplicate ACK **

1. Checksum -> Each TCP segment has 16-bit checksum covering header and data -> detects corruption

1. Flow Control -> receiver advertises a window size to control how much data sender can transmit (prevent buffer overflow)

1. Ordered delivery: receiver stores out-of-order segments and waits to deliver them in sequence
  1. Connection termination

  2. Three way handshake process to terminate connection (FIN indicates that there is no more data to send and requests to close the connection)

  3. Or 4-step teardown process:

1. One end can stop sending data while still receiving data
1. Either server or client can issue request

1. Second FIN segment not generated immediately
  1. Ensures all data has been delivered and acknowledged before closing connection

  2. Sequence numbers

  3. Every byte of data is assigned a sequence number, allows receiver to reorder segments and detect missing data

  4. Sender sends the acknowledgment number that is sequence no. of last byte received from receiver + 1

  5. Receiver sends acknowledgment number that is sequence no. of last byte received from sender + 1

**Flow control - Sliding window **

  • Improve throughout (rate of message delivery)

  • Transmit multiple packets before waiting for acknowledgement

  • operates at octet level, not packet or segment level

  • each ACK contains receiver window size that specifies how many more octets it can receive without buffer overflow

  • Sender uses sliding window to determine how many octets it can send without waiting for ACK

  • Window size increases when receiver processes data and can fill up buffer

  • Window size decreases when receiver buffer fills up

Port Numbers

  • **System/well-known ports **

    • 0 to 1023: controlled and assigned by Internet Assigned Numbers Authority (IANA) e.g. TCP port for HTTP
  • **Registered/user ports **

    • 1024 to 49151: not assigned or controlled by IANA, can only be registered with IANA to prevent duplication e.g. PostgreSQL uses 5432
  • **Dynamic/private ports **

    • 49152 to 65 535: neither controlled nor registered, used as temporary or private port numbers

Network Layer


Packets


Network layer: the guy that creates the route

  • Responsible for the source-to-destination delivery of a packet

  • Logical addressing: Adds a header with logical addresses (IP addresses) of sender and receiver to distinguish systems across network boundaries.

  • Routing: Connecting devices (routers or switches) route or switch packets to their final destination across internetworks.

  • Only need network layer when devices are on different networks, if on same network, devices can communicate using layer 2 - Data Link Layer

Data Link Layer


Frames


  • Responsible for enabling direct communication between two devices on the same local network and overseeing packet delivery between them.

  • Packages data into frames (Framing). Each frame includes:

    • Header: With MAC address of source and destination.

    • Payload: Actual data.

    • Trailer: With error-checking information.

  • Physical addressing: Adds a header with sender/receiver addresses for frame distribution.

  • Flow control: Imposes mechanisms to prevent overwhelming the receiver if data absorption rate is slower than production.

  • Error control: Adds reliability by mechanisms to detect and retransmit damaged/lost frames, and recognize duplicates. Achieved via a trailer.

    • Error detection methods: Parity bits, Checksums, CRC (Cyclic Redundancy Check). Discard corrupted frames and higher layers may request retransmission.
  • Access control: Determines which device controls the link when multiple devices are connected. Uses Media Access Control (MAC) protocol to avoid collisions:

    • CSMA/CD (Carrier Sense Multiple Access with Collision Detection): Used in wired Ethernet; devices listen before transmitting and detect collisions.

    • CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance): Used in wireless networks; devices wait for a clear signal before sending.

  • Sublayers:

    • LLC (Logical Link Control): Provides interface with network layer, handles error checking and flow control.

    • MAC (Media Access Control): Handles channel access (e.g., CSMA/CD, CSMA/CA) and physical addressing.

    • Ethernet and Wi-Fi include both MAC and LLC.

  • MAC Address (Media Access Control address):

    • A 48-bit (6-byte) hardware address, usually written in hexadecimal (e.g., 00:1A:2B:3C:4D:5E).

    • First 3 bytes (OUI): Identify the manufacturer.

    • Last 3 bytes: Device-specific identifier assigned by manufacturer. (different for the same model)

    • Each network device has a unique MAC address, hardcoded into the Network Interface Card (NIC).

    • Used in Ethernet and Wi-Fi for local addressing (within the same network/LAN).

    • Added as source/destination in Ethernet frames.

Physical Layer


Bits


  • Coordinates functions to carry a bit stream over a physical medium.

  • Deals with mechanical and electrical specifications of interfaces and transmission media.

  • Defines physical characteristics of interfaces and media.

  • Representation of bits: Defines how 0s and 1s are encoded into electrical or optical signals.

    • Digital signals: Use discrete voltages (e.g., 0V for 0, 5V for 1).

    • Analog signals: Continuous waveforms representing data as varying voltage, current, or electromagnetic field.

  • Data rate: Defines the transmission rate (bits per second) and the duration of a bit.

  • Synchronization of bits: Sender and receiver clocks must be synchronized.

  • Line configuration: Concerned with connecting devices to the media:

    • Point-to-point connection: Dedicated link between two devices; entire capacity reserved for them.

    • Multipoint / Multidrop connection: More than two devices share a single link; channel capacity is shared spatially or temporally.

  • Physical topology: Defines how devices are connected to make a network. Geometric representation of links and nodes.

    • Mesh Topology: Every device has a dedicated point-to-point link to every other device (n-1 links for n devices).

    • Star Topology: Every device has a dedicated point-to-point link to a central controller; devices are not directly linked.

    • Bus Topology: A multipoint connection where a long cable acts as a backbone linking all devices via drop lines and taps.

    • Ring Topology: Each device has a dedicated point-to-point connection with two other devices, passing signals in one direction; repeaters regenerate bits.

  • Transmission mode: Defines direction of transmission between two devices:

    • Simplex: Unidirectional communication; one device transmits, the other only receives (e.g., keyboards, monitors).

    • Half-duplex: Each device can transmit and receive, but not simultaneously (e.g., walkie-talkies).

    • Full-duplex: Both stations can transmit and receive simultaneously (e.g., telephone network).

  • Transmission Media: Two broad categories:

    • Wired Transmission:

      • Twisted Pair Cable: Copper cable with twisted insulated wires to reduce interference, used in Ethernet LANs (e.g., Cat5, Cat6).

      • Coaxial Cable: Electric cable for high-frequency signals with a central conductor, insulation, and metal shield, efficient over long distances.

      • Fiber Optic Cable: Transmits data as light pulses through glass/plastic strands, high bandwidth, faster speeds, used in telecommunications for long distances.

    • Wireless Transmission:

      • Radio Waves: Electromagnetic radiation with long wavelengths, low frequencies, used for wireless transmission by modulating amplitude/frequency (e.g., Wi-Fi, mobile phones, satellite communication).

      • Microwaves: Used in satellite and long-distance communications.

      • Infrared: Used in short-range communication (e.g., TV remotes).

Data Encapsulation/Decapsulation

  • Encapsulation: The flow of data from the application layer down to the physical layer. Headers and trailers are added to the data at various layers.
    • User data -> Data (Application, Presentation, Session) -> Segments (Transport) -> Packets (Network) -> Frames (Data Link) -> Bits (Physical).
  • Decapsulation: The process of unwrapping data as it moves up the layers at the receiving end.

End-to-End Data Flow (Host A Source to Host B Destination via Routers)

  • Host A (Source):

  • Application layer initiates communication, passes data to presentation layer.
  • Presentation layer performs transformations (compression, encryption, translation), passes data to session layer.
  • Session layer initiates communication session, passes data to transport layer.
  • Transport layer segments data,** adds a header** (sequence, acknowledgement numbers), passes segments down to the network layer. This header is for the receiving transport layer.
  • Network layer treats the segment + transport header as data, puts it into packets, adds its own header (source/destination network-layer addresses), passes packets to data link layer. This header is for the receiving network layer.
  • Data link layer treats the packet + network header as data, puts it into frames, adds a header and trailer (error control info), passes frames to physical layer. This header is for the receiving data link layer.
  • Physical layer treats frames as raw bits, transmits them through the physical channel to the router.
  • Router:
    • Performs partial decapsulation because it only needs to read up to the network layer header to route data.
    • Physical layer receives raw bits, gathers them into frames, sends to data link layer.
    • Data link layer reads header/trailer, removes them, sends data as a packet to network layer.
    • Network layer reads the network header to determine destination network address, chooses best route, and then starts encapsulation again.
    • Data goes down data link and physical layers and is transmitted to the next hop (another router or destination host). This process repeats if multiple routers are involved.
  • Host B (Destination):
    • Raw bits are elevated as frames to data link layer.
    • Data link layer reads and removes header/trailer, elevates data as packets to network layer.
    • Network layer reads packet header (determines if correct destination, other control info), removes header, elevates data as segments to transport layer.
    • Transport layer reads segment header (sequence number for ordering), removes header, elevates data to session layer. Transport header also has session info.
    • Session layer determines if it’s the end of the session or waits for more data.
    • Presentation layer retransforms data (decompression, decryption, translation) to the original or application-defined form.
    • Data is transferred to the application and received by the user.

TCP/IP Protocol Suite / DoD Model

Introduction

  • TCP/IP (Transmission Control Protocol/Internet Protocol) is a protocol suite – a set of protocols organized in different layers.
  • Upper-level protocols are supported by services from lower-level protocols.
  • Developed prior to the OSI model, so layers don’t match exactly.
  • Developed using the Department of Defense (DoD) reference model.

TCP/IP Protocol Suite vs OSI Model

  • OSI Model (7 layers): Application, Presentation, Session, Transport, Network, Data Link, Physical.
  • (5 layers): Application, Transport, Network, Data link, Physical

**our syllabus only focus on 5 layers**

Layering Principle

  • Designed so that “layer n at the destination receives exactly the same object sent by layer n at the source”.
  • Data units (messages, segments, packets, frames) are conceptually identical at peer layers across networks, with frames and packets being identical across different networks or router hops.

Benefits of Layering

  • Modularity: Each layer focuses on a specific function, making the system easier to design, understand, and troubleshoot.
  • Interoperability: Standardized layer functions and interfaces allow devices/software from different vendors to work together.
  • Flexibility and Abstraction: Changes in one layer don’t affect others due to defined interfaces.
  • Simplified Troubleshooting: Issues can be diagnosed layer by layer.
  • Standardization: Provides a common language and framework for networking protocols.

TCP/IP Protocol Suite - Data Encapsulation

  • Similar to OSI, data is encapsulated with headers/trailers as it moves down the layers.
  • User Data -> Data -> Segments -> Packets -> Frames -> Bits.

TCP/IP Protocol Suite - Physical Layer

  • Does not define any specific protocol; supports all standard and proprietary protocols.
  • Communication is between two nodes (computer or router).
  • Unit of communication is a single bit.

TCP/IP Protocol Suite - Data Link Layer (layer 1 and 2)

  • Does not define any specific protocol; supports all standard and proprietary protocols.
  • Communication is between two nodes.
  • Unit of communication is a frame, which encapsulates data from the network layer with a header and optional trailer.
  • TCP/IP is flexible and can run over any underlying network infrastructure (Ethernet, Wi-Fi, fiber, etc.) because it doesn’t tie itself to specific hardware standards.

TCP/IP Protocol Suite - Network Layer (Internetwork Layer/Internet Layer)

  • Main purpose: Select the best path for data to travel from source to destination (routing).
  • Leading protocol is Internet Protocol (IP).
  • Supporting protocols: Internet Control Message Protocol (ICMP), Address Resolution Protocol (ARP), and Reverse Address Resolution Protocol (RARP).

TCP/IP Protocol Suite - Transport Layer

  • Similar purpose to OSI’s transport layer: gives source and destination end-to-end conversation ability.
  • Responsible for delivering packets to the correct application/service on the source and destination devices
  • Two defined protocols: Transmission Control Protocol (TCP) for connection-oriented communication, and User Datagram Protocol (UDP) for connectionless communication.

TCP/IP Protocol Suite - Application Layer

  • Main duty: Take data from applications, deliver to transport layer, and collect data from transport layer to deliver to correct applications.
  • Contains a large group of high-level protocols:
    • Hyper Text Transfer Protocol (HTTP).
    • File Transfer Protocol (FTP).
    • Simple Mail Transfer Protocol (SMTP).
    • Post Office Protocol 3 (POP3).
    • Telnet.
    • Domain Name Service (DNS).

Mode of Data Transfer (network layer)

  • Circuit Switching
    • *everything move together
    • Connection-oriented: A connection must be established before data transmission.
    • Data moves across the same path throughout the entire communication.
    • Example: Early telephone systems.
    • Never implemented at the network layer.
  • Packet Switching
    • *broken down, moved separately
    • Connectionless: No connection is established before transmission.
    • Data is fragmented into smaller chunks called packets.
    • Each packet is individually addressed and sent, finding its own way to the recipient.
    • Receiving computer waits for all packets, reassembles them into the original message before delivering to the upper layers
    • The network layer in the Internet is a packet-switched network.

  • Packet Switching at Network Layer (Key Steps)
    • Routing: Process of selecting the best path for a packet to reach its destination. IP is responsible for sending packets from Host A to Host B, possibly via routers.
    • At Host A (Source):
      • Packetizing/Packet Creation: Data is encapsulated into an IP packet, adding an IP header with source IP (Host A) and destination IP (Host B) addresses.
      • Routing decision:
        • Direct delivery: If Host B is on the same local network, the packet is sent directly.
        • Indirect delivery: Otherwise (different network), the packet is forwarded to the default gateway (usually a router).
      • Fragmentation: If data size exceeds the Maximum Transmission Unit (MTU) of the frame, the packet is fragmented into smaller units before passing to the data link layer.
      • MAC address resolution: The MAC address of the next hop (host/router) is obtained, usually using ARP (Address Resolution Protocol) with the destination IP address.
    • At the Router:
      • Receives the packet from Host A.
      • Validates the header to ensure it’s not corrupted and delivered to the correct router.
      • Check the destination IP address.
      • Consults routing table to determine the next hop and forwards the packet.
      • May perform fragmentation if needed before passing to the data link layer.
      • Repeat steps if multiple routers are involved.
    • At Host B (Destination):
      • Validates the packet header, extracts data from fragments.
      • When all fragments arrive, reassembles data and delivers to the transport layer.
      • Network layer sets a reassembly timer; if expired, fragments are destroyed, an error message is sent, and datagrams need retransmission.

Protocol

  • Definition: A set of rules, standards, or procedures that govern how data is transmitted, received, and interpreted between devices in a communication network.
  • Features of a Protocol
    • Standardized for compatibility and interoperability.
    • Defines how data is formatted and organized.
    • Specifies how devices initiate, maintain, and terminate communication.
    • Specifies how errors are handled (detecting and correcting).
  • Network Layer - Protocols
    • Internet Protocol version 4 (IPv4): Responsible for packetizing, forwarding, and delivery of a packet at the network layer.
      • IP is an unreliable connectionless protocol responsible for source-to-destination delivery.
      • Provides best-effort delivery service.
      • Packets can be corrupted, lost, arrive out of order, delayed, or create congestion.
      • Each packet is handled independently and can follow a different route.
      • Protocol data unit (PDU) in the Network layer: Packets.
    • Internet Control Message Protocol version 4 (ICMPv4): Supports IP by handling errors that may occur in network-layer delivery.
      • Used for sending error messages, diagnostics, controlling data flow.
      • Example: ICMP source-quench packet (router tells host to slow down due to overload), PING (sends ICMP echo requests for connectivity testing).
    • Internet Group Management Protocol (IGMP): Helps IPv4 in multicasting.
      • Enables one host to send one stream of data to many hosts simultaneously (multicast).
    • Address Resolution Protocol (ARP): Glues network and data link layers by mapping network-layer addresses (IP address) to link-layer addresses (MAC address).
      • Steps to resolve hardware address:
        • Look in ARP cache (stored for 2-10 minutes).
        • If not found, an ARP request broadcast is initiated to all nodes in the local network.
        • The destination node with the requested IP address responds with its hardware address.
  • IPv4 Header Fields (Example)
    • Version (VER): 4 bits, indicates IP version (always 4 for IPv4).
    • Header Length (HLEN): 4 bits, header length in 32-bit words (min 5, 20 bytes).
    • Service Type: 8 bits, originally priority, now DSCP for Quality of Service (QoS).
    • Total Length: 16 bits, length of entire packet (header + data) in bytes (max 65,535).
    • Identification: 16 bits, unique value for identifying fragments of the same original packet.
    • Flags: 3 bits, controls fragmentation (DF - Don’t Fragment, MF - More Fragments).
    • Fragmentation Offset: 13 bits, used to reassemble fragmented packets in order.
    • Time to Live (TTL): 8 bits, limits packet’s lifespan; decremented by each router, packet dropped when 0.
    • Protocol: 8 bits, specifies next-level protocol (e.g., 1=ICMP, 6=TCP, 17=UDP).
    • Header Checksum: 16 bits, error-checking for IPv4 header only.
    • Source IP Address: 32 bits, IPv4 address of sender.
    • Destination IP Address: 32 bits, IPv4 address of intended recipient.
    • Options (optional): Variable, additional control information, rarely used.
    • Padding: Variable, extra bits to make header length a multiple of 32 bits.
  • How a Packet is Sent from Host to Source (using IP)
    • Source and destination IP addresses are placed in the IP header.
    • Network layer checks if destination is on the same local network or a different (remote) network by comparing IP addresses with subnet masks.
    • If on the same subnet, packet is sent directly (direct delivery).
    • If on a different subnet, packet is sent via default gateway/router (indirect delivery).
    • If packet size exceeds MTU, it will be fragmented.
    • MAC address of next hop/destination device is obtained via ARP.

IP Address (Network layer)

  • IP Address
    • Every host on a TCP/IP network needs a unique address to send data from host to host.
    • Addressing information in the header is used to route packets.
  • IPv4
    • A 32-bit address that uniquely identifies every host on a network.
    • Known as a logical address – software assigned and non-permanent.
    • Expressed in dotted-decimal** notation** (e.g., 172.16.254.1), also has binary and hexadecimal notations.
    • Divided into two parts: prefix (defines the network) and suffix (defines the host).
      • Prefix length is ‘n’ bits, suffix length is (32 - n) bits.
  • IPv6
    • 128-bit addresses, allowing for 2^128 unique addresses.
    • Written in hexadecimal form – 8 groups of 4 hex digits (16 bits) (e.g., EFDC:BA62:7654:3312:EFDC:BA72:7653:3210).
    • IPv4 can be used within IPv6 addressing (hexa-decimal IPv4 address placed in the last 32 bits of IPv6 address).
    • Zero compression: IPv6 addresses with many zeros can be shortened by dropping non-significant/leading zeros and using double-colon (::) once for consecutive zeros.
        1. Drop all the initially (leading) 0s
        1. :0:0:0:0: → :: (but can only be done to one part, cannot have 2)
  • IPv6 vs IPv4 Comparison
    • Address size: IPv4 (32 bits), IPv6 (128 bits).
    • Address format: IPv4 (Dotted decimal), IPv6 (Hexadecimal colon-separated).
    • Number of addresses: IPv4 (~2^32), IPv6 (~2
    • Header size: IPv4 (Variable), IPv6 (Fixed, simplified).
    • Broadcast: IPv4 (Supported), IPv6 (Replaced by multicast).
  • IPv6 Address Types
    • Unicast: One-to-one communication.
    • Multicast: One-to-many communication (like groups); starts with FF00::/8.
    • Anycast: One-to-nearest (in routing terms); assigned to multiple interfaces.
    • Link-local: For local communication within a network; starts with FE80::/10.
    • Global Unicast: Public IPv6 address; starts with 2000::/3.
  • IPv4 - Classful Addressing Scheme
    • Used fixed-length prefixes to represent unique network addresses (n=8, 16, 24). Designed for small and large networks.
Class A (large network):
- Network portion: 8 bits (first bit always 0).
- Possible network numbers: 2^7 = 128 (0.0.0.0 and 127.0.0.0 reserved). Usable: 126 networks.
- Host portion: 24 bits.
- Possible host combinations: 2^24 (16,777,216).
- **Network address**: All host bits 0 (e.g., 10.0.0.0).
- **Broadcast address**: All host bits 1 (e.g., 10.255.255.255).
- Usable hosts per Class A network: 2^24 - 2 = 16,777,214.
Class B (medium-sized network):
- Network portion: 16 bits (first 2 bits always 10).
- Usable network numbers: 2^14 = 16,384.
- Host portion: 16 bits.
- Possible host combinations: 2^16 (65,536).
- Usable hosts per Class B network: 2^16 - 2 = 65,534.
Class C (small network, businesses):
- Network portion: 24 bits (first 3 bits always 110).
- Usable network numbers: 2^21 = 2,097,152.
- Host portion: 8 bits.
- Possible host combinations: 2^8 (256).
- Usable hosts per Class C network: 2^8 - 2 = 254.
Class D (multicasting):
- First bits: 1110.
- Address range: 224.0.0.0 to 239.255.255.255.
- Used for **multicasting** (sending data to a selected group of devices). Not used for regular host addresses.
Class E (experiment):
- First bits: 1111.
- Address range: 240.0.0.0 to 255.255.255.255.
- Reserved for experimental and future use. Not used in public networks.
- **255.255.255.255**: A limited broadcast address used to send to all hosts on the local network.
  • Different types of Addresses:
    • Network address: Identifies the entire network segment, not assigned to any device. Used by routers for routing packets. First address in any subnet.
    • Broadcast address: Used to send a message to all hosts on the network at once. Last address in a subnet.
    • Multicasting: Send data to a selected group of devices.
  • Two-level addressing: Each classful address contains netid (defines network) and hostid (defines a particular host).
  • Given an IP address in classful addressing, one can find:
    • Its class and the value of ‘n’.
    • The number of addresses in the block: N = 2
    • The first address (network address): Keep ‘n’ leftmost bits, set (32-n) rightmost bits to 0s.
    • The last address (broadcast address): Keep ‘n’ leftmost bits, set (32-n) rightmost bits to 1s.
  • IPv4 – Network Mask
    • A 32-bit number with the ‘n’ leftmost bits set to 1s and the rest (32-n) set to 0s.
    • Used to extract the network address from an IP address by using the AND operation.
  • IPv4 – Limitations of Classful Addressing
    • IP addresses in fixed sizes (A, B, C) were either too large or too small, leading to IP address wastage and scaling issues.
    • Routing tables grew large and inefficient.
    • Contributed to rapid IPv4 exhaustion.
    • Not flexible; couldn’t tailor address block size to network size.
  • IPv4 – Strategies to Overcome Limitations
    • Subnetting.
    • Variable-length Subnet Masking (VLSM).
    • Network Address Translation (NAT).
    • Private IP Address Range.
    • Classless Inter-Domain Routing (CIDR).
    • Transition to IPv6 (long-term strategy).
  • IPv4 – Subnet Addressing/Subnetting

  • Process of dividing a larger network into smaller, more manageable subnetworks.
  • Resolved insufficient network addresses in classful scheme without abandoning it.
  • Allows a single network prefix for multiple physical networks.
  • Helps organize networks, reduce congestion, and minimize broadcast traffic.
  • Isolates network parts, reducing security risks.
  • Imposes hierarchical addressing, leading to hierarchical routing.
  • Fixed-length subnetting: A site chooses one division for the local portion and uses it throughout.
  • Variable-length subnetting: Each network selects its own subnet partition.
    • Advantage: Flexibility (mixture of large/small networks), higher address space utilization.
    • Disadvantage: Difficult to administer, careful assignment to avoid address ambiguity.
  • IPv4 – Subnet Mask
    • A 32-bit number showing how many bits are used for the network portion and the host portion.
    • Covers the internet portion and the physical network part of the local portion.
    • Bits are set to 1 for subnet prefix and 0 for host identifier.
  • Network Address Translation (NAT)
    • A method in routers to translate private IP addresses (inside local network) into public addresses (on the internet) and vice versa.
    • Enables multiple devices on a private network to share one public IP address.
  • IPv4 - Classless Addressing Scheme (CIDR)
    • Classless Inter-Domain Routing (CIDR) was developed after classful addressing (1993).
    • Goals: Prevent IP address exhaustion, provide more flexible allocation, support route aggregation (reducing routing table sizes).
    • Represents IP addresses in dotted decimal notation followed by a slash and a number (prefix length) (e.g., 167.199.170.82/27, where 27 is the network portion length).
    • First address: Keep ‘n’ leftmost bits, set (32-n) rightmost bits to 0s.
    • Last address: Keep ‘n’ leftmost bits, set (32-n) rightmost bits to 1s.
    • CIDR blocks for private networks are not routable on the public Internet. If forwarded, routers discard them.
    • NAT translates private IPs to public IPs for Internet access.
    • 169.254.0.0/16 is a link-local address: Devices assign themselves an address in this block if they fail to obtain an IP from a DHCP server automatically.

Network 3

Checksum

  • Error detection method used by most TCP/IP protocols
  • Calculated at sender and value obtained is sent with packet
    • Packet is divided into k sections of n bits each
    • Sections added together using one’s complement arithmetic
    • Final result complemented to make checksum
  • Receiver repeats the same calculation on the whole packet including checksum
    • Received packet is divided into k sections of n bits each
    • All sections added together using one’s complement arithmetic
    • Result is complemented
    • If final result is 0, packet is accepted
  • If result is correct packet is accepted
  • In IP, only header is covered, not data
  • Higher-level protocols that encapsulate data in IP datagram have checksum fields covering the whole packet -> checksum for IP datagram does not have to check encapsulated data
  • Header of IP packet changes with each visited router, no need to recalculate checksum for whole packet which includes the unchanged part (the data) which will increase processing time

**One’s complement arithmetic **

Same as normal binary addition but when there’s carry out of the Most Significant Bit (MSB), carry is wrapped around and added to least significant bit (LSB)

**Check digit **

  • Each digit is assigned to a weight
  • Digit is multiplied by weight and products added together
  • Sum of product divided by 11 and reminder is subtracted from 11 to give the check digit

**Sockets **

  • A socket is an endpoint of communication between 2 devices on a network
  • Interface between application and transport layer
  • Located between OS and applications
  • Types
Stream Socket (TCP)Datagram Socket (UDP)
Connection-orientedconnectionless
ReliableUnreliable
Error-checked
Fast

Client-server architecture

  • Multiple client devices communicate with and request services from a central server
  • Server program waits for incoming requests and responds to requests
  • Client opens communication channel using IP address of the remote host and port address of the specific server program running on that machine
ClientServer
DefinitionA client is a computer or program that initiates a request for services or resources from a server over a networkA server is a computer program that provides services or resources to clients over a network
Finite: started by user and terminates when service is completeInfinite: runs infinitely unless problem arises or server shuts down
Examplesweb browser, email programweb server, file server, database server, email server

Advantages and disadvantages of client-server architecture

AdvantagesDisadvantages
Centralised resource management
- Server holds and manages resources
- Central control of data, security policies, backups and user access
Single point of failure
- If server shuts down, all clients lose access to services
Scalability:
- new clients can be added easily without changing system
- server can be upgraded to serve more clients
High cost of setup and maintenance
- Servers are expensive, require skilled admins
- infrastructure and licensing costs
Improved security
- Security policies enforced from server side e.g. user authentication, file permissions
Network congestion and overload
Ease of maintenance
- no need to configure every client device, updates, backups and configurations done on server
Complexity of configuration and management of a secure and efficient server
Reliability and consistency
- data stored is kept consistent - all clients access from one source
Network dependence
- stable network connection required for clients
Remote access support
- server access can be from anywhere over the internet

**Peer-to-peer architecture **

P2P architecture is a decentralised network model where each computer (peer) acts as both a client and a server

Key features

  1. All peers have equal role: can initiate or respond to a request
  2. Decentralised: no central point of control, resources distributed among peers
  3. Resource sharing: resources and services shared among peers
  4. Autonomy:each peer manages its own resources and can be online or offline at any time

Example: BitTorrent p2p file sharing, blockchain networks

AdvantagesDisadvantages
Low cost - no need for expensive server hardware or infralack of centralised control - no central authority to manage users, resources and security, harder to monitor and enforce rules
scalability: new peers can join network easily to contribute resources (no major reconfiguration)security risks - each peer is responsible for its own security - malicious peers can spread malware
no single point of failure - one peer failing will not affect the whole networkdata consistency: files in peers not guaranteed to be up to date : hard to sync
resource sharing - peers share files, processing power or bandwidth directlyperformance: performance suffers if there are few online peers or peers have low bandwidth

Dynamic Host Configuration Protocol (DHCP)

  • Automatically assigns IP addresses and other network configuration parameters to clients on a network
    • IP addresses, subnet masks, default gateways, DNS server addresses, lease duration

Types of allocation

  1. Static IP address
  2. Manual configuration: device manually configured with the IP address and other network configuration parameters, DHCP server not involved
  3. DHCP reservation - uses MAC address to always get the same IP address from DHCP pool - DHCP request is required
  4. Dynamic IP address
  5. DHCP server leases a dynamic IP address to the client for a period of time

Dynamic IP allocation

D - Discover - client sends broadcast to available DHCP servers
O - Offer - DHCP server replies with an offer including IP address and configuration

R - Request - client requests to use offered IP address

A - Acknowledge - server confirms and leases IP address to client

UDP is used to send broadcast

Lightweight, minimal overhead

TCP not used as it is connection-oriented: no IP address yet

DNS: Domain Name System

Translates domain names into IP addresses

  1. User passes host name to file transfer client (FTC)
  2. FTC passes host name to DNS client
  3. DNS client sends message to DNS server with query containing FT server name using IP address of DNS server
  4. DNS server responds with IP address of FT server
  5. DNS client passes IP address to FT client
  6. FT client uses IP address to access the FT server

Analogy (2 to 4 is Name Address Resolution)

  1. User passes host name to file transfer client (FTC) (postman)
  2. FTC (postman) passes host name to DNS client (directory office)
  3. DNS client (directory office) sends message to DNS server (central directory) with query containing FT server name using IP address of DNS server
  4. DNS server responds with IP address** (street address)** of FT server
  5. DNS client (directory office) passes IP address (street address) to FTC (postman)
  6. FTC (postman) uses IP address (street address) to access the FT server** (the house)**

You → Postman → Directory Office → Central Directory → Directory Office → Postman → House.

**Name address resolution steps **

  1. Check local cache
  2. Client checks its own cache for IP address
  3. Query local DNS server
  4. Client sends query to DNS server specified in IP configuration
  5. Server checks its own cache
  6. Query global DNS hierarchy (if not cached)
  7. if the ISP DNS resolver does not have the answer, it contacts the DNS hierarchy
    1. Recursive resolution: ISP DNS resolver resolves the name
    1. Root DNS server -> directs to TLD server -> directs to Authoritative DNS server -> returns actual IP
      1. Iterative resolution: step-by-step queries from client/local ISP DNS resolver, using referrals from each server
    2. Root DNS server -> returns address of TLD server -> returns address of authoritative DNS server -> returns actual IP address
  8. IP address returned back to client

From 2023 Promo:

DNS translates domain name given by the user to the IP address that the computer can

read and process. DNS server first checks if the requested domain name is available in its cache.

If not found, it sends request to the local DNS by the Internet Service Provider. If still not found,

DNS searches from a hierarchy of distributed database to locate the domain name. Once

found, DNS server sends the IP address back to the user.

Use of UDP in DNS

  • Speed: fast as users expect pages to load fast
  • Small size: DNS queries and responses easily fit in UDP datagram
  • Low overhead: simple header requires less time and bandwidth
  • Stateless: simple req and response, does not need to maintain connection

Hypertext Transfer Protocol (HTTP)

Stateless protocol

HTTP request:

  1. Request line - GET /test.html HTTP/1.1
  2. HTTP command/method is GET
  3. Path is test.html
  4. Version is HTTP/1.1
  5. Header fields provide additional information to web server - Host: example.com

HTTP Response:

  1. Status line - whether the server is able to perform the request e.g. HTTP/1.1 200 OK
  2. Status code: 200: OK, 404: Not found, 500: Internal Server Error
  3. Header fields - additional information e.g. Content-Type: text/plain
  4. Message body: contains document in format specified by Content-Type header field

Simple Mail Transfer Protocol (SMTP)

  • Send/relay email across internet, NOT for retrieving email
  • uses port 25/587
  • Client-server architecture

Structure

  1. Envelope
  2. MAIL FROM
  3. RCPT TO
  4. DATA (message content)
    1. Message headers: sender, receiver, content type
    1. Message body: content of email

Post Office Protocol v3 (POP3)

  • Download emails from server to client and delete message from mailbox on server
  • Port 110/995
  • Client-server architecture
  • client opens connection to server on TCP port 110, sends user name and password to access mailbox, user can then list and retrieve the mail messages 1 by 1

Internet Message Access Protocol v4 (IMAP4)

  • Allow users to view and manage messages on the server
  • Access mail messages from multiple locations (email clients), ensures all copies are synchronised and consistent
  • Extended functionality: obtain information about message or examine header fields without retrieving entire message, search and retrieve portions of message
  • Port 143/993

File Transfer Protocol (FTP)

  • Copying a file from one host to another
  • Resolves problems with hosts having
    • different file name conventions
    • different ways of representing text and ata
    • different directory structures
  • 2 connections between hosts: one for control info (port 21)
    • used for commands from clients and response from server
    • remains open during sessions
  • and the other for** data transfer** (port 20)
    • used for file transfer
    • open when needed and closed after data transfer