If somebody have experience with small devices with on-board ethernet, then this small view can be interesting.
] capture(shell): `tcpdump -w /tmp/dump -e -n -vvv -xx -XX -i eth0`
] reading(shell): `tcpdump -r /tmp/dump -e -n -vvv -xx -XX | pager`
] input(python):
== IP RAW socket under 254 (SOMETHING/IP) PROTO ==
>>> s=socket(AF_INET,SOCK_RAW,254)
>>> s.sendto("OLECOM", ("1.1.1.1",0))
6
>>> s.sendto("OLECOZ", ("1.1.1.1",0))
6
=
TIME, 00:17:31:8e:4f:3a > 00:01:30:fb:4e:30, ethertype IPv4 (0x0800),
length 40: (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: unknown (254),
length: 26) 158.194.64.22 > 1.1.1.1: ip-proto-254 6
0x0000: 0001 30fb 4e30 0017 318e 4f3a 0800 4500 ..0.N0..1.O:..E.
0x0010: 001a 0000 4000 40fe 590c 9ec2 4016 0101 ....@.@.Y...@...
0x0020: 0101 4f4c 4543 4f4d ..OLECOM
TIME, 00:17:31:8e:4f:3a > 00:01:30:fb:4e:30, ethertype IPv4 (0x0800),
length 40: (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: unknown (254),
length: 26) 158.194.64.22 > 1.1.1.1: ip-proto-254 6
0x0000: 0001 30fb 4e30 0017 318e 4f3a 0800 4500 ..0.N0..1.O:..E.
0x0010: 001a 0000 4000 40fe 590c 9ec2 4016 0101 ....@.@.Y...@...
0x0020: 0101 4f4c 4543 4f5a ..OLECOZ
____
== IP RAW socket under 1 (ICMP/IP) PROTO ==
>>> s=socket(AF_INET,SOCK_RAW,1)
>>> s.sendto("OLECOM-ICM", ("1.1.1.1",0))
10
>>> s.sendto("OLECOM-ICMP", ("1.1.1.1",0))
11
=
TIME, 00:17:31:8e:4f:3a > 00:01:30:fb:4e:30, ethertype IPv4 (0x0800),
length 44: (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: ICMP (1),
length: 30) 158.194.64.22 > 1.1.1.1: ICMP type-#79,
length 10 (wrong icmp cksum 4543 (->f0cf)!)
[|ip]
0x0000: 0001 30fb 4e30 0017 318e 4f3a 0800 4500 ..0.N0..1.O:..E.
0x0010: 001e 0000 4000 4001 5a05 9ec2 4016 0101 ....@.@.Z...@...
0x0020: 0101 4f4c 4543 4f4d 2d49 434d ..OLECOM-ICM
TIME, 00:17:31:8e:4f:3a > 00:01:30:fb:4e:30, ethertype IPv4 (0x0800),
length 45: (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: ICMP (1),
length: 31) 158.194.64.22 > 1.1.1.1: ICMP type-#79,
length 11 (wrong icmp cksum 4543 (->a0cf)!)
[|ip]
0x0000: 0001 30fb 4e30 0017 318e 4f3a 0800 4500 ..0.N0..1.O:..E.
0x0010: 001f 0000 4000 4001 5a04 9ec2 4016 0101 ....@.@.Z...@...
0x0020: 0101 4f4c 4543 4f4d 2d49 434d 50 ..OLECOM-ICMP
____
== IP RAW socket under 255 (RAW/IP) PROTO ==
>>> s=socket(AF_INET,SOCK_RAW,255)
>>> s.sendto("OLECOM-255", ("1.1.1.1",0))
10
>>> s.sendto("", ("1.1.1.1",0))
0
=
TIME, 00:17:31:8e:4f:3a > 00:01:30:fb:4e:30, ethertype IPv4 (0x0800),
length 24: [|ip]
0x0000: 0001 30fb 4e30 0017 318e 4f3a 0800 4f4c ..0.N0..1.O:..OL
0x0010: 4543 4f4d 2d32 3535 ECOM-255
TIME, 00:17:31:8e:4f:3a > 00:01:30:fb:4e:30, ethertype IPv4 (0x0800),
length 14: [|ip]
0x0000: 0001 30fb 4e30 0017 318e 4f3a 0800 ..0.N0..1.O:..
____
== ETHERNET RAW socket (under in fact NOTHING) ==
>>> sr=socket(AF_PACKET,SOCK_RAW,0)
>>> sr.sendto("123456789000zzolecom", ("eth0",0))
20
=
TIME, 37:38:39:30:30:30 > 31:32:33:34:35:36, ethertype Unknown (0x7a7a),
length 20:
0x0000: 3132 3334 3536 3738 3930 3030 7a7a 6f6c 123456789000zzol
0x0010: 6563 6f6d ecom
____
>>> sr.sendto("", ("eth0",0))
0
>>> sr.sendto("", ("eth0",0))
0
=
TIME, [|ether]
TIME, [|ether]
____
Capability of raw access to protocols on different levels can be very
handy simple way of fast communication, no TCP/IP, no UDP/IP, just data.
IP broadcast (255.255.255.255) plus ethernet capture (also winpcap)
create a duplex without any problems.
____
sed 'sed && sh + olecom = love' << ''
-o--=O`C
#oo'L O
<___=E M
light Ethernet hardware interfaces
Hardware guys vs software
A creative example of the value of free drivers
http://lwn.net/Articles/275638/
Yea, while programming is more complicated than designing digital hardware[*], handcrafting make it even harder. Some programmers do craft better some don't.
[*] Analog hardware, while being more limited on materials (quality passive elements, op-amps, adc, dac) faces same thing on designing products (PCB, noise, modelling): tools and skills:
http://kerneltrap.org/node/15894#comment-295068
_____