Skip to content

Amitaibou/NetworkFinalProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 Network Final Project

Adaptive Video Streaming over TCP and RUDP

Python Protocol Streaming University

βš™οΈ Requirements

  • Python 3.10+
  • FFmpeg ( used for TS to MP4 conversion)

Tested on:

  • Windows 11
  • Python 3.10

Running the Project on a New Computer

This document explains exactly how to run the project from scratch on another computer.

Follow the steps in order.


1. Install Python

The project was developed and tested using:

Python 3.10+

Check if Python is installed:

python --version

If Python is not installed, download it from:

https://www.python.org/downloads/

During installation make sure to enable:

Add Python to PATH


2. Install required Python packages

Open a terminal inside the project folder and run:

pip install -r requirements.txt

If the file requirements.txt does not exist, install manually:


3. Install FFmpeg (optional but recommended)

FFmpeg is used to convert downloaded video from .ts to .mp4 format.

Check if FFmpeg is installed:

ffmpeg -version

If it is not installed, download it from:

https://ffmpeg.org/download.html

Add FFmpeg to the system PATH.

If FFmpeg is not installed the program will still work, but the video will remain in .ts format instead of .mp4.

Most video players such as VLC can still play .ts files.


4. Clone or download the project

Clone the repository:

git clone https://github.com/Amitaibou/NetworkFinalProject.git

Then enter the project directory:

cd finalProject

If the project was downloaded as a ZIP file, simply extract it and open a terminal in the project root folder.


5. Prepare video segments

The system streams segmented videos.

Source videos must be placed in the following directory:

video_sources/

Example structure:

video_sources/ video1.mp4 video2.mp4

After placing the videos, run the preparation script:

python prepare_video.py

This script will automatically generate segmented videos in multiple quality levels.

The script creates the following structure:

assets/videos/video1/

  • low/
  • mid/
  • high/

assets/videos/video2/

  • low/
  • mid/
  • high/

Each folder contains multiple video segments.

This step only needs to be performed once.


5. Important notes

If the assets/videos folder is empty, run:

python prepare_video.py

before starting the servers.

All servers must run in separate terminals.

Do not close the servers while the client is downloading video.


End of instructions.

πŸ“Œ Overview

This project presents a simplified network-based video delivery system implemented in Python.

It combines several networking components into one integrated application, including:

  • DHCP client/server for dynamic IP assignment
  • DNS client/server for domain name resolution
  • Application server for segmented video delivery
  • TCP and custom Reliable UDP (RUDP) transport
  • Manual and adaptive quality selection

The purpose of the project is to demonstrate how a client can obtain an IP address, resolve a service name, connect to a video server, and download segmented video while comparing different transport mechanisms.


✨ Main Features

  • Dynamic IP assignment using DHCP
  • Domain name resolution using DNS
  • Video delivery over TCP
  • Video delivery over custom Reliable UDP (RUDP)
  • Support for:
    • Stop & Wait
    • Go-Back-N
    • Selective Repeat
  • Manual quality selection:
    • low
    • mid
    • high
  • Adaptive quality selection based on measured bandwidth
  • Packet loss simulation for RUDP testing
  • Logging, runtime metrics, and summary statistics
  • Automatic TS to MP4 conversion after download

🧱 System Architecture

flowchart LR
    C[Client] -->|DHCP Discover / Request| D[DHCP Server]
    C -->|DNS Query| N[DNS Server]
    C -->|TCP or RUDP Video Requests| A[Application Server]

    D -->|Assigned IP Lease| C
    N -->|Resolved IP Address| C
    A -->|Manifest + Video Segments| C
Loading

πŸ” Client Execution Flow

flowchart TD
    S[Start Client] --> H[Request IP from DHCP]
    H --> I[Receive Lease]
    I --> J[Query DNS]
    J --> K{Resolved domain is video server?}
    K -- No --> L[Show resolved IP only]
    K -- Yes --> M[Fetch manifest]
    M --> N[Select video]
    N --> O[Select transport]
    O --> P{RUDP selected?}
    P -- Yes --> Q[Choose RUDP mode]
    P -- No --> R[Continue]
    Q --> R
    R --> T[Choose Auto or Manual quality]
    T --> U[Download all segments]
    U --> V[Merge output]
    V --> W[Convert TS to MP4]
    W --> X[Open result]
Loading

πŸ—‚οΈ Project Structure

finalProject/
β”œβ”€β”€ assets/
β”‚   └── videos/
β”‚       β”œβ”€β”€ video1/
β”‚       β”‚   β”œβ”€β”€ low/
β”‚       β”‚   β”œβ”€β”€ mid/
β”‚       β”‚   └── high/
β”‚       └── video2/
β”‚           β”œβ”€β”€ low/
β”‚           β”œβ”€β”€ mid/
β”‚           └── high/
β”‚
β”œβ”€β”€ client/
β”‚   β”œβ”€β”€ app_client.py
β”‚   β”œβ”€β”€ dhcp_client.py
β”‚   └── dns_client.py
β”‚
β”œβ”€β”€ protocol/
β”‚   β”œβ”€β”€ config.py
β”‚   β”œβ”€β”€ logger.py
β”‚   └── rudp.py
β”‚
β”œβ”€β”€ servers/
β”‚   β”œβ”€β”€ app_server.py
β”‚   β”œβ”€β”€ dhcp_server.py
β”‚   └── dns_server.py
β”‚
β”œβ”€β”€ video_sources/
β”‚   β”œβ”€β”€ video1.mp4
β”‚   └── video2.mp4
β”‚
β”œβ”€β”€ prepare_video.py
└── README.md

πŸš€ How to Run

Open four separate terminals from the project root.

1️⃣ Start DHCP Server

python servers/dhcp_server.py

2️⃣ Start DNS Server

python servers/dns_server.py

3️⃣ Start Application Server

python servers/app_server.py

4️⃣ Start Client

python client/app_client.py

πŸŽ₯ Preparing Videos


Place source video files inside:

video_sources/

Then run:

python prepare_video.py

This script generates segmented videos in multiple quality levels under:

assets/videos/

Example:

assets/videos/barcelona/
β”œβ”€β”€ low/
β”œβ”€β”€ mid/
└── high/

βš™οΈ Supported Transport Modes

  • Transport Mode Description
  • TCP Built-in Reliable transport using standard TCP
  • RUDP Stop & Wait Sends one packet at a time, simple but slower
  • RUDP Go-Back-N Uses a sending window, retransmits a range on loss
  • RUDP Selective Repeat Retransmits only missing packets, usually most efficient

πŸ“Ά Streaming Modes

Mode Behavior Manual User selects a fixed quality for all segments Auto Client estimates bandwidth and adjusts the next segment quality

πŸ§ͺ Educational Concepts Demonstrated

  • DHCP lease allocation
  • DNS name resolution
  • TCP vs UDP behavior
  • Reliability over UDP
  • Packet loss and retransmissions
  • Window-based transmission
  • Adaptive video streaming
  • Client-server architecture
  • Logging and runtime analysis

πŸ“ Usage Flow

  • The client requests an IP address from the DHCP server.
  • The client queries the DNS server for a domain name.
  • If the domain points to the video application server, the client continues.
  • The client downloads the video manifest.

The user selects:

  1. video
  2. transport protocol
  3. an RUDP mode (if needed)
  4. manual or adaptive quality mode
  5. The client downloads all video segments.
  6. The output is saved locally and reconstructed into an MP4 file.

πŸ“Š Expected Behavior

  • TCP usually provides very fast and stable transfer on localhost.
  • RUDP makes packet loss, acknowledgments, and retransmissions more visible.
  • Under packet loss:
  • Go-Back-N may reduce effective throughput more aggressively
  • Selective Repeat usually performs better than Go-Back-N
  • In Auto mode, lower measured bandwidth may cause the next segment quality to drop to mid or low

Developed by

Amitai Buzaglo Β· Ofri Ben Shabo Β· Daniel Kfir

Department: Computer Science
Institution: Ariel University
Academic Level: Second-year undergraduate students


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages