{"id":22763159,"url":"https://github.com/rachhshruti/reliable-file-transfer-udp","last_synced_at":"2025-04-14T21:52:10.984Z","repository":{"id":83958550,"uuid":"114144150","full_name":"rachhshruti/reliable-file-transfer-udp","owner":"rachhshruti","description":"Reliable file transfer using unreliable User Datagram protocol","archived":false,"fork":false,"pushed_at":"2024-07-20T18:49:59.000Z","size":1694,"stargazers_count":10,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T10:01:36.190Z","etag":null,"topics":["client-server","congestion-control","cpp","flow-control","networking","sliding-window-protocol","udp"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rachhshruti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-13T16:32:09.000Z","updated_at":"2024-09-05T00:54:46.000Z","dependencies_parsed_at":"2023-03-12T20:10:26.176Z","dependency_job_id":null,"html_url":"https://github.com/rachhshruti/reliable-file-transfer-udp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rachhshruti%2Freliable-file-transfer-udp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rachhshruti%2Freliable-file-transfer-udp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rachhshruti%2Freliable-file-transfer-udp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rachhshruti%2Freliable-file-transfer-udp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rachhshruti","download_url":"https://codeload.github.com/rachhshruti/reliable-file-transfer-udp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968741,"owners_count":21191158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client-server","congestion-control","cpp","flow-control","networking","sliding-window-protocol","udp"],"created_at":"2024-12-11T11:07:21.431Z","updated_at":"2025-04-14T21:52:10.959Z","avatar_url":"https://github.com/rachhshruti.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Reliable UDP\n\nTwo transport protocols used to transfer files include: TCP and UDP. UDP is an unreliable protocol whereas TCP provides reliability, flow control, and congestion control, but it has an explicit connection establishment phase, which some application may not find desirable. The goal of this project is to design and implement a file transfer application which has all the good features of TCP without the connection establishment phase.\n\n# Features\n\n## Header Format design\n\nThe UDP Server and Client uses the following header format:\n\n\u003cimg src=\"https://github.com/rachhshruti/reliable-file-transfer-udp/blob/master/images/header.png\" width=\"700\" height=\"200\" align=\"center\"/\u003e\n\n* Sequence Number: This is the 32-bit sequence number of the segment that is to be sent.\n* Acknowledgement Number: This is the 32-bit acknowledgement number for the correctly received segment.\n* Ack Flag: This is the 8-bit Ack flag which is set to 1 when an acknowledgement is sent and set to 0 when data is sent.\n* Data: This is 1450 byte data field which is used to store the file data. This field is not used in case an acknowledgement is being sent.\n\n## Sliding window algorithm\n\nThe server receives file request from the client. It extracts the file name from the request and gets the content of the file in a buffer. It then segments the file into chunks of size 1450 bytes as supported by the header.\n\nThere are two window sizes to be considered:\n1. Congestion window: The number of bytes the server can send without congesting the routers in the middle of network path.\n2. Advertised window: The number of bytes the client can receive without requiring to send an acknowledgement. It is decided offline between server and client and accepted as the command-line argument in this project.\n\nThe server starts sending file segments till the minimum of the congestion window size and advertised window size. After sending all the segments in a window, it waits to receive an acknowledgement. When an acknowledgement is received for a sequence number that is less than the next sequence number that is to be sent, then it means some previous segment was not correctly received and the server accepts the 3 duplicate acknowledgements from the client. It then sets the next sequence number based on the acknowledgement received. After receiving the cumulative acknowledgement, it continues sending the segments in the next window. When duplicate acknowledgements are received, the server will start sending segments from the packet that was not correctly received.\n\n## Adaptive Retransmission\n\nImplemented Jacobson/Karel's algorithm for estimating the round trip time (RTT) for the packets to be recieved by the client and acknowledgment received by the server. If the server does not get acknowledgement within RTT, it will retransmit those packets again.\n\nPseudo code:\n~~~~\nEstimated_RTT = (1-α) Estimated RTT + (α) Sample_RTT\nIn the original TCP Specification, α=.0125\n\nJacobson/Karels included a variation component to the calculation for the Estimated_RTT\nEstimated_RTT = Estimated_RTT + δ (Sample_RTT-Estimated_RTT) \nDeviation = Deviation + δ (|Sample_RTT- Estimated_RTT|- Deviation) \nTimeout = μ * Estimated_RTT + φ * Deviation\nTypically φ=4, μ = 1, δ is between 0 and 1\n~~~~\n\n## Congestion control\nServer starts by sending 1 segment. Then, follows 2 phases of congestion control:\n\n1. __Slow Start:__ Segment size is increased exponentially until it is correctly acknowledged by the receiver within the timeout and the congestion window size is less than the ssthresh which is set to 64000 bytes.\n\n2. __Congestion Avoidance:__ When the congestion window size becomes greater than or equal to ssthresh, the congestion\nwindow size is increased linearly by 1 segment size.\n\n__Timeout:__ It is calculated using the Jacobson/Karel's algorithm given above. When a timeout occurs, the ssthresh is set to half the value of the congestion window and the congestion window is reset to 1 segment size.\n\n# Running the code\n\n## Creating and configuring virtual machines\n\t\n\tvagrant up\n   \n   This will boot both the server and client machines\n\n## SSH into virtual machines\n\t\n\tvagrant ssh reliableUDPServer\n\tvagrant ssh reliableUDPClient\n   \n## Compile the code\n\t\n\tmake\n\n## To run reliable UDP server:\n\n  `./Server port advertised_window`\n\nThe server accepts the following command-line arguments:\n\nport: port number to be used for communication\n\nadvertised_window: the number of bytes server is allowed to send before waiting for an acknowldgement\n\n## To run reliable UDP client:\n\n  `./Client server_host_name port file_name advertised_window`\n\nThe client accepts the following command-line arguments:\n\nport and advertised_window: same as that of the server\n\nserver_host_name: host name of the server\n\nfile_name: the name of the file requested by the client\n\nOnce the code is run successfully, you will find the file that the client requested for in the ReliableUDPClient folder.\n\n# Screenshots\n\n\u003cimg src=\"https://github.com/rachhshruti/reliable-file-transfer-udp/blob/master/images/reliable-file-transfer-udp-output.png\" width=\"1000\" height=\"600\" align=\"center\"/\u003e\n\n# References\n\n[Computer Networking-Top-Down-Approach](https://www.amazon.com/Computer-Networking-Top-Down-Approach-6th/dp/0132856204)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frachhshruti%2Freliable-file-transfer-udp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frachhshruti%2Freliable-file-transfer-udp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frachhshruti%2Freliable-file-transfer-udp/lists"}