{"id":30180398,"url":"https://github.com/seyed0123/udp_transfer","last_synced_at":"2025-08-12T07:38:07.950Z","repository":{"id":307231038,"uuid":"1028793743","full_name":"seyed0123/UDP_transfer","owner":"seyed0123","description":"A application for transferring files using UDP protocol","archived":false,"fork":false,"pushed_at":"2025-07-30T04:39:49.000Z","size":6318,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-30T06:35:48.222Z","etag":null,"topics":["filetransfer-udp","network","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seyed0123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-07-30T04:37:25.000Z","updated_at":"2025-07-30T04:42:29.000Z","dependencies_parsed_at":"2025-07-30T06:50:02.411Z","dependency_job_id":null,"html_url":"https://github.com/seyed0123/UDP_transfer","commit_stats":null,"previous_names":["seyed0123/udp_transfer"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/seyed0123/UDP_transfer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seyed0123%2FUDP_transfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seyed0123%2FUDP_transfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seyed0123%2FUDP_transfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seyed0123%2FUDP_transfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seyed0123","download_url":"https://codeload.github.com/seyed0123/UDP_transfer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seyed0123%2FUDP_transfer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270024475,"owners_count":24514028,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["filetransfer-udp","network","python"],"created_at":"2025-08-12T07:38:05.524Z","updated_at":"2025-08-12T07:38:07.931Z","avatar_url":"https://github.com/seyed0123.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# File Transfer System over UDP Protocol\n\nThis project implements a reliable file transfer system using the UDP protocol, designed to ensure accurate and efficient data transmission even in environments prone to packet loss or errors. The system supports parallel server connections for redundancy and faster transfers, while incorporating error checking with SHA-256 checksums to guarantee data integrity. Communication occurs over port 10526, with clients broadcasting requests and servers responding if they host the requested file.\n\nThe transfer process begins when a client broadcasts a request across the network. Servers listening on the designated port check if they have the requested file and respond with metadata including the number of chunks and a hash of the original file. Each file is divided into 1KB chunks, which are sent in random order to avoid congestion and improve efficiency. As the client receives these chunks, it verifies each one using its checksum, tracks missing pieces, and requests retransmission as needed. Once all chunks are received and validated, the client reconstructs the file and performs a final hash comparison to ensure complete accuracy.\n\nTo use the system, run the server module to make files available for transfer and the client module to request specific files from the network. Multiple servers can serve the same file simultaneously, increasing reliability and speed by allowing the client to receive different chunks from different sources. While best suited for local networks due to UDP broadcast constraints, this implementation demonstrates how reliability and efficiency can be achieved over an inherently unreliable transport protocol through thoughtful design and error-handling strategies.\n\n## Project Structure\n\n```\nproject/\n├── client/              # Client implementation\n│   └── data/            # Directory for downloaded files\n└── server/              # Server implementation\n    └── data/            # Directory for served files\n```\n\n## How It Works\n\n### Communication Flow\n\n1. **Initial Request Phase**\n   - Client broadcasts `get \u003cfilename\u003e` request\n   - Waits 10 seconds for responses (retries up to 10 times)\n\n2. **Server Response**\n   - Server checks for requested file\n   - If available, responds with:\n     ```\n     except \u003cchunk_count\u003e chunks \u003cfile_hash\u003e\n     ```\n   - Prepares shuffled chunks of file data (1KB each)\n\n3. **Data Transfer Phase**\n   - Server sends chunks in random order with format:\n     ```\n     struct.pack(f'!II{chunk_size}s32s', chunk_number, chunk_size, chunk_data, checksum)\n     ```\n   - Client:\n     - Maintains list of received chunks\n     - Verifies each chunk's checksum\n     - Tracks missing chunks\n     - Requests retransmission if needed\n\n4. **Completion Phase**\n   - Client assembles file when all chunks received\n   - Verifies final file hash matches server's original hash\n\n## Example Usage\n\n**Server Output:**\n```txt\nWaiting for client to request\nReceived request for file: example.txt\nSending example.txt to ('192.168.161.26', 52072)\nSent chunk 1\nSent chunk 2\nSent chunk 0\n```\n\n**Client Output:**\n```txt\nBroadcasting request for file\nServer found: ('192.168.161.26', 10526) the data is ['except', '3', 'chunks', '29265671788ccd39a7cb18aa66ed535a4896a781269880aad609b93bfc2588f3']\nFile /home/seyed/code/python/network/client/data/example.txt received successfully.\n```\n\n## Command Line Usage\n\n### Basic Commands\n\n**Start server:**\n```bash\npython main.py server [--port 10526]\n```\n\n**Request file:**\n```bash\npython main.py get filename [--port 10526]\n```\n\n### Help Options\n\nView server options:\n```bash\npython main.py server --help\n```\n\nView client options:\n```bash\npython main.py get --help\n```\n\n## Key Features\n\n- **Parallel Server Support**: Multiple servers can respond simultaneously\n- **Error Resilience**:\n  - Checksum verification for each chunk\n  - Automatic retransmission of missing chunks\n  - Final file hash verification\n- **Efficient Transfer**:\n  - Shuffled chunk order prevents network congestion\n  - Duplicate chunk detection\n\n## Notes\n\n- The system works best in local networks due to UDP broadcast limitations\n- File chunks are 1KB by default (adjustable via `CHUNK_SIZE`)\n- Multiple servers serving the same file will automatically provide redundancy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseyed0123%2Fudp_transfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseyed0123%2Fudp_transfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseyed0123%2Fudp_transfer/lists"}