Skip to content

kdpkst/file-transfer-and-network-traffic-control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Computer Networking Projects

  1. Introduction
  2. File Transfer Application
  3. SDN-based Network Traffic Control
  4. Contributors

Introduction

The repository consists of two different projects: File Transfer Application and SDN-based Network Traffic Control. The repo houses the codes for both projects, each residing in its respective folder named file_transfer and network_traffic_control.

File Transfer Application

The project aims to utilize Python socket programming to implement a client-side application for file uploading, adhering to a custom application-layer protocol.

Note: The protocol and the server-side application was defined and implemented by XJTLU Dr. Fei Cheng.

Protocol Specification

STEP (Simple Transfer and Exchange Protocol) is a stateless, client-server, TCP-based protocol for data and file exchange. It uses JSON as the data representation format for simplicity. STEP servers provide services for uploading, storing, downloading, and deleting data and files. Clients need authorization to access and manage both public and private data on the server. By default, the server listens on port 1379. The connection established between the client and server remains active until the client decides to close it. STEP clients initiate connections to send one or more continuous requests, while the STEP server accepts incoming connections and responds with corresponding responses. Both requests and responses in STEP messages share the same format, including fields such as "Operation", "Direction", and other specific fields.

STEP Message Format:
The figure and table below clarify the message format:

STEP Message Format

Part Length (Bytes) Description
Length of JSON Data (Compulsory, Binary, unsigned int) 4 Represent the length of JSON Data (N), allowing for a maximum length of 2^32 bytes
Length of Binary Data (Compulsory, Binary, unsigned int) 4 Represent the length of Binary File Data (M), allowing for a maximum length of 2^32 bytes
JSON Data (Compulsory, Text but encoded to Binary) N JSON data which should be decoded and parsed according to JSON rules
Binary File Data (Optional, Binary) M Binary file data, file or block

Reserved Fields of JSON Data:

Note: The operations related to data (e.g., SAVE, DELETE, and GET for data) are not relevant to this project though it is well-defined in the protocol, as the primary objective is to implement a client-side application for file uploading.

  1. type: Specifies the type of data transfer, which can be AUTH, DATA, FILE.
  2. operation: Defines the operation to be performed, which can be SAVE, DELETE, GET, UPLOAD, DOWNLOAD, BYE, LOGIN.
    • For authorization, operation can be LOGIN.
      • "type" field must be AUTH, and include "username" (your ID as a string) and "password" (MD5 hash of your ID) fields. The response will include a "token."
    • For DATA, operations can be SAVE, DELETE, and GET.
      • SAVE: Save data, with an optional "key" field. The server will reply with the key or generate one if not provided.
      • GET: Retrieve data using a specified key.
      • DELETE: Delete data using a key.
    • For FILE, operations can be SAVE, DELETE, GET, UPLOAD, and DOWNLOAD.
      • SAVE: Start a file storage request with a "key" and "size" of the file. The key can be defined by the client or generated by the server if not provided. The server responds with the file upload plan.
      • DELETE: Delete a file by its key.
      • GET: Initiate a file download request by key, and the server responds with the file download plan.
      • UPLOAD: Upload a file block or the entire file using the "key" and "block_index." The server sends the MD5 checksum when it receives the complete file.
      • DOWNLOAD: Download a file block or the entire file using the "key" and "block_index."
  3. direction: Specifies the direction of communication, which can be REQUEST or RESPONSE.
  4. status: Indicates the status of the request, with values of 200 for success and 400+ for errors.
    • Successful status codes:
      • 200: OK
    • Error status codes:
      • 400: Compulsory field is missing.
      • 401: Password error for login.
      • 402: The key already exists.
      • 403: No token or an incorrect token.
      • 404: Key not found.
      • 405: Block index exceeds the maximum block number.
      • 406: Uploaded size doesn't match the required block size.
      • 407: Incorrect direction.
      • 408: Incorrect operation.
      • 409: Type is not allowed.
      • 410: Field is missing.
  5. md5: MD5 hash value of the file.
  6. size: file size, ranging from 1 to 4,294,967,296.
  7. block_index: block index (0 to N-1, where N is the total block number).
  8. block_size: block size, ranging from 1 to 65,536.
  9. total_block: total block number for uploading or downloading.
  10. key: A string field that can be a custom key or generated by the server.
  11. token: A string obtained during the authorization process.

Requirements_file_transfer

  • Python3

Usage_file_transfer

  1. Clone the repository:
git clone https://github.com/kdpkst/file-transfer-and-network-traffic-control.git
  1. Change to the source code directory:
cd file-transfer-and-network-traffic-control/file_transfer/Codes/
  1. Copy server.py to your server. Copy client.py to your device.
  2. On the server side (Server will listen on port 1397 if port is not explicitly specified):
python3 server.py --port port_to_listen_on
  1. On the client side (Default id is 1202437 if it is not explicitly specified):
python3 client.py --server_ip your_server_ip --port server_port --id your_id --f filepath

Document_file_transfer

For more detailed info, please click to read the report for this project.

SDN-based Network Traffic Control

The project utilizes Mininet, a powerful tool for emulating SDN (Software Defined Network), to construct a simple SDN network topology (see the following figure) and simulate traffic control within the Mininet-emulated environment. The primary objective is to develop two different SDN controller applications using Ryu framework to implement traffic forwarding and redirection, respectively. The controller application that implements traffic forwarding directly forwards network traffic from Client to Server 1, while the other one redirects the traffic to Server 2 without the awareness of Client.

SDN topo

Requirements_SDN

  • Linux environment (Ubuntu 20.04)
  • Python2
  • Python3
  • Mininet (2.2.2)
  • Ryu (4.34)
  • XTerm (353)

Usage_SDN

  1. Construct the network topology by running the command in the terminal
 sudo python2 networkTopo.py
  1. Five subterminals appear, then run the controller application in the terminal named Controller
 ryu-manager ryu_forward.py 

or

 ryu-manager ryu_redirect.py 
  1. Run server.py on the Server1 and Server2, then run client.py on Client node.
 python3 server.py
 python3 client.py
  1. Observe subterminals info.

Document_SDN

For more detailed info, please click to read the report for this project.

Contributors

About

File Transfer Application & SDN-based Network Traffic Control

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages