Skip to content

akuldevali/IP_Project_1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Network Protocols Performance Testing Framework

This framework provides tools for testing and comparing the performance of different network protocols: HTTP/1.1, HTTP/2, and BitTorrent. It includes client and server implementations for all three protocols, designed to measure throughput, latency, and protocol overhead across different file sizes.

Table of Contents

  1. Requirements
  2. Installation
  3. Directory Structure
  4. HTTP/1.1 Implementation
  5. HTTP/2 Implementation
  6. BitTorrent Implementation
  7. Running Comprehensive Tests
  8. Understanding Results
  9. Troubleshooting

Requirements

For HTTP/1.1:

  • Python 3.6+
  • Flask (pip install flask)
  • Requests (pip install requests)
  • Werkzeug (pip install werkzeug)
  • Statistics module (part of Python standard library)

For HTTP/2:

  • Python 3.6+
  • h2 (pip install h2)
  • socket (part of Python standard library)
  • Statistics module (part of Python standard library)
  • psutil (pip install psutil)

For BitTorrent:

  • Python 3.6+
  • libtorrent (pip install python-libtorrent or platform-specific installation)
  • Statistics module (part of Python standard library)
  • argparse (part of Python standard library)

Installation

Basic Setup

  1. Clone or download this repository
  2. Install the required dependencies:
# Common requirements
pip install statistics

# For HTTP/1.1 implementation
pip install flask requests werkzeug

# For HTTP/2 implementation
pip install h2 psutil

# For BitTorrent implementation
# Note: libtorrent installation can be platform-specific
# On Ubuntu/Debian:
sudo apt-get install python3-libtorrent

# On macOS (with Homebrew):
brew install libtorrent-rasterbar
pip install python-libtorrent

# On Windows:
# Download appropriate binaries or use Anaconda:
conda install -c conda-forge libtorrent

Directory Structure

Create the following directory structure:

network-testing/
├── http1/
│   ├── http1_server.py
│   ├── http1_client.py
│   ├── Data files/     # Test files for HTTP/1.1
│   └── http1_server.log # Generated when running
├── http2/
│   ├── server.py
│   ├── client.py
│   ├── Data files/     # Test files for HTTP/2
│   └── http2_server.log # Generated when running
├── bitTorrent/
│   ├── seeder.py
│   ├── leecher.py
└── README.md

HTTP/1.1 Implementation

HTTP/1.1 Server Setup

  1. Navigate to the HTTP/1.1 directory:

    cd http1
  2. Start the server:

    python http1_server.py

    The server will:

    • Listen on 0.0.0.0:8080 (all interfaces)
    • Serve files from the "Data files" directory
    • Log activity to http1_server.log

HTTP/1.1 Client Setup

  1. Edit the http1_client.py file to update the server IP address:

    # Define server URLs - update with your actual server IPs
    computer1_url = 'http://YOUR_SERVER_IP:8080'  # Replace with your server's IP
  2. Run the client:

    python http1_client.py

    The client will:

    • Download files of different sizes (10kB, 100kB, 1MB, 10MB)
    • Perform multiple transfer repetitions (1000, 100, 10, 1 respectively)
    • Calculate throughput, latency, and overhead metrics
    • Save results to http1_1_throughput_results.json

HTTP/2 Implementation

HTTP/2 Server Setup

  1. Navigate to the HTTP/2 directory:

    cd http2
  2. Start the server:

    python server.py

    To use specific host/port:

    python server.py --host 192.168.1.100 --port 8443

    The server will:

    • Listen on the specified interface (default: 0.0.0.0:8080)
    • Serve files from the "Data files" directory
    • Log activity to http2_server.log

HTTP/2 Client Setup

  1. Run the client with your server's IP and port:

    python client.py --server YOUR_SERVER_IP --port 8080
  2. For testing a single file:

    python client.py --server YOUR_SERVER_IP --port 8080 --file A_1MB --repeats 5
  3. For testing with two servers:

    python client.py --server SERVER1_IP --port 8080 --server2 SERVER2_IP --port2 8080

BitTorrent Implementation

The BitTorrent implementation requires both a seeder and a leecher component to measure file transfer performance. This implementation uses existing torrent files rather than creating test files from scratch.

Installing libtorrent

Before running the BitTorrent tests, you need to install the libtorrent library:

sudo apt-get install python3-libtorrent

Install a library to create a .torrent file which is shared to all the peers.

pip3 install py3createtorrent

Creating Torrent Files

The sender needs to  creates the .torrent file which will be used to send files to the peers.

- CMD: py3createtorrent -t udp://tracker.opentrackr.org:1337/announce <path-to-file>

Example:
- py3createtorrent -t udp://tracker.opentrackr.org:1337/announce A_1MB

BitTorrent Seeder Setup

python seeder.py --torrent myfile.torrent --dir . --port 7001

Parameters:

  • --torrent: Path to the .torrent file
  • --dir: Directory where the original file is located
  • --port: Base port for BitTorrent communication (default: 7001)

The seeder will:

  • Load the torrent file
  • Start serving the file to peers
  • Continue running until manually terminated (Ctrl+C)

BitTorrent Leecher Setup

  1. Run the leecher with the path to the torrent file and test parameters:

    python leecher.py --torrent myfile.torrent --trials 5 --filesize 1048576

    Before running these that leecher also has the torrent file mentioned in the command if you don't have create torrent file as told from above

    Parameters:

    • --torrent: Path to the .torrent file
    • --trials: Number of download trials to run
    • --filesize: Expected file size in bytes (required for accurate metrics)

    The leecher will:

    • Download the file multiple times (based on trials)
    • Measure download time, throughput, and overhead
    • Save detailed metrics to a timestamped CSV file
    • Generate a summary file with average metrics

Running Comprehensive Tests

For a complete comparison of all three protocols:

  1. Set up test files for all protocols
  2. Run tests for each protocol separately
  3. Compare results across protocols

Example Test Sequence

First, test HTTP/1.1:

cd http1
python http1_server.py  # Run on server machine
python http1_client.py  # Run on client machine

Next, test HTTP/2:

cd http2
python server.py  # Run on server machine
python client.py --server SERVER_IP  # Run on client machine

Finally, test BitTorrent:

py3createtorrent -t udp://tracker.opentrackr.org:1337/announce A_1MB
python seeder.py --torrent A_1MB.torrent --dir test_files  # Run on server machine
python leecher.py --torrent A_1MB.torrent --trials 3 --filesize 1048576  # Run on client machine

Understanding Results

HTTP/1.1 and HTTP/2 Results

Both HTTP implementations generate JSON result files that include:

  • Average Throughput: Data transfer rate in kilobits per second (kbps)
  • Standard Deviation: Variation in throughput across multiple transfers
  • Overhead Ratio: The ratio of total transferred data to file size (headers and protocol overhead)
  • Transfer Count: Number of transfers performed

BitTorrent Results

BitTorrent generates two files per test:

  • Detailed CSV file: Contains metrics for each trial
  • Summary file: Contains average metrics across all trials

Metrics include:

  • Round-Trip Time (RTT): Total download time
  • Throughput: Data transfer rate in kilobits per second
  • Total Data Transferred: Ratio of total data to file size
  • Total Payload Transferred: Actual file data received

Protocol Comparison

When comparing protocols, look for:

  1. Throughput differences across file sizes
  2. Overhead ratios - typically BitTorrent has higher overhead for small files
  3. Consistency (standard deviation) - lower variation means more predictable performance
  4. Scaling efficiency - how performance changes as file size increases

Troubleshooting

Common Issues for All Protocols

  1. Connection Refused:

    • Ensure the server/seeder is running
    • Check if the IP address and port are correctly configured
    • Verify firewall settings allow traffic on the specified port
  2. Slow Performance:

    • Check network conditions
    • Verify no other bandwidth-intensive applications are running
    • Try running tests during periods of low network usage

HTTP-Specific Issues

  1. File Not Found Errors:
    • Ensure test files are created in the correct directories
    • Check file permissions
    • Verify filenames match exactly what the client is requesting

BitTorrent-Specific Issues

  1. Tracker Connection Issues:

    • If using an external tracker, ensure it's accessible
    • Consider using DHT or local trackers for testing
  2. Seeding Issues:

    • Ensure the seeder has the complete file
    • Verify the seeder is properly configured for incoming connections
    • Check that both seeder and leecher are using the same .torrent file
  3. libtorrent Installation Problems:

    • libtorrent can be difficult to install on some platforms
    • Consider using Docker for a consistent environment
    • For Windows, the Anaconda distribution often simplifies installation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages