### **Protocol**

A **protocol** is a set of rules and standards that define how data is transmitted, received, and processed between devices or systems in a network. Protocols ensure that communication is consistent, reliable, and efficient.

#### Key Characteristics:

- **Standardization**: Protocols are often standardized (e.g., TCP/IPTCP/IP, HTTPHTTP, FTPFTP) to ensure compatibility across different systems.
    
- **Layered Structure**: In networking, protocols are organized into layers (e.g., OSI modelOSI model or TCP/IP modelTCP/IP model), each handling specific tasks like data transmission, error checking, or routing.
    
- **Examples**:
    
    - HTTP/HTTPSHTTP/HTTPS: Used for web browsing.
        
    - TCP/IPTCP/IP: Ensures reliable data delivery over the internet.
        
    - SMTPSMTP: Used for sending emails.
        
    - FTPFTP: Used for file transfers.

### **Node**

A **node** is any device or point in a network that can send, receive, or process data. Nodes are the building blocks of a network and can include computers, servers, routers, switches, or even IoT devices.

#### Key Characteristics:

- **Types of Nodes**:
    
    - **End Nodes**: Devices like computers, smartphones, or printers that are the source or destination of data.
        
    - **Intermediate Nodes**: Devices like routers or switches that help route data between end nodes.
        
- **Functionality**: Nodes can perform tasks like data storage, processing, or forwarding.
    
- **Examples**:
    
    - A laptop connected to a Wi-Fi network is an **end node**.
        
    - A router in a home network is an **intermediate node**.
        

---

### 3. **Network**

A **network** is a collection of interconnected nodes that communicate with each other using protocols to share resources, data, or services. Networks can range from small local setups to vast global systems like the internet.

#### Key Characteristics:

- **Types of Networks**:
    
    - LANLAN (Local Area Network): A small network within a single location, like a home or office.
        
    - WANWAN (Wide Area Network): A large network spanning multiple locations, like the internet.
        
    - MANMAN (Metropolitan Area Network): A network covering a city or campus.
        
    - PANPAN (Personal Area Network): A network for personal devices, like Bluetooth connections.
        
- **Components**:
    
    - Nodes (devices).
        
    - Links (wired or wireless connections).
        
    - Protocols (rules for communication).
        
- **Purpose**: Networks enable communication, resource sharing (e.g., printers, files), and collaboration.
    

---

### Relationship Between Protocol, Node, and Network

- **Protocols** define how **nodes** communicate within a **network**.
    
- **Nodes** are the physical or virtual entities that participate in the network.
    
- The **network** is the infrastructure that connects nodes and enables communication using protocols.
    

---

### Example: Sending an Email

1. **Network**: The internet connects your computer (node1node1​) to the email server (node2node2​).
    
2. **Node**: Your computer sends the email, and the email server receives it.
    
3. **Protocol**: SMTPSMTP (Simple Mail Transfer Protocol) defines how the email is transmitted between nodes.

| Feature                | $LAN$ (Local Area Network)      | $MAN$ (Metropolitan Area Network)   | $WAN$ (Wide Area Network)         |
| ---------------------- | ------------------------------- | ----------------------------------- | --------------------------------- |
| **Geographical Scope** | Small area (e.g., home, office) | Medium area (e.g., city, campus)    | Large area (e.g., country, globe) |
| **Range**              | Up to $1\ km$                   | Up to $100\ km$                     | Unlimited (global reach)          |
| **Speed**              | High ($1\ Gbps$ to $10\ Gbps$)  | Moderate ($100\ Mbps$ to $1\ Gbps$) | Lower ($10\ Mbps$ to $100\ Mbps$) |
| **Cost**               | Low                             | Moderate                            | High                              |
| **Ownership**          | Privately owned                 | Privately or publicly owned         | Publicly owned (e.g., ISPs)       |
| **Latency**            | Low                             | Moderate                            | High                              |
| **Reliability**        | High                            | Moderate                            | Lower                             |
| **Use Cases**          | - Home networks                 | - City-wide networks                | - Global internet                 |
|                        | - Office networks               | - University campuses               | - Corporate networks              |
|                        | - School labs                   | - Government networks               | - Cloud services                  |
| **Example**            | Wi-Fi in your house             | Fiber optic network in a city       | The internet                      |


### **OSI Model Overview**

The **OSI (Open Systems Interconnection) model** is a conceptual framework that standardizes the functions of a communication system into **7 layers**. Each layer has a specific role and interacts with the layers above and below it.

**PHONETICS**: **A**ll **P**eople **S**eem **T**o **N**eed **D**ata **P**reprocessing

---

### **OSI Model Layers and Their Roles**

| Layer | Name         | Role                                                                  | Data Unit    | Example                                                              |
| ----- | ------------ | --------------------------------------------------------------------- | ------------ | -------------------------------------------------------------------- |
| 7     | Application  | Provides interfaces for end-user applications (e.g., browsers, email) | **Data**     | HTTP, FTP, SMTP                                                      |
| 6     | Presentation | Translates data into a format the application layer can understand    | **Data**     | Encryption, compression (e.g., SSL/TLS)                              |
| 5     | Session      | Manages connections between applications                              | **Data**     | Establishes, maintains, and terminates sessions (e.g., RPC, NetBIOS) |
| 4     | Transport    | Ensures reliable data delivery and error recovery                     | **Segments** | TCP (reliable), UDP (unreliable)                                     |
| 3     | Network      | Handles routing and forwarding of data between devices                | **Packets**  | IP, ICMP, routers                                                    |
| 2     | Data Link    | Manages direct communication between devices on the same network      | **Frames**   | Ethernet, MAC addresses, switches                                    |
| 1     | Physical     | Transmits raw bits over a physical medium                             | **Bits**     | Cables, Wi-Fi, hubs                                                  |

---
### **OSI Model Layers Explained**


#### **1. Application Layer ($Layer\ 7$)**
- **Function**: Provides interfaces for end-user applications to communicate over a network. It enables services like email, file transfers, and web browsing.
- **Key Protocols**: $HTTP$, $HTTPS$, $FTP$, $SMTP$, $DNS$, $POP3$.
- **Data Unit**: **Data** (raw user data, such as an email or a web page).
- **Example**: When you open a website in your browser, the browser uses $HTTP$ to request the web page from the server.

---

#### **2. Presentation Layer ($Layer\ 6$)**
- **Function**: Translates data into a format that the application layer can understand. It handles encryption, compression, and data formatting.
- **Key Protocols**: $SSL/TLS$, $JPEG$, $MPEG$, $ASCII$.
- **Data Unit**: **Data** (formatted or encrypted data).
- **Example**: When you log in to a secure website, the $SSL/TLS$ protocol encrypts your data to protect it from eavesdropping.

---

#### **3. Session Layer ($Layer\ 5$)**
- **Function**: Manages sessions (connections) between applications. It establishes, maintains, and terminates communication sessions.
- **Key Protocols**: $RPC$ (Remote Procedure Call), $NetBIOS$, $PPTP$.
- **Data Unit**: **Data** (session control information).
- **Example**: When you start a video call, the session layer ensures the connection stays active and terminates it when the call ends.

---

#### **4. Transport Layer ($Layer\ 4$)**
- **Function**: Ensures reliable data delivery between devices. It handles error recovery, flow control, and data segmentation.
- **Key Protocols**: $TCP$ (Transmission Control Protocol), $UDP$ (User Datagram Protocol).
- **Data Unit**: **Segments** (for $TCP$) or **Datagrams** (for $UDP$).
- **Example**: When you download a file, $TCP$ breaks the file into **segments**, ensures they are delivered without errors, and reassembles them at the destination. If a segment is lost, $TCP$ retransmits it.

---

#### **5. Network Layer ($Layer\ 3$)**
- **Function**: Handles routing and forwarding of data between devices across different networks. It assigns logical addresses ($IP$ addresses) to devices and encapsulates data into **packets**.
- **Key Protocols**: $IP$ (Internet Protocol), $ICMP$ (Internet Control Message Protocol), $ARP$ (Address Resolution Protocol).
- **Data Unit**: **Packets** (data with source and destination $IP$ addresses).
- **Example**: When you send an email, the network layer determines the best path for the data to travel from your computer to the email server. It encapsulates the data into **packets**, each containing the source and destination $IP$ addresses.

---

#### **6. Data Link Layer ($Layer\ 2$)**
- **Function**: Manages direct communication between devices on the same network. It handles error detection, physical addressing ($MAC$ addresses), and encapsulates data into **frames**.
- **Key Protocols**: Ethernet, $PPP$ (Point-to-Point Protocol), $Wi-Fi$.
- **Data Unit**: **Frames** (data with source and destination $MAC$ addresses).
- **Example**: When your computer sends data to a printer on the same network, the data link layer encapsulates the data into **frames**, each containing the source and destination $MAC$ addresses. It ensures the data reaches the correct device.

---

#### **7. Physical Layer ($Layer\ 1$)**
- **Function**: Transmits raw bits (0s and 1s) over a physical medium (e.g., cables, Wi-Fi). It defines electrical, mechanical, and procedural standards for communication.
- **Key Protocols**: Ethernet cables, $Wi-Fi$, $DSL$, $USB$.
- **Data Unit**: **Bits** (raw binary data).
- **Example**: When you plug in an Ethernet cable, the physical layer converts the **frames** from the data link layer into electrical signals for transmission.

---
### **Packets and Frames Explained**

---

#### **1. Packets (Network Layer - $Layer\ 3$)**
- **Definition**: A **packet** is a unit of data used in the **Network Layer** to route information between devices across different networks. It contains both the **payload** (actual data) and **control information** (headers and trailers).
- **Purpose**: Packets enable efficient and reliable data transmission by breaking data into smaller chunks and adding routing information.

---
### **TCP Packet Header Explained**

The **TCP (Transmission Control Protocol)** header is a critical part of the TCP packet, ensuring reliable and ordered delivery of data between devices. Below is a breakdown of the TCP header fields based on the provided diagram:


##### **Packet Diagram**
![[TCP-packet-format.jpg]]

---

#### **Explanation of Each Field**

1. **Source Port (16 bits)**:
    
    - Identifies the sending port on the source device.
        
    - Example: If your browser is sending data, this could be a random port like `54321`.
        
2. **Destination Port (16 bits)**:
    
    - Identifies the receiving port on the destination device.
        
    - Example: For HTTP traffic, this is typically port `80`.
        
3. **Sequence Number (32 bits)**:
    
    - Tracks the order of data segments being sent.
        
    - Ensures data is reassembled correctly at the destination.
        
    - Example: The first segment might have a sequence number of `1000`, the next `2000`, and so on.
        
4. **Acknowledgement Number (32 bits)**:
    
    - Confirms receipt of data by acknowledging the next expected sequence number.
        
    - Example: If the receiver gets data up to sequence number `3000`, it sends an acknowledgment for `3001`.
        
5. **Data Offset (4 bits)**:
    
    - Specifies the size of the TCP header in 32-bit words.
        
    - Helps the receiver locate the start of the data payload.
        
6. **Reserved (3 bits)**:
    
    - Reserved for future use. Currently set to `0`.
        
7. **Flags (9 bits)**:
    
    - Control flags for TCP communication:
        
        - **URG**: Urgent pointer field is significant.
            
        - **ACK**: Acknowledgment field is significant.
            
        - **PSH**: Push function (send data immediately).
            
        - **RST**: Reset the connection.
            
        - **SYN**: Synchronize sequence numbers (used during connection establishment).
            
        - **FIN**: No more data from sender (used during connection termination).
            
8. **Window Size (16 bits)**:
    
    - Indicates the size of the receiving window (buffer space available for incoming data).
        
    - Used for flow control.
        
9. **Checksum (16 bits)**:
    
    - Ensures data integrity by detecting errors in the TCP header and payload.
        
10. **Urgent Pointer (16 bits)**:
    
    - Points to the end of urgent data (if the `URG` flag is set).
        
11. **Options (Variable)**:
    
    - Optional fields for additional functionality (e.g., maximum segment size, window scaling).
        
12. **Padding (Variable)**:
    
    - Ensures the header ends on a 32-bit boundary.
        
13. **Data (Payload)**:
    
    - The actual data being transmitted (e.g., part of a file or message).
---

##### **Example of a Packet**
- When you send an email, the email content is broken into smaller **packets**. Each packet contains:
  - **Header**: Source $IP$ (your computer), Destination $IP$ (email server), and protocol ($TCP$).
  - **Payload**: Part of the email content (e.g., "Hello, how are you?").
  - **Trailer**: Error-checking data to ensure the packet is not corrupted.

---

#### **2. Frames (Data Link Layer - $Layer\ 2$)**
- **Definition**: A **frame** is a unit of data used in the **Data Link Layer** to manage communication between devices on the same network. It encapsulates **packets** and adds physical addressing ($MAC$ addresses).
- **Purpose**: Frames ensure data is delivered to the correct device on the same network and handle error detection.

---

##### **Frame Structure**
A frame typically consists of the following components:
1. **Header**:
   - **Preamble**: Synchronizes communication between devices (7 bytes).
   - **Start Frame Delimiter ($SFD$)**: Marks the start of the frame (1 byte).
   - **Source MAC Address**: The $MAC$ address of the sender (6 bytes).
   - **Destination MAC Address**: The $MAC$ address of the receiver (6 bytes).
   - **EtherType**: Indicates the type of payload (e.g., $IPv4$, $ARP$) (2 bytes).
2. **Payload**:
   - The encapsulated **packet** from the Network Layer (46 to 1500 bytes for Ethernet).
3. **Trailer**:
   - **Frame Check Sequence ($FCS$)**: Ensures data integrity by detecting errors (4 bytes).

---

##### **Frame Diagram**
![[Pasted image 20250125144638.png]]

---

##### **Example of a Frame**
- When your computer sends data to a printer on the same network:
  - The **packet** from the Network Layer is encapsulated into a **frame**.
  - **Header**: Source $MAC$ (your computer’s $MAC$), Destination $MAC$ (printer’s $MAC$), and EtherType ($IPv4$).
  - **Payload**: The encapsulated packet (e.g., part of a document to be printed).
  - **Trailer**: $FCS$ to ensure the frame is not corrupted.

---

### **Key Differences Between Packets and Frames**
| Feature            | **Packet** (Network Layer)                     | **Frame** (Data Link Layer)                  |
| ------------------ | ---------------------------------------------- | -------------------------------------------- |
| **Layer**          | $Layer\ 3$                                     | $Layer\ 2$                                   |
| **Purpose**        | Routes data between networks                   | Delivers data to devices on the same network |
| **Addressing**     | Uses $IP$ addresses                            | Uses $MAC$ addresses                         |
| **Encapsulation**  | Encapsulates **segments** from Transport Layer | Encapsulates **packets** from Network Layer  |
| **Error Checking** | Uses checksum in the header                    | Uses $FCS$ in the trailer                    |

---
### **Data Link Layer: Sublayers and Their Importance**

The **Data Link Layer** ($Layer\ 2$) is divided into two sublayers:
1. **Logical Link Control (LLC)**
2. **Media Access Control (MAC)**

These sublayers work together to ensure reliable and efficient communication between devices on the same network.

---

#### **1. Logical Link Control (LLC)**
- **Function**:
  - Manages communication between devices by providing a common interface to the **Network Layer** ($Layer\ 3$).
  - Handles **flow control** and **error checking** for data frames.
- **Key Responsibilities**:
  - **Multiplexing**: Allows multiple protocols (e.g., $IPv4$, $IPv6$, $ARP$) to share the same physical link.
  - **Error Control**: Detects and corrects errors in transmitted frames.
  - **Flow Control**: Ensures the sender does not overwhelm the receiver with data.
- **Importance**:
  - Provides a standardized way for the **Network Layer** to interact with the **Data Link Layer**.
  - Ensures data integrity and reliability across different network protocols.

---

#### **2. Media Access Control (MAC)**
- **Function**:
  - Manages access to the physical medium (e.g., Ethernet cable, Wi-Fi) and controls how devices share the network.
  - Handles **addressing** and **framing** of data.
- **Key Responsibilities**:
  - **MAC Addressing**: Assigns a unique $MAC$ address to each device for identification on the network.
  - **Frame Delimiting**: Adds start and stop bits to frames for synchronization.
  - **Collision Control**: Implements protocols like $CSMA/CD$ (Carrier Sense Multiple Access with Collision Detection) to avoid collisions in shared media.
- **Importance**:
  - Ensures efficient and fair use of the network medium.
  - Enables devices to communicate directly on the same network using $MAC$ addresses.

---

### **Comparison of LLC and MAC Sublayers**
| Feature               | **Logical Link Control (LLC)**            | **Media Access Control (MAC)**                   |
| --------------------- | ----------------------------------------- | ------------------------------------------------ |
| **Primary Role**      | Interfaces with the Network Layer         | Manages access to the physical medium            |
| **Key Functions**     | Error control, flow control, multiplexing | MAC addressing, framing, collision handling      |
| **Importance**        | Ensures data integrity and reliability    | Enables efficient and fair network access        |
| **Example Protocols** | $IEEE\ 802.2$                             | Ethernet ($IEEE\ 802.3$), Wi-Fi ($IEEE\ 802.11$) |

---

### **Importance of the Data Link Layer**
1. **Reliable Communication**:
   - Ensures data is transmitted without errors and in the correct order.
2. **Efficient Resource Utilization**:
   - Manages access to the network medium to avoid collisions and ensure fair usage.
3. **Device Identification**:
   - Uses $MAC$ addresses to uniquely identify devices on the same network.
4. **Interoperability**:
   - Provides a common interface for different network protocols and technologies.

---

### **Example: Ethernet Communication**
1. **LLC Sublayer**:
   - Encapsulates the $IP$ packet from the Network Layer into an LLC frame.
   - Adds error-checking information and ensures flow control.
2. **MAC Sublayer**:
   - Adds source and destination $MAC$ addresses to the frame.
   - Implements $CSMA/CD$ to avoid collisions on the Ethernet network.
3. **Physical Layer**:
   - Transmits the frame as raw bits over the Ethernet cable.


### **Transportation Modes in Networking**

Transportation modes define how data flows between devices in a network. There are three main types:

---

#### **1. Simplex**
- **Definition**: Communication is **unidirectional**. Data flows in only one direction, from the sender to the receiver.
- **Example**:
  - Keyboard to computer (you send data to the computer, but the computer doesn’t send data back to the keyboard).
  - Television broadcasting (TV station sends signals to your TV, but your TV doesn’t send signals back).
- **Use Case**: Suitable for scenarios where feedback or two-way communication is not required.

---

#### **2. Half-Duplex**
- **Definition**: Communication is **bidirectional**, but data flows in **one direction at a time**. Devices take turns sending and receiving data.
- **Example**:
  - Walkie-talkies (one person speaks while the other listens, and then they switch roles).
  - Traditional Ethernet networks (devices share the same medium and take turns transmitting data).
- **Use Case**: Useful when the communication medium is shared, and simultaneous two-way communication is not necessary.

---

#### **3. Full-Duplex**
- **Definition**: Communication is **bidirectional**, and data flows in **both directions simultaneously**. Devices can send and receive data at the same time.
- **Example**:
  - Telephone calls (both parties can speak and listen simultaneously).
  - Modern Ethernet networks (using switches, devices can send and receive data simultaneously).
- **Use Case**: Ideal for high-speed, real-time communication where simultaneous two-way communication is required.

---

### **Comparison of Transportation Modes**
| Feature          | **Simplex**               | **Half-Duplex**           | **Full-Duplex**           |
|------------------|---------------------------|---------------------------|---------------------------|
| **Direction**    | Unidirectional            | Bidirectional (one at a time) | Bidirectional (simultaneous) |
| **Example**      | Keyboard to computer      | Walkie-talkies            | Telephone calls           |
| **Efficiency**   | Low                       | Medium                    | High                      |
| **Complexity**   | Simple                    | Moderate                  | Complex                   |
| **Use Case**     | Broadcasting, sensors     | Shared medium networks    | Real-time communication   |
![[data-transmission-modes-in-networking.png]]
---

### **Mbps vs MBps: Understanding the Difference**

#### **1. Mbps (Megabits per Second)**
- **Definition**: Measures **data transfer speed** in **millions of bits per second**.
- **Usage**: Commonly used to describe **network speeds** (e.g., internet bandwidth).
- **Example**:
  - A 100 Mbps internet connection means the network can transfer 100 million bits per second.
- **Formula**:
  $1\ Mbps = 1,000,000\ bits\ per\ second$

#### **2. MBps (Megabytes per Second)**
- **Definition**: Measures **data transfer speed** in **millions of bytes per second**.
- **Usage**: Commonly used to describe **file transfer speeds** (e.g., downloading a file).
- **Example**:
  - A download speed of 12.5 MBps means you can download 12.5 million bytes per second.
- **Formula**:
  $1\ MBps = 1,000,000\ bytes\ per\ second$

---

#### **Key Differences Between Mbps and MBps**
| Feature        | **Mbps**                  | **MBps**                   |
| -------------- | ------------------------- | -------------------------- |
| **Unit**       | Megabits per second       | Megabytes per second       |
| **Usage**      | Network speed             | File transfer speed        |
| **Conversion** | 1 byte = 8 bits           | 1 MBps = 8 Mbps            |
| **Example**    | Internet speed (100 Mbps) | Download speed (12.5 MBps) |

---

#### **Conversion Between Mbps and MBps**
- To convert **Mbps to MBps**, divide by 8:
  $$
  MBps = \frac{Mbps}{8}
  $$
- Example:
  - A 100 Mbps connection can transfer data at:
$$
    \frac{100\ Mbps}{8} = 12.5\ MBps
    $$

---
### **Networking Devices Explained**

---

#### **1. Network Interface Card (NIC)**
- **Function**: Connects a device (e.g., computer, printer) to a network. It provides a unique **MAC address** for identification.
- **Role**: Enables communication between the device and the network.
- **Example**:
  - A laptop uses its **NIC** to connect to a Wi-Fi network. The NIC converts data into signals that can be transmitted over the network.

---

#### **2. Repeaters**
- **Function**: Amplifies or regenerates signals to extend the range of a network. It compensates for signal degradation over long distances.
- **Role**: Ensures signals can travel farther without losing quality.
- **Example**:
  - In a large office, a **repeater** is used to boost the Wi-Fi signal so it reaches all areas of the building.

---

### **Simplified Networking Devices Summary**

---

#### **1. Hub**
- **What it does**: A hub is a device that **broadcasts data to all devices** connected to it, regardless of the intended recipient.
- **Analogy**: Like a loudspeaker in a room—everyone hears the message, even if it’s meant for only one person.

---

#### **2. Switch**
- **What it does**: A switch is a **smarter hub** that forwards data **only to the intended device** based on **MAC addresses**.
- **Analogy**: Like a postal worker who delivers mail only to the correct address.

---

#### **3. Bridge**
- **What it does**: A bridge connects **two network segments** and filters traffic so that data is forwarded **only to the intended segment**.
- **Analogy**: Like a toll bridge that only allows certain vehicles to pass between two cities.

---

#### **4. Router**
- **What it does**: A router is like a **combination of a switch and a bridge**, but it works at a higher level. It connects **different networks** (e.g., your home network to the internet) and routes data based on **IP addresses**.
- **Analogy**: Like a traffic cop directing cars (data) between different roads (networks).

---

#### **5. Gateway**
- **What it does**: A gateway connects **two networks that use different protocols** and translates data between them.
- **Analogy**: Like a translator who helps two people speaking different languages communicate.

---

### **Comparison of Networking Devices**
| Device            | **Function**                              | **Role**                                  | **Example**                              |
|-------------------|-------------------------------------------|-------------------------------------------|------------------------------------------|
| **NIC**           | Connects devices to a network             | Enables network communication             | Laptop connecting to Wi-Fi               |
| **Repeater**      | Amplifies signals                         | Extends network range                     | Boosting Wi-Fi in a large office         |
| **Hub**           | Connects multiple devices                 | Central connection point                  | Small home network                       |
| **Bridge**        | Connects network segments                 | Reduces congestion                        | Connecting departments in a university   |
| **Switch**        | Connects devices and forwards data        | Efficient and secure communication        | Office network with multiple devices     |
| **Router**        | Connects different networks               | Routes data between networks              | Home router connecting to the internet   |
| **Gateway**       | Connects dissimilar networks              | Translates between protocols              | Corporate email to internet              |

---

### **Key Takeaways**
- **NIC**: Connects devices to a network.
- **Repeater**: Extends network range by amplifying signals.
- **Hub**: Connects devices but broadcasts data to all.
- **Bridge**: Connects network segments and filters traffic.
- **Switch**: Connects devices and forwards data efficiently(MAC addresses).
- **Router**: Connects and routes data between networks(IP addresses).
- **Gateway**: Connects and translates between dissimilar networks.

---
![[Pasted image 20250125153157.png]]![[Pasted image 20250125153206.png]]



### **Fiber Optics Explained**

---

#### **1. Fiber Optics Basics**
- **Definition**: Fiber optics is a technology that uses **thin strands of glass or plastic (fibers)** to transmit light signals over long distances.
- **Key Principle**: Light is trapped inside the fiber by **total internal reflection**.

---

#### **2. Light Rays in Fiber Optics**
- **Three Examples of Light Rays**:
  1. **Ray 1**: Light hits the air/silica boundary at a **small angle** and **refracts out** of the fiber.
  2. **Ray 2**: Light hits the boundary at the **critical angle** and travels along the surface.
  3. **Ray 3**: Light hits the boundary at a **larger angle** and is **totally internally reflected**, staying trapped inside the fiber.
- **Total Internal Reflection**: Occurs when light hits the boundary at an angle greater than the critical angle, ensuring it stays inside the fiber.
![[Pasted image 20250125153546.png]]
![[Pasted image 20250125153611.png]]
---

#### **3. Transmission of Light through Fiber**
- **How it Works**: Light signals are transmitted through the fiber by bouncing off the walls due to total internal reflection.
- **Attenuation**: Loss of signal strength as light travels through the fiber. In the **infrared region**, attenuation is minimized, making it ideal for long-distance communication.
![[Pasted image 20250125153651.png]]
---

#### **4. Fiber Cables**
- **(a) Side View of a Single Fiber**:
  - **Core**: Central region where light travels.
  - **Cladding**: Outer layer that reflects light back into the core.
  - **Coating**: Protective layer around the cladding.
- **(b) End View of a Sheath with Three Fibers**:
  - Multiple fibers are bundled together inside a single sheath for increased capacity.
![[Pasted image 20250125153721.png]]


---

#### **5. Fiber Optic Networks**
- **Definition**: Networks that use fiber optic cables to transmit data as light signals.
- **Advantages**:
  - High bandwidth.
  - Low attenuation.
  - Immune to electromagnetic interference.
- **Applications**:
  - Internet backbone.
  - Telecommunications.
  - Medical imaging.
  
![[Pasted image 20250125153751.png]]
---

### **Wireless Transmission Explained**

---

#### **1. The Electromagnetic Spectrum**
- **Definition**: The range of all types of electromagnetic radiation, from **radio waves** to **gamma rays**.
- **Key Bands for Wireless Communication**:
  - Radio waves.
  - Microwaves.
  - Infrared.
  - Visible light.
  ![[Pasted image 20250125165533.png]]
##### **Key Concepts in Electromagnetic Communication**
- **Modulation**: Encoding information onto electromagnetic waves by varying their amplitude, frequency, or phase.
  - **AM (Amplitude Modulation)**: Varies the amplitude of the wave.
  - **FM (Frequency Modulation)**: Varies the frequency of the wave.
- **Bandwidth**: The range of frequencies available for communication. Higher bandwidth allows more data to be transmitted.
- **Attenuation**: Loss of signal strength as it travels through a medium. Different frequencies experience different levels of attenuation.
![[Pasted image 20250125165804.png]]

---

#### **2. Radio Transmission**
- **Definition**: Uses **radio waves** (low-frequency electromagnetic waves) to transmit data over long distances.
- **Applications**:
  - AM/FM radio broadcasting.
  - Wi-Fi networks.
  - Cellular communication (e.g., 4G, 5G).
- **Advantages**:
  - Long range.
  - Penetrates walls and obstacles.
- **Disadvantages**:
  - Limited bandwidth.
  - Susceptible to interference.
![[Pasted image 20250125165844.png]]
---

#### **3. Microwave Transmission**
- **Definition**: Uses **microwaves** (higher-frequency electromagnetic waves) for point-to-point communication.
- **Applications**:
  - Satellite communication.
  - Radar systems.
  - Microwave links for long-distance communication.
- **Advantages**:
  - High bandwidth.
  - Suitable for line-of-sight communication.
- **Disadvantages**:
  - Requires clear line of sight.
  - Affected by weather conditions.

---

#### **4. Infrared and Millimeter Waves**
- **Infrared Transmission**:
  - **Definition**: Uses **infrared light** for short-range communication.
  - **Applications**:
    - Remote controls.
    - Infrared data links (e.g., IrDA).
  - **Advantages**:
    - Secure (does not penetrate walls).
    - Low cost.
  - **Disadvantages**:
    - Short range.
    - Requires line of sight.
- **Millimeter Waves**:
  - **Definition**: Uses **high-frequency waves** (30 GHz to 300 GHz) for high-speed communication.
  - **Applications**:
    - 5G networks.
    - Wireless HDMI.
  - **Advantages**:
    - Extremely high bandwidth.
  - **Disadvantages**:
    - Short range.
    - Easily blocked by obstacles.

---

#### **5. Lightwave Transmission**
- **Definition**: Uses **visible light** or **lasers** for wireless communication.
- **Applications**:
  - Li-Fi (Light Fidelity).
  - Free-space optical communication.
- **Advantages**:
  - Extremely high bandwidth.
  - Secure (light does not penetrate walls).
- **Disadvantages**:
  - Requires line of sight.
  - Affected by environmental conditions (e.g., fog, dust).
![[Pasted image 20250125165903.png]]

---

### **Key Takeaways**
- **Electromagnetic Spectrum**: The range of electromagnetic waves used for wireless communication.
- **Radio Transmission**: Long-range, low-frequency communication (e.g., Wi-Fi, cellular).
- **Microwave Transmission**: High-bandwidth, line-of-sight communication (e.g., satellite links).
- **Infrared and Millimeter Waves**:
  - Infrared: Short-range, secure communication (e.g., remote controls).
  - Millimeter Waves: High-speed, short-range communication (e.g., 5G).
- **Lightwave Transmission**: High-bandwidth, secure communication using visible light or lasers (e.g., Li-Fi).

### **Communication Satellites Explained (Not important)**

---

#### **1. Communication Satellites**
- **Definition**: Artificial satellites placed in orbit to facilitate communication over long distances by relaying signals between Earth-based stations.
- **Functions**:
  - Transmit TV, radio, and internet signals.
  - Enable global communication (e.g., phone calls, GPS).
- **Advantages**:
  - Wide coverage area.
  - Suitable for remote and rural areas.
- **Disadvantages**:
  - High initial cost.
  - Signal latency (delay).
![[Pasted image 20250125170630.png]]
![[Pasted image 20250125170702.png]]
---

#### **2. Geostationary Satellites (GEO)**
- **Orbit**: Positioned at **35,786 km** above the equator, matching Earth’s rotation.
- **Characteristics**:
  - **Fixed Position**: Appears stationary relative to Earth.
  - **Coverage**: Covers about one-third of the Earth’s surface.
- **Uses**:
  - TV broadcasting.
  - Weather monitoring.
  - Long-distance communication.
- **Advantages**:
  - Continuous coverage of a specific area.
  - High bandwidth.
- **Disadvantages**:
  - High latency (~250 ms round-trip delay).
  - Expensive to launch and maintain.

---

#### **3. Medium-Earth Orbit Satellites (MEO)**
- **Orbit**: Positioned between **2,000 km** and **35,786 km** above Earth.
- **Characteristics**:
  - **Coverage**: Covers a smaller area than GEO satellites.
  - **Latency**: Lower than GEO but higher than LEO.
- **Uses**:
  - GPS and navigation systems.
  - Regional communication networks.
- **Advantages**:
  - Lower latency than GEO.
  - Moderate coverage area.
- **Disadvantages**:
  - Requires multiple satellites for global coverage.
  - Moderate cost.

---

#### **4. Low-Earth Orbit Satellites (LEO)**
- **Orbit**: Positioned between **160 km** and **2,000 km** above Earth.
- **Characteristics**:
  - **Coverage**: Covers a small area but moves quickly.
  - **Latency**: Very low (~20-30 ms round-trip delay).
- **Uses**:
  - Internet services (e.g., Starlink).
  - Earth observation.
  - Real-time communication.
- **Advantages**:
  - Low latency.
  - High data transfer speeds.
- **Disadvantages**:
  - Requires a large constellation of satellites for global coverage.
  - Frequent replacement due to shorter orbital lifespan.

---

#### **5. Satellites versus Fiber**
- **Satellites**:
  - **Advantages**:
    - Global coverage, including remote areas.
    - Quick deployment.
  - **Disadvantages**:
    - Higher latency (especially GEO).
    - Susceptible to weather interference.
- **Fiber Optics**:
  - **Advantages**:
    - Extremely high bandwidth.
    - Low latency.
    - Immune to electromagnetic interference.
  - **Disadvantages**:
    - Expensive to install in remote areas.
    - Limited to areas with infrastructure.

---

### **Key Takeaways**
- **Geostationary Satellites (GEO)**: High-altitude, fixed-position satellites for TV and long-distance communication.
- **Medium-Earth Orbit Satellites (MEO)**: Used for GPS and regional communication, with moderate latency.
- **Low-Earth Orbit Satellites (LEO)**: Low-latency, high-speed satellites for internet and real-time communication.
- **Satellites vs Fiber**:
  - Satellites: Global coverage, higher latency.
  - Fiber: High bandwidth, low latency, but limited to areas with infrastructure.

---

### **Multiplexing and Networks Explained**

---

#### **1. Multiplexing**
- **Definition**: A technique that allows the **simultaneous transmission of multiple signals** across a single data link.
- **Hardware**: The device used for multiplexing is called a **MUX** (Multiplexer).
- **Purpose**: Enables **cost-effective resource sharing** by efficiently utilizing links and nodes.

---

#### **2. Types of Multiplexing**
- **Frequency Division Multiplexing (FDM)**:
  - Divides the bandwidth of a communication channel into **multiple frequency bands**.
  - Each signal is assigned a unique frequency band.
  - Example: Radio and TV broadcasting.
   ![[Pasted image 20250125171525.png]]
- **Wavelength Division Multiplexing (WDM)**:
  - Used in fiber optics, where multiple signals are transmitted using **different wavelengths of light**.
  - Example: High-capacity fiber optic networks.
  - ![[Pasted image 20250125171416.png]]
- **Time Division Multiplexing (TDM)**:
  - Divides the channel into **time slots**, with each signal assigned a specific slot.
  - **Synchronous TDM**: Fixed time slots are allocated, even if no data is transmitted.
  - **Asynchronous TDM**: Time slots are allocated dynamically based on demand.
  - Example: Telephone networks.
  - ![[images.png]]
- **Statistical Multiplexing**:
  - Data is transmitted based on the **demand of each flow**.
  - More efficient than TDM, as it dynamically allocates bandwidth.
  - Example: Packet-switched networks.

## **Ports, Sockets, and TCP Client-Server Interaction**

---

#### **1. Port**
- **Definition**: A **virtual point** where network connections start and end.
- **Characteristics**:
  - Software-based and managed by the operating system.
  - Each port is associated with a specific process or service.
  - Allows differentiation between traffic types (e.g., email vs. web traffic).
- **Functions**:
  - Define an **endpoint** for communication.
  - Initiate and accept connections.
  - Send and receive data.
  - Terminate connections gracefully.
- **Examples**:
  - **FTP**: Port 21 (file transfer).
  - **HTTP**: Port 80 (web browsing).
  - **SMTP/POP3**: Ports 25/110 (email).
  - **DHCP** : Ports 67/68

---

#### **2. Types of Sockets**
- **Stream Socket (Connection-Oriented)**:
  - Uses **TCP** for reliable, error-free communication.
  - Ensures data arrives in order.
  - Examples: Telnet/SSH, HTTP.
- **Datagram Socket (Connectionless)**:
  - Uses **UDP** for fast, best-effort communication.
  - Packets may be lost or arrive out of order.
  - Examples: Streaming audio/video (e.g., RealPlayer).

---

#### **3. FTP Commands and Responses**
- **Sample Commands**:
  - `USER username`: Specifies the username.
  - `PASS password`: Specifies the password.
  - `LIST`: Returns a list of files in the current directory.
  - `RETR filename`: Retrieves a file from the server.
  - `STOR filename`: Uploads a file to the server.
- **Sample Responses**:
  - `331 Username OK, password required`.
  - `125 Data connection already open; transfer starting`.
  - `425 Can’t open data connection`.
  - `452 Error writing file`.

---

#### **4. TCP Client-Server Interaction**
![[Pasted image 20250125171909.png]]
---

![[Pasted image 20250125171958.png]]

## **Network Requirements and Performance Measures**

---

#### **1. Bandwidth**
- **Definition**: The **maximum data transfer rate** of a network or communication channel, measured in **bits per second (bps)**.
- **Importance**:
  - Determines how much data can be transmitted at once.
  - Higher bandwidth allows faster data transfer.
- **Example**:
  - A network with a bandwidth of **100 Mbps** can transfer up to 100 million bits per second.

---

#### **2. Throughput**
- **Definition**: The **actual data transfer rate** achieved in a network, measured in **bits per second (bps)**.
- **Importance**:
  - Reflects real-world performance, considering factors like congestion and errors.
  - Throughput is often **lower than bandwidth** due to network overhead.
- **Example**:
  - A network with **100 Mbps** bandwidth might achieve a throughput of **80 Mbps** due to congestion.

---

#### **3. Latency/Delay**
- **Definition**: The **time taken** for data to travel from the source to the destination, measured in **milliseconds (ms)**.
- **Types of Latency**:
  - **Propagation Delay**: Time taken for a signal to travel through the medium.
  - **Transmission Delay**: Time taken to push all bits of a packet onto the link.
  - **Processing Delay**: Time taken by routers or switches to process the packet.
  - **Queuing Delay**: Time spent by a packet waiting in a queue for transmission.
- **Importance**:
  - Lower latency is critical for real-time applications (e.g., video calls, gaming).
- **Example**:
  - A latency of **50ms** is acceptable for most applications, but **>200ms** can cause noticeable delays.

---
### **Network Throughput and Latency Calculations**

---

#### **1. Throughput Calculation**
- **Given**:
  - Bandwidth = **10 Mbps**.
  - Frames per minute = **12,000**.
  - Bits per frame = **10,000**.
- **Steps**:
  1. Calculate **bits per second (bps)**:
     $$
     \text{Bits per second} = \frac{\text{Frames per minute} \times \text{Bits per frame}}{60}
     $$
     $$
     \text{Bits per second} = \frac{12,000 \times 10,000}{60} = 2,000,000\ \text{bps} = 2\ \text{Mbps}
     $$
  2. **Throughput** = **2 Mbps**.

---

#### **2. Propagation Delay Formula**
- **Formula**:
  $$
  \text{Propagation Delay} = \frac{\text{Distance}}{\text{Propagation Speed}}
  $$

---

#### **3. Transmission Delay Formula**
- **Formula**:
  $$
  \text{Transmission Delay} = \frac{\text{Message Size}}{\text{Bandwidth (bps)}}
  $$

---

#### **4. Latency Formula**
- **Formula**:
  $$
  \text{Latency} = \text{Propagation Delay} + \text{Transmission Delay} + \text{Queuing Time} + \text{Processing Time}
  $$

---

#### **5. Propagation Time Calculation**
- **Given**:
  - Distance = **12,000 km** = \($12,000 \times 10^3\ \text{m}$\).
  - Propagation speed = ($2.4 \times 10^8\ \text{m/s}$).
- **Calculation**:
  $$
  \text{Propagation Delay} = \frac{12,000 \times 10^3}{2.4 \times 10^8} = 0.05\ \text{seconds} = 50\ \text{ms}
  $$

---
