Skip to content

Commit e7112fc

Browse files
committed
Adding fast example
1 parent 87c7b9b commit e7112fc

1 file changed

Lines changed: 38 additions & 8 deletions

File tree

README.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ Raw socket is a layer 2 python library for communication using the MAC addresses
44

55
This 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, ...
66

7+
Python versions tested:
8+
9+
- [x] 2.7.x
10+
- [ ] 3.x
11+
12+
OSes:
13+
14+
- [ ] Linux 14.04
15+
- [x] Linux 16.04
16+
- [ ] Linux 18.04
17+
- [ ] Linux 18.04
18+
- [ ] Windows 10
19+
- [ ] Mac OSX
20+
721
**Pros:**
822

923
- Low level
@@ -33,9 +47,28 @@ cd rawsocket_python
3347
sudo python setup.py install
3448
```
3549

36-
## Usage
50+
## Fast testing
3751

38-
### Sending
52+
On one computer:
53+
54+
```bash
55+
sudo python -c "from rawsocketpy import RawSocket
56+
sock = RawSocket('wlp2s0', 0xEEFA)
57+
print(sock.recv())"
58+
59+
# 12:34:56:78:9A:BC == 0xEEFA => FF:FF:FF:FF:FF:FF - OK:
60+
# Boo
61+
```
62+
63+
On the second computer:
64+
65+
```bash
66+
sudo python -c "from rawsocketpy import RawSocket
67+
sock = RawSocket('wlp2s0', 0xEEFA)
68+
print(sock.send('Boo'))"
69+
```
70+
71+
## In-depth
3972

4073
```python
4174
from rawsocketpy import RawSocket
@@ -49,10 +82,6 @@ sock = RawSocket("wlp2s0", 0xEEFA)
4982
sock.send("some data") # Broadcast "some data" with an ethertype of 0xEEFA
5083
sock.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
5184
sock.send("other data", ethertype="\xEE\xFF") # Broadcast "other data" with an ether type of 0xEEFF
52-
53-
# On capable hardware, you can spoof your MAC address:
54-
sock.mac = "\x12\x13\x14\x15\x16\x17"
55-
sock.send("some data")
5685
```
5786

5887
### Receiving
@@ -64,6 +93,7 @@ from rawsocketpy import RawSocket, u_to_str
6493

6594
sock = RawSocket("wlp2s0", 0xEEFA)
6695
packet = sock.recv()
96+
# The type of packet is RawPacket() which allows pretty printing and unmarshal the raw data.
6797

6898
print(packet) # Pretty print
6999
packet.dest # unicode string "\xFF\xFF\xFF\xFF\xFF\xFF"
@@ -75,15 +105,15 @@ print u_to_str(packet.dest) # Human readable MAC: FF:FF:FF:FF:FF:FF
75105
print u_to_str(packet.type, "") # Human readable type: EEFA
76106
```
77107

78-
79108
## I want to contribue!!
80109

81110
You are free to contribue, the following capabilities are welcome:
82111

83112
- Windows compatibility
84113
- Python 3.x compatibility
85114
- Server implementation (callbacks on new data)
115+
- Readthedocs documentation
86116

87117
## Credits
88118

89-
- Alexis PAQUES - [@AlexisTM](https://github.com/AlexisTM/)
119+
- Alexis PAQUES - [@AlexisTM](https://github.com/AlexisTM/)

0 commit comments

Comments
 (0)