Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Networks 📝

Learning Goals

By the end of this section you will:

  • understand the principles of transmitting data over a network

  • understand the signficance network transmission concepts including latency, jitter, quality of service guarantee, and timeliness of delivery

  • understand the TCP/IP, HTTP/HTTPS, FTP/FTPS, VPN, streaming, and broadcasting network transmission protocols

  • understand the methods of exchanging data including REST, JSON, XML and CSV/TSV

Networks are the backbone of the modern world, but how do they work? Check the following videos to learn the fundamental about networking.

Network Transmission Principles 📝

Network transmission principles are fundamental concepts in networking that govern how data is sent and received across computer networks. These principles are essential for understanding how information flows efficiently and reliably over the internet and other network infrastructures.

Latency

Latency refers to the delay or lag that occurs when data is transmitted from one point to another in a network. It can be caused by various factors:

Low latency is crucial for real-time applications like video conferencing and online gaming, where delays can lead to a poor user experience.

Jitter

Jitter is the variation in the delay of received packets in a network. It represents the inconsistency in the timing of packet arrivals. It can result from network congestion, varying path lengths for different packets, or differences in the processing time at network devices.

In applications like Voice over IP (VoIP) and streaming media, jitter can lead to disruptions and poor audio or video quality. Minimizing jitter is essential for smooth communication.

Quality of Service (QoS) Guarantee

Network Quality of Service (QoS) guarantee refers to the assurance that a network can provide specific levels of service and performance to different types of traffic or applications. QoS is critical in ensuring that data, voice, video, and other applications receive the necessary bandwidth, low latency, and minimal packet loss to function effectively.

To guarantee QoS, networks often employ various mechanisms, such as traffic prioritization, bandwidth reservation, and congestion management. For example, in a VoIP (Voice over Internet Protocol) call, QoS guarantee ensures that voice packets are prioritized over less time-sensitive data packets, reducing the chances of voice call degradation due to network congestion.

Timeliness of delivery

The principle of timeliness of delivery in networking refers to the requirement that data should be delivered within a timeframe suitable for its intended use. This is crucial for ensuring that the information remains relevant and useful by the time it reaches its destination.

Network Transmission Protocols 📝

TCP/IP 📝

TCP/IP stands for Transmission Control Protocol / Internet Protocol. It is the core set of communication rules (called a protocol suite) that computers use to send and receive data over networks, including the internet.

Developed in the 1970s, TCP/IP is now the standard for all internet communication.

TCP/IP Protocol Layers

TCP/IP is made up of four layers. Each layer has its own job:

  1. Application Layer

    • Deals with applications and user services

    • This is the layer you interact with (e.g., web browsers, email clients)

    • Protocols here:

      • HTTP/HTTPS – web browsing

      • SMTP – sending emails

      • IMAP/POP3 – receiving emails

      • FTP – file transfer

  2. Transport Layer

    • Manages the delivery of data

    • Breaks data into chunks (called segments) and reassembles them

    • Handles error checking and flow control

    • Two main protocols:

      • TCP – Reliable, ordered delivery (used for most things)

      • UDP – Faster, no guarantee of delivery (used for games, video calls)

  3. Internet Layer

    • Handles routing of data between devices across networks

    • Breaks data into packets and labels them with IP addresses

    • Protocols here:

    • IP – Internet Protocol (IPv4 and IPv6)

    • ICMP – for sending error and control messages (used by ping)

  4. Network Access Layer (Link Layer)

    • Manages how data is sent physically over the network (wires, Wi-Fi, etc.)

    • Converts packets into electrical signals or radio waves

    • Protocols: Ethernet, Wi-Fi, ARP

How TCP/IP Works (Step-by-Step)

  1. User Action: You enter www.example.com in your browser.

  2. DNS Lookup: Your computer gets the IP address for the website using DNS.

  3. Data Preparation: Your browser sends an HTTP request (application layer).

  4. TCP Adds Reliability: The data is split into segments with error checks.

  5. IP Handles Routing: Each segment is wrapped in an IP packet and given a destination IP.

  6. Data Sent Over Network: Packets travel through routers and switches.

  7. Receiving End: The server reassembles the segments and sends back a response.

  8. Browser Displays Page: You see the website once all the data is received.

TCP vs UDP Comparison

FeatureTCPUDP
DeliveryReliable (resends lost data)Unreliable (no resending)
OrderKeeps orderNo guarantee of order
SpeedSlower (due to checking)Faster
Use casesWeb browsing, email, downloadsVideo calls, games, live streams

What is IP?

IP (Internet Protocol) is a network layer protocol that handles addressing and routing of data between devices on a network. It ensures that packets of data are sent from the sender to the correct destination.

Every device on a network — like your phone, laptop, or a website server — is assigned a unique IP address, which acts like a digital address so the internet knows where to send information.

IP is responsible for

  1. Addressing

    • Every device must have a unique IP address.

    • IP addresses identify the sender and the receiver of data.

  2. Packetization

    • IP splits data into small units called packets.

    • Each packet includes:

      • Sender IP address

      • Destination IP address

      • Other information (e.g. time to live)

  3. Routing

  1. Delivery (Best-Effort)

Types of IP Addresses

Static vs Dynamic IP Addresses

TypeDescription
Static IPDoes not change. Manually set. Used for servers.
Dynamic IPChanges over time. Assigned by DHCP. Most common.

IP Header

Every IP packet includes a header with important information:

HTTP / HTTPS 📝

HTTP (Hypertext Transfer Protocol) and HTTPS (Hypertext Transfer Protocol Secure) are both protocols used for transferring data between a web browser (client) and a web server. The primary difference lies in security and data protection.

Key Differences

FeatureHTTPHTTPS
Full NameHypertext Transfer ProtocolHypertext Transfer Protocol Secure
SecurityNo encryption; data sent in plain textData encrypted using SSL/TLS
Default Port80443
Data ProtectionVulnerable to interception and tamperingProtects against eavesdropping and tampering
Server AuthenticationNo verification of server identityUses digital certificates to verify server
URL Prefixhttp://https://
Use CaseGeneral browsing, non-sensitive dataSensitive data (logins, payments, personal)
SEO BenefitNo boostPreferred by search engines

Basic Workflow

  1. Connection Establishment: The client initiates a TCP connection to the server. HTTP typically operates over TCP/IP and uses port 80 for standard HTTP connections.

  2. Request-Response Cycle:

    • Request: Once the TCP connection is established, the client sends an HTTP request to the server. This request includes:

      • a request line (method, URL, HTTP version)

      • headers (host, user-agent, content-type, etc.)

      • sometimes a body (for methods like POST or PUT)

    • Response: The server processes the request and sends back an HTTP response. This response contains:

      • a status line (HTTP version, status code, status message)

      • response headers (content-type, content-length, server, etc.)

      • often a body containing the requested resource or data

  3. Connection Closure: After the response is delivered, the connection can be closed, or kept open for further requests if the header Connection: keep-alive is used.

    HTTP Methods

Status Codes

HTTP responses come with status codes that indicate the outcome of the request:

FTP / FTPS 📝

FTP

FTP stands for File Transfer Protocol. It’s one of the oldest protocols used to transfer files between two computers over a TCP/IP network (like the internet).

How It Works:

Security FTP is not secure by default:

FTPS

FTPS stands for FTP Secure or FTP over SSL/TLS.

Benefits of FTPS:

VPN

A VPN (Virtual Private Network) keeps your internet connection private and secure. It uses protocols to create a safe tunnel for your data.

Here are the most common VPN protocols:

ProtocolSpeedSecurityBest For
PPTP✅ Fast❌ WeakOld systems (not safe)
L2TP/IPsec⚠️ Okay✅ GoodBetter security
OpenVPN⚠️ Okay✅ GreatMost safe setups
IKEv2/IPsec✅ Fast✅ GreatPhones and mobile use
WireGuard✅ Fast✅ GreatModern, future VPNs

Streaming 📝

Streaming protocols are rules that control how audio and video are sent over the internet so that people can watch or listen in real time without downloading the entire file first.

There are two main types:

Common Streaming Protocols

ProtocolBest ForKey Features
HLSLive & on-demandWidely supported, adaptive quality
MPEG-DASHOn-demandOpen standard, flexible
RTMPLive streamingLow delay, used for uploading video
WebRTCVideo callsReal-time, works in browsers

Broadcasting 📝

Broadcast protocols are ways of sending data from one device to many devices at once on a network. They are used when the same message needs to reach a group of devices without sending it separately to each one.

How Broadcasting Works

Common Broadcast Protocols

TypeDescription
UnicastOne-to-one (sent to a single device)
BroadcastOne-to-all (sent to every device on LAN)
MulticastOne-to-many (sent to a specific group)

Data Exchange Methods 📝

REST (Representational State Transfer) 📝

REST is an architectural style for designing networked applications. It relies on a stateless, client-server, cacheable communications protocol — the HTTP (Hypertext Transfer Protocol).

RESTful systems use HTTP requests to perform CRUD (Create, Read, Update, Delete) operations on resources.

Key Concepts

Example of Data Exchange Using REST:

JSON 📝

JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy for humans to read and write, and easy for machines to parse and generate. It’s widely used in web applications to send and receive data between a server and a client.

Key Features of JSON

JSON Structure

JSON data is represented as key-value (called dictionaries in Python) pairs organized in a hierarchical structure. The basic building blocks of JSON are:

JSON Example

Here’s a complete example representing a student record:

{
  "student": {
    "id": 12345,
    "name": "John Doe",
    "age": 21,
    "isEnrolled": true,
    "courses": [
      {
        "courseName": "Mathematics",
        "courseCode": "MATH101",
        "credits": 3
      },
      {
        "courseName": "English Literature",
        "courseCode": "ENG201",
        "credits": 4
      }
    ],
    "contact": {
      "email": "john.doe@example.com",
      "phone": "555-1234"
    }
  }
}

JSON usage

JSON advantages

JSON disadvantages

XML 📝

XML (eXtensible Markup Language) is a versatile and widely-used format for storing and transporting data. Unlike JSON, which is primarily used for data interchange, XML is more commonly used for document storage, configuration files, and data interchange in enterprise systems.

Key Features of XML

XML Structure

XML Example

Here’s a complete example representing a student record in XML:

<?xml version="1.0" encoding="UTF-8"?>
<student>
  <id>12345</id>
  <name>John Doe</name>
  <age>21</age>
  <isEnrolled>true</isEnrolled>
  <courses>
    <course>
      <courseName>Mathematics</courseName>
      <courseCode>MATH101</courseCode>
      <credits>3</credits>
    </course>
    <course>
      <courseName>English Literature</courseName>
      <courseCode>ENG201</courseCode>
      <credits>4</credits>
    </course>
  </courses>
  <contact>
    <email>john.doe@example.com</email>
    <phone>555-1234</phone>
  </contact>
</student>

XML usage

XML advantages

XML Disadvantages

CSV & TSV

CSV (Comma-Separated Values) and TSV (Tab-Separated Values) are both formats used for storing and exchanging tabular data in a plain text format. In a CSV file, each line corresponds to a row of data, and each value in the row is separated by a comma. TSV is similar to CSV, but instead of commas, tabs are used to separate values.

CSV & TSV Key Features

CSV Structure

CSV Example

Name, Age, City
Alice, 30, New York
Bob, 25, Los Angeles
Charlie, 35, "San Francisco, CA"

TSV Structure

TSV Example

Name    Age    City
Alice    30    New York
Bob    25    Los Angeles
Charlie    35    San Francisco, CA

Key Differences

Advantages of CSV and TSV

Disadvantages of CSV and TSV