Skip to content

File transfer over TCP/UDP sockets with network programming on mininet and various models

Notifications You must be signed in to change notification settings

adityatripathiiit/Socket-Programming-Variants

Repository files navigation

Socket-Programming-Variants ⭐

File transfer over TCP/UDP sockets with network programming on mininet and various models. Contains client and server programs that enable to download multiple files on a same/single TCP/UDP connection. Also a Mininet network, where you instantiate different desired (parameterized) topologies, where one of the host node acts as server and subset of the remaining nodes act as a clients.

Codebase Directory Architecture: πŸ“

Socket-Programming-Variants
β”œβ”€ custom_network_topology
β”‚  β”œβ”€ mininet_variants
β”‚  β”‚  β”œβ”€ Tree_custom_Link_Bandwidth.py
β”‚  β”‚  β”œβ”€ Tree_custom_Link_Loop.py
β”‚  β”‚  └─ Tree_custom_Link_Scaling_Load.py
β”‚  β”œβ”€ novels
β”‚  β”‚  β”œβ”€ Heartsease.txt
β”‚  β”‚  β”œβ”€ Roget’s Thesaurus.txt
β”‚  β”‚  β”œβ”€ The 1991 CIA World Factbook.txt
β”‚  β”‚  β”œβ”€ The Conquest Of Peru.txt
β”‚  β”‚  └─ War and Peace.txt
β”‚  β”œβ”€ README.txt
β”‚  β”œβ”€ received_files
β”‚  β”‚  └─ tcp
β”‚  β”‚     └─ Heartsease_TCP_268651.txt
β”‚  β”œβ”€ tcp_fork
β”‚  β”‚  β”œβ”€ tcp_client_non_persistent.py
β”‚  β”‚  β”œβ”€ tcp_client_persistent.py
β”‚  β”‚  └─ tcp_server.py
β”‚  └─ tcp_thread
β”‚     β”œβ”€ tcp_client_non_persistent.py
β”‚     β”œβ”€ tcp_client_persistent.py
β”‚     └─ tcp_server.py
β”œβ”€ fork_thread_server
β”‚  β”œβ”€ novels
β”‚  β”‚  β”œβ”€ Heartsease.txt
β”‚  β”‚  β”œβ”€ Roget’s Thesaurus.txt
β”‚  β”‚  β”œβ”€ The 1991 CIA World Factbook.txt
β”‚  β”‚  β”œβ”€ The Conquest Of Peru.txt
β”‚  β”‚  └─ War and Peace.txt
β”‚  β”œβ”€ README.txt
β”‚  β”œβ”€ received_files
β”‚  β”‚  └─ tcp
β”‚  β”‚     └─ Heartsease_TCP_268651.txt
β”‚  β”œβ”€ tcp_fork
β”‚  β”‚  β”œβ”€ client_run.sh
β”‚  β”‚  β”œβ”€ tcp_client_non_persistent.py
β”‚  β”‚  β”œβ”€ tcp_client_persistent.py
β”‚  β”‚  └─ tcp_server.py
β”‚  └─ tcp_thread
β”‚     β”œβ”€ client_run.sh
β”‚     β”œβ”€ tcp_client_non_persistent.py
β”‚     β”œβ”€ tcp_client_persistent.py
β”‚     └─ tcp_server.py
β”œβ”€ mininet_migration
β”‚  β”œβ”€ mininet_variants
β”‚  β”‚  β”œβ”€ linear_switch_bandwidth.py
β”‚  β”‚  β”œβ”€ linear_switch_delay.py
β”‚  β”‚  β”œβ”€ linear_switch_hops.py
β”‚  β”‚  β”œβ”€ linear_switch_loss.py
β”‚  β”‚  β”œβ”€ single_switch_diff_file.py
β”‚  β”‚  └─ single_switch_same_file.py
β”‚  β”œβ”€ novels
β”‚  β”‚  β”œβ”€ Heartsease.txt
β”‚  β”‚  β”œβ”€ Roget’s Thesaurus.txt
β”‚  β”‚  β”œβ”€ The 1991 CIA World Factbook.txt
β”‚  β”‚  β”œβ”€ The Conquest Of Peru.txt
β”‚  β”‚  └─ War and Peace.txt
β”‚  β”œβ”€ README.txt
β”‚  β”œβ”€ received_files
β”‚  β”‚  └─ tcp
β”‚  β”‚     └─ Heartsease_TCP_268651.txt
β”‚  β”œβ”€ tcp_fork
β”‚  β”‚  β”œβ”€ tcp_client_non_persistent.py
β”‚  β”‚  β”œβ”€ tcp_client_persistent.py
β”‚  β”‚  └─ tcp_server.py
β”‚  └─ tcp_thread
β”‚     β”œβ”€ tcp_client_non_persistent.py
β”‚     β”œβ”€ tcp_client_persistent.py
β”‚     └─ tcp_server.py
β”œβ”€ persistent_connection
β”‚  β”œβ”€ novels
β”‚  β”‚  β”œβ”€ Heartsease.txt
β”‚  β”‚  β”œβ”€ Roget’s Thesaurus.txt
β”‚  β”‚  β”œβ”€ The 1991 CIA World Factbook.txt
β”‚  β”‚  β”œβ”€ The Conquest Of Peru.txt
β”‚  β”‚  └─ War and Peace.txt
β”‚  β”œβ”€ README.txt
β”‚  β”œβ”€ received_files
β”‚  β”‚  β”œβ”€ tcp
β”‚  β”‚  β”‚  └─ Heartsease_TCP_268651.txt
β”‚  β”‚  └─ udp
β”‚  β”‚     └─ Heartsease_UDP_268651.txt
β”‚  β”œβ”€ tcp
β”‚  β”‚  β”œβ”€ tcp_client.py
β”‚  β”‚  └─ tcp_server.py
β”‚  └─ udp
β”‚     β”œβ”€ udp_client.py
β”‚     └─ udp_server.py
└─ README.md

Features checklist βœ…

βœ… Client-Server Architecture
βœ… File transfer over TCP socket 
βœ… File transfer over UDP Socket
βœ… Persistent UDP file transfer [TFTP protocol RFC 1350]
βœ… Persistent TCP file transfer
βœ… Multithreaded Server using forking and threading 
βœ… Multirequest client 
βœ… Client and server programs that enable to download multiple files on a same/single TCP/UDP connection
βœ… Mininet migration of various models on custom topologies and prebuilt topologies(linear, tree etc) with custom configured network parameters. 

Instructions to Run πŸƒ

  • There are instructions on how to run the programs inside each subdirectory of this repository. Please refer to those

Changes required to create a persistent connection over πŸš€


  • TCP

    • On the Client-side:
      • ACK is sent and received after send the requested filename
      • ACK is sent after receiving every chunk of file from the server.
      • If the chunk says β€œEOF” in binary, then this means that the server sends the signal that the current file has ended and all the further data will not be a part of this file. This β€œEOF” is sent from the server. This process is repeated for all the files requested.
    • On the Server-side:
      • Apart from all the corresponding acks receiving and sending from the client, the server sent an β€œEOF” signal to mark the end of the sending file

  • UDP

    • UDP is connectionless protocol. Therefore talking about connection does notmake sense in UDP. But for this part, we have considered transferring all the files on a single formed socket.

    • Here we tried to convert UDP to a reliable model using inspiration from TCP and TFTP protocol RFC 1350. We used techniques such as sending ACK’s and resending of the packets, in combination with timeouts to achieve the working of this model.

    • The most important places that we needed to ensure reliability was while sending the name of the file to be fetched and while marking the end of a receiving file.

    • To ensure this, at both the places we kept on sending ACKs from both the server and the client, until and unless, one of them does not get the required information. And the other one is handled with carefully placed timeouts. Here

    • we have placed timeouts in server sockets at both of these places, which ensure the reliability of the system.

    • Apart from the above changes, we have send ACKs after every chunk of file that is transferred. And as explained earlier, we used the same algorithm to mark the end of the file, by combination of specific ACKs, repeated sending and timeouts.

    Please Check the code to get more insight.