A lightweight C utility to generate and transmit custom Ethernet (Layer 2) frames directly onto the wire using raw sockets. This tool allows for the specification of custom EtherTypes and payloads, making it ideal for network protocol testing and educational purposes.
- Raw Socket Transmission: Bypasses the standard TCP/IP stack to send frames directly.
- Custom EtherType: Easily define your own protocol identifiers.
- Hardware Address Retrieval: Automatically fetches the source MAC address and interface index using
ioctl. - Custom Payloads: Supports arbitrary string or binary payloads.
- Operating System: Linux (Raw sockets
AF_PACKETare Linux-specific). - Privileges: Root/Sudo access is required to open raw sockets.
Open l2frame.c and modify the following variables to match your environment:
interface: The name of your network interface (e.g.,eth0,wlan0).dst_mac_str: The destination MAC address.ethtype: Your custom EtherType (e.g.,0x8888).payload: The data you wish to transmit.
Compile the program using gcc:
gcc l2frame.c -o l2Run the executable with sudo:
sudo ./l2To verify the transmission, capture traffic on the specified interface using Wireshark. Filter by your custom EtherType (e.g., eth.type == 0x8888).
Attach your Wireshark capture here to demonstrate the frame structure.
l2frame.c: Main source code.l2: Compiled executable.
MIT License
