{"id":23074758,"url":"https://github.com/bursasha/py-multithread-tcp-robot-server","last_synced_at":"2025-04-03T11:44:14.464Z","repository":{"id":246268506,"uuid":"820552008","full_name":"bursasha/py-multithread-tcp-robot-server","owner":"bursasha","description":"A multithreaded TCP server in Python for client-robot authentication, navigation, and message retrieval 🤖","archived":false,"fork":false,"pushed_at":"2024-06-26T19:34:25.000Z","size":78,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T01:17:27.609Z","etag":null,"topics":["computer-networks","custom-protocol","multithreaded-server","network-programming","python-server","python3","socket-programming","tcp-client-server"],"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/bursasha.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}},"created_at":"2024-06-26T17:42:18.000Z","updated_at":"2024-06-26T19:39:55.000Z","dependencies_parsed_at":"2024-06-27T00:02:55.781Z","dependency_job_id":"bb46994a-363a-4b12-ab4c-7515946c1967","html_url":"https://github.com/bursasha/py-multithread-tcp-robot-server","commit_stats":null,"previous_names":["bursasha/py-multithread-tcp-robot-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bursasha%2Fpy-multithread-tcp-robot-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bursasha%2Fpy-multithread-tcp-robot-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bursasha%2Fpy-multithread-tcp-robot-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bursasha%2Fpy-multithread-tcp-robot-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bursasha","download_url":"https://codeload.github.com/bursasha/py-multithread-tcp-robot-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246998137,"owners_count":20866690,"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":["computer-networks","custom-protocol","multithreaded-server","network-programming","python-server","python3","socket-programming","tcp-client-server"],"created_at":"2024-12-16T08:29:28.630Z","updated_at":"2025-04-03T11:44:14.439Z","avatar_url":"https://github.com/bursasha.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Multithreaded Python TCP Robot Server** 🤖\n\n## **Repository Overview** 📄\nThis repository contains a _multithreaded_ **TCP** server implementation designed to control remote robots, \nallowing them to authenticate, navigate to a target coordinate, and retrieve a secret message. \nThe project is implemented in **Python** and adheres to the specifications provided by the university **Computer Networks** course.\n\n## **Repository Structure** 📂\n- **`main.py`**: The main server program implementing the multithreaded TCP server.\n- **`README.md`**: This README file providing an overview and usage instructions.\n- **`tester-arm`**: The tester executable for ARM architecture to validate the server implementation against predefined tests.\n\n## **Course Description and Task Overview** 📚\nThe **Computer Networks** course includes practical and theoretical tasks focusing on network communication protocols. \nThe specific task is to create a _multithreaded_ server for **TCP/IP** communication that can handle multiple clients (robots) simultaneously. \nEach robot starts at a random coordinate and must navigate to the origin **[0,0]** to pick up a secret message.\n\n### **Detailed Specification** 🔍\n\n#### **Communication Protocol** 🔐\nCommunication between the server and robots is conducted via a pure textual protocol with commands ending in a special sequence **`\"\\a\\b\"`**.\n\n#### **Server Messages** 📩\n- `SERVER_MOVE`: Command to move one position forward.\n- `SERVER_TURN_LEFT`: Command to turn left.\n- `SERVER_TURN_RIGHT`: Command to turn right.\n- `SERVER_PICK_UP`: Command to pick up the message.\n- `SERVER_LOGOUT`: Command to terminate the connection after a successful message discovery.\n- `SERVER_KEY_REQUEST`: Command to request Key ID for authentication.\n- `SERVER_OK`: Positive acknowledgment.\n- `SERVER_LOGIN_FAILED`: Authentication failed.\n- `SERVER_SYNTAX_ERROR`: Incorrect message syntax.\n- `SERVER_LOGIC_ERROR`: Message sent in an incorrect situation.\n- `SERVER_KEY_OUT_OF_RANGE_ERROR`: Key ID out of the expected range.\n\n#### **Client Messages** 📨\n- `CLIENT_USERNAME`: Message with the username.\n- `CLIENT_KEY_ID`: Message with the Key ID.\n- `CLIENT_CONFIRMATION`: Message with the confirmation code.\n- `CLIENT_OK`: Confirmation of performed movement, including robot coordinates.\n- `CLIENT_RECHARGING`: Robot starts recharging.\n- `CLIENT_FULL_POWER`: Robot has recharged and resumes operations.\n- `CLIENT_MESSAGE`: Text of the discovered secret message.\n\n#### **Authentication Process** 🔒\n1. **Client sends username.**\n2. **Server requests Key ID.**\n3. **Client sends Key ID.**\n4. **Server sends a confirmation code calculated using the username and server key.**\n5. **Client sends its confirmation code.**\n6. **Server verifies the confirmation code and responds with `SERVER_OK` or `SERVER_LOGIN_FAILED`.**\n\n#### **Robot Navigation** 📡\nThe server guides the robot to the origin **[0,0]** using a series of `SERVER_MOVE`, `SERVER_TURN_LEFT`, and `SERVER_TURN_RIGHT` commands. \nThe robot responds with its current coordinates after each move.\n\n#### **Secret Message Discovery** 🎁\nOnce at **[0,0]**, the server sends `SERVER_PICK_UP` to retrieve the secret message from the robot. \nThe server then sends `SERVER_LOGOUT` to terminate the connection.\n\n#### **Recharging Process** 🔋\nRobots notify the server when they start recharging (`CLIENT_RECHARGING`) and resume operations with `CLIENT_FULL_POWER`.\n\n### **Special Situations and Error Handling** ⛔️\n- **Timeouts**: Connections are terminated if messages are not received within specified intervals.\n- **Syntax Errors**: The server responds with `SERVER_SYNTAX_ERROR` for incorrect message formats.\n- **Logic Errors**: Errors during the recharging process result in `SERVER_LOGIC_ERROR`.\n\n## **Technologies and Concepts Used** 🛠️\n- **Python**:\n    - _Multithreading_ with the `Thread` class from the `threading` module.\n    - _Socket programming_ using the `socket` module.\n    - Exception handling for robust error detection and response.\n- **TCP/IP Communication**:\n    - Implementing a _custom communication protocol_ over TCP.\n    - Managing _concurrent client connections_ using threads.\n\n## **Launching the Server and Client** 🚀\n\n### **Running the Server**\n1. **Ensure Python is installed on your system.**\n2. **Navigate to the project directory.**\n3. **Run the server using the following command:**\n```sh\npython3 main.py\n```\n\n### **Running the Tester**\n1. **Ensure the tester executable is available in the project directory.**\n2. **Launch the tester in a compatible environment (e.g., VirtualBox with Tiny Core Linux).**\n3. **Run the tester with the appropriate parameters:**\n   ```sh\n   tester \u003cport number\u003e \u003cserver address\u003e [test number(s)]\n   ```\n    - Example:\n      ```sh\n      tester 4321 127.0.0.1 2 3 8 | less\n      ```\n\n## **Conclusion** 📝\nThis repository provides a comprehensive implementation of a _multithreaded_ **TCP** server for robot control, following the detailed specifications provided by the **Computer Networks** course. \nThe project demonstrates practical applications of network programming, multithreading, and custom protocol implementation in Python.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbursasha%2Fpy-multithread-tcp-robot-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbursasha%2Fpy-multithread-tcp-robot-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbursasha%2Fpy-multithread-tcp-robot-server/lists"}