{ "info": { "author": "AlexisTM", "author_email": "alexis.paques@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2", "Topic :: Internet", "Topic :: System :: Networking", "Topic :: System :: Networking :: Monitoring" ], "description": "# RawSocketPy\n\n[API Documentation](https://rawsocket-python.readthedocs.io/en/latest/api.html)\n\nRaw socket is a layer 2 python library for communication using the MAC addresses only. \n\nThis allows you to create a custom made Ethernet/WiFi communication system which is **not** using IP nor TCP/UDP or to debug custom frames such as SERCOS III, Profibus, ARP, PTP, ...\n\nPython versions tested:\n\n- [x] 2.7.x\n- [x] 3.5.x\n\nOSes:\n\n- [ ] Linux 14.04\n- [x] Linux 16.04\n- [ ] Linux 18.04\n- [ ] Windows 10\n- [ ] Mac OSX\n\n**Pros:**\n\n- Low level\n- Not using TCP-UDP/IP\n- Dead simple\n- Can broadcast\n- MTU of 1500\n- Asynchronous server\n- Stateful capability\n\n**Cons:**\n\n- Low level\n- Not using TCP-UDP/IP\n- No encryption\n- No fragmentation\n- **Requires root**\n- MTU of 1500\n\n## Installation\n\n```bash\n# Soon\nsudo -H pip install rawsocketpy\n\n# for now:\ngit clone https://github.com/AlexisTM/rawsocket_python\ncd rawsocket_python\nsudo python setup.py install\n```\n\n## Fast testing\n\nOn one computer:\n\n```bash\nsudo python -c \"from rawsocketpy import RawSocket\nsock = RawSocket('wlp2s0', 0xEEFA)\nwhile True: print(sock.recv())\"\n\n# 12:34:56:78:9A:BC == 0xEEFA => FF:FF:FF:FF:FF:FF - OK:\n# Boo\n```\n\nOn the second computer over the same router:\n\n```bash\nsudo python -c \"from rawsocketpy import RawSocket; import time\nsock = RawSocket('wlp2s0', 0xEEFA)\nwhile True:\n sock.send('Boo')\n print('Boo has been sent')\n time.sleep(0.5)\"\n```\n\n## In-depth\n\n```python\nfrom rawsocketpy import RawSocket\n\n# 0xEEFA is the ethertype\n# The most common are available here: https://en.wikipedia.org/wiki/EtherType\n# The full official list is available here: https://regauth.standards.ieee.org/standards-ra-web/pub/view.html#registries \n# Direct link: https://standards.ieee.org/develop/regauth/ethertype/eth.csv\n# You can use whatever you want but using a already use type can have unexpected behaviour.\nsock = RawSocket(\"wlp2s0\", 0xEEFA)\nsock.send(\"some data\") # Broadcast \"some data\" with an ethertype of 0xEEFA\nsock.send(\"personal data\", dest=\"\\xAA\\xBB\\xCC\\xDD\\xEE\\xFF\") # Send \"personal data to \\xAA\\xBB\\xCC\\xDD\\xEE\\xFF with an ether type of 0xEEFA\nsock.send(\"other data\", ethertype=\"\\xEE\\xFF\") # Broadcast \"other data\" with an ether type of 0xEEFF\n```\n\n### Receiving\n\nOn another machine, you can run the following:\n\n```python\nfrom rawsocketpy import RawSocket, to_str\n\nsock = RawSocket(\"wlp2s0\", 0xEEFA)\npacket = sock.recv()\n# The type of packet is RawPacket() which allows pretty printing and unmarshal the raw data.\n\n# If you are using Python2, all data is encoded as unicode strings \"\\x01..\" while Python3 uses bytearray.\n\nprint(packet) # Pretty print\npacket.dest # string \"\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\" or bytearray(b\"\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\")\npacket.src # string \"\\x12\\x12\\x12\\x12\\x12\\x13\" or bytearray(b\"\\x12\\x12\\x12\\x12\\x12\\x13\")\npacket.type # string \"\\xEE\\xFA\" or bytearray([b\"\\xEE\\xFA\"]\npackegt.data # string \"some data\" or bytearray(b\"some data\"]\n\nprint(to_str(packet.dest)) # Human readable MAC: FF:FF:FF:FF:FF:FF\nprint(to_str(packet.type, \"\")) # Human readable type: EEFA\n```\n\n## Stateless blocking Server\n\n```python\nfrom rawsocketpy import RawServer\n\nclass LongTaskTest(RawRequestHandler):\n def handle(self):\n time.sleep(1)\n print(self.packet)\n\n def finish(self):\n print(\"End\")\n\n def setup(self):\n print(\"Begin\") \n\ndef main():\n rs = RawServer(\"wlp2s0\", 0xEEFA, LongTaskTest)\n rs.spin()\n\nif __name__ == '__main__':\n main()\n```\n\n## Stateful Asynchronous server\n\nAvailable **only** if **gevent** is installed.\n\n```python\nfrom rawsocketpy import RawRequestHandler, RawAsyncServerCallback\nimport time\n\ndef callback(handler, server):\n print(\"callback\")\n handler.setup()\n handler.handle()\n handler.finish()\n\n\nclass LongTaskTest(RawRequestHandler):\n def handle(self):\n time.sleep(1)\n print(self.packet)\n\n def finish(self):\n print(\"End\")\n\n def setup(self):\n print(\"Begin\") \n\ndef main():\n rs = RawAsyncServerCallback(\"wlp2s0\", 0xEEFA, LongTaskTest, callback)\n rs.spin()\n\nif __name__ == '__main__':\n main()\n```\n\n## I want to contribue!!\n\nYou are free to contribue, the following capabilities are welcome:\n\n- Windows compatibility\n- More Python versions and OS tests\n\n## Credits\n\n- Alexis PAQUES - [@AlexisTM](https://github.com/AlexisTM/)", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/AlexisTM/rawsocket_python", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "rawsocketpy", "package_url": "https://pypi.org/project/rawsocketpy/", "platform": "", "project_url": "https://pypi.org/project/rawsocketpy/", "project_urls": { "Homepage": "https://github.com/AlexisTM/rawsocket_python" }, "release_url": "https://pypi.org/project/rawsocketpy/0.3.0/", "requires_dist": null, "requires_python": "", "summary": "This library allows you to implement a custom layer 2 communication using raw sockets in Python 2 and Python 3, synchronous and asynchronous, with and without callbacks.", "version": "0.3.0" }, "last_serial": 4152855, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "f79febd83a15310b2a7618c7437b3088", "sha256": "98eb3fb4d6695aa3f28839b5d97b168655d86a672ccef89c4b090dd0bc8afb36" }, "downloads": -1, "filename": "rawsocketpy-0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "f79febd83a15310b2a7618c7437b3088", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 6717, "upload_time": "2018-08-08T10:39:13", "url": "https://files.pythonhosted.org/packages/0b/4f/a059fcbbee103b72d50e52e38acf24db5dc95f789cee8a1eda6ed0aea7fc/rawsocketpy-0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "60f1057ea451691786e5121e740096b4", "sha256": "79b6f2b1879b87f187c296b77b34110fbb830f7bc30d9660b784a7ffdc2c7d04" }, "downloads": -1, "filename": "rawsocketpy-0.1.tar.gz", "has_sig": false, "md5_digest": "60f1057ea451691786e5121e740096b4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4146, "upload_time": "2018-08-08T10:39:15", "url": "https://files.pythonhosted.org/packages/46/ee/348715d8558fb824069e3cc73d09be6da3119399e8c878c82865a7d4b6bc/rawsocketpy-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "1f04dbb85d77c10d27c03dc6aab9a39b", "sha256": "f1f05335a3edde8bf7c9ed254d71c2028ecc5ed6742045db1a7a58b56e656b71" }, "downloads": -1, "filename": "rawsocketpy-0.2-py2-none-any.whl", "has_sig": false, "md5_digest": "1f04dbb85d77c10d27c03dc6aab9a39b", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 7912, "upload_time": "2018-08-08T14:08:07", "url": "https://files.pythonhosted.org/packages/63/19/4581f3c223837e3007817516dca6486f0aee550dc7eb8f2f83eef5bd00b7/rawsocketpy-0.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0f00a1c2dbd33b1da72464225a746dfb", "sha256": "ffd7f9d9964c9885d3cbb774f27a1f4764bfb08a22b00c1cf8b041cfefee1b29" }, "downloads": -1, "filename": "rawsocketpy-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "0f00a1c2dbd33b1da72464225a746dfb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5632, "upload_time": "2018-08-08T14:09:56", "url": "https://files.pythonhosted.org/packages/13/3b/244f69bb1a361c6470c1383f0ed0120d3c72f50b1986089fe838902dcd0b/rawsocketpy-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3ed09c958ea43b5ccd726dd89f774955", "sha256": "07a882b2a5e4ffecc53163ef48e5723ee93b1cd123bd253b3b1c00fc16f60583" }, "downloads": -1, "filename": "rawsocketpy-0.2.tar.gz", "has_sig": false, "md5_digest": "3ed09c958ea43b5ccd726dd89f774955", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4829, "upload_time": "2018-08-08T14:08:45", "url": "https://files.pythonhosted.org/packages/db/1e/6b695ef0c0dc3c26115e4c1ea820636851b83cd1a3f8c63a9272e53d0edb/rawsocketpy-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "397384bc8771325cdf219f7e21ffd1b5", "sha256": "7a0525464aa995a48731a317d5fe55439f79592d39a43349d0136307c0d0b7af" }, "downloads": -1, "filename": "rawsocketpy-0.2.1.tar.gz", "has_sig": false, "md5_digest": "397384bc8771325cdf219f7e21ffd1b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4823, "upload_time": "2018-08-08T14:11:24", "url": "https://files.pythonhosted.org/packages/41/76/082711707d2dd5f33b6ef88609ff4ca87eb03250d105eafce71a7819e701/rawsocketpy-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "dc2ade85af1bf74270f665ddecb93dd9", "sha256": "923ade666e25a9f111cef48735fe999809a5ffd0e9573a43b6645713c4735325" }, "downloads": -1, "filename": "rawsocketpy-0.3.0-py2-none-any.whl", "has_sig": false, "md5_digest": "dc2ade85af1bf74270f665ddecb93dd9", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 12452, "upload_time": "2018-08-09T13:15:49", "url": "https://files.pythonhosted.org/packages/cb/79/df3ec0d0124b6b85f21efb3de07f6820ff13b11d9591cf02d9fb83d69d6f/rawsocketpy-0.3.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fde9d4a8d42efd0c02f73630d526432c", "sha256": "a4908bb8c8ff5f0b777eca8c2ec286bb5723e0046fd6fd283426e3e99ce3de58" }, "downloads": -1, "filename": "rawsocketpy-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fde9d4a8d42efd0c02f73630d526432c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9789, "upload_time": "2018-08-09T13:15:50", "url": "https://files.pythonhosted.org/packages/45/06/e3dc2bd3c0d7ac0edaf4df84c1a4c6f26d0c2edf38e23681df15b765f911/rawsocketpy-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fd22d470f4cd566f3d994e11887f61cf", "sha256": "4de2ebd6768777b1e7edb281cd8864535a41747b29551433e8f7fb6c810f02c8" }, "downloads": -1, "filename": "rawsocketpy-0.3.0.tar.gz", "has_sig": false, "md5_digest": "fd22d470f4cd566f3d994e11887f61cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7228, "upload_time": "2018-08-09T13:13:40", "url": "https://files.pythonhosted.org/packages/5f/61/c9bc1be2c0a44b8d82d17082ee7e02a1e3fa709823af6894e49562f405a3/rawsocketpy-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dc2ade85af1bf74270f665ddecb93dd9", "sha256": "923ade666e25a9f111cef48735fe999809a5ffd0e9573a43b6645713c4735325" }, "downloads": -1, "filename": "rawsocketpy-0.3.0-py2-none-any.whl", "has_sig": false, "md5_digest": "dc2ade85af1bf74270f665ddecb93dd9", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 12452, "upload_time": "2018-08-09T13:15:49", "url": "https://files.pythonhosted.org/packages/cb/79/df3ec0d0124b6b85f21efb3de07f6820ff13b11d9591cf02d9fb83d69d6f/rawsocketpy-0.3.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fde9d4a8d42efd0c02f73630d526432c", "sha256": "a4908bb8c8ff5f0b777eca8c2ec286bb5723e0046fd6fd283426e3e99ce3de58" }, "downloads": -1, "filename": "rawsocketpy-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fde9d4a8d42efd0c02f73630d526432c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9789, "upload_time": "2018-08-09T13:15:50", "url": "https://files.pythonhosted.org/packages/45/06/e3dc2bd3c0d7ac0edaf4df84c1a4c6f26d0c2edf38e23681df15b765f911/rawsocketpy-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fd22d470f4cd566f3d994e11887f61cf", "sha256": "4de2ebd6768777b1e7edb281cd8864535a41747b29551433e8f7fb6c810f02c8" }, "downloads": -1, "filename": "rawsocketpy-0.3.0.tar.gz", "has_sig": false, "md5_digest": "fd22d470f4cd566f3d994e11887f61cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7228, "upload_time": "2018-08-09T13:13:40", "url": "https://files.pythonhosted.org/packages/5f/61/c9bc1be2c0a44b8d82d17082ee7e02a1e3fa709823af6894e49562f405a3/rawsocketpy-0.3.0.tar.gz" } ] }