EtherToTransStack is a comprehensive implementation of a network protocol stack built from scratch, starting from the Ethernet layer up to the Transport layer (TCP). This project provides a fully functional networking stack that operates on virtual network interfaces and implements essential networking protocols.
The stack is organized in a layered architecture:
- Ethernet frame handling
- Device management for network interfaces
- Support for sending and receiving raw Ethernet frames
- MAC address resolution
- IP packet processing and forwarding
- ARP protocol implementation for address resolution
- Custom routing protocol (similar to RIPv2)
- IP fragmentation and reassembly
- Complete TCP implementation
- Connection establishment and termination (SYN, FIN sequences)
- Flow control with sliding window
- Retransmission mechanisms
- Socket API for application integration
- Modular Design: Clear separation between networking layers
- Protocol Support: Implements Ethernet II, ARP, IP, and TCP protocols
- Routing Capabilities: Custom routing protocol for packet forwarding
- Thread Safety: Mutex-protected shared resources
- Debugging Tools: Packet tracing and network state inspection
- Test Applications: Echo servers, packet senders/receivers, and routing tests
src/
├── include/ # Header files
│ ├── link/ # Link layer interfaces
│ ├── network/ # Network layer interfaces
│ └── transport/ # Transport layer interfaces
├── link/ # Link layer implementation
├── network/ # Network layer implementation
├── transport/ # Transport layer implementation
└── test/ # Test applications
├── eth_sender # Ethernet frame sender
├── eth_receiver # Ethernet frame receiver
├── arp_sender # ARP requester
├── arp_receiver # ARP responder
├── ip_sender # IP packet sender
├── router # Routing test application
├── echo_client.c # TCP echo client
└── echo_server.c # TCP echo server
- Uses libpcap for accessing network interfaces
- Custom implementation of protocol headers and state machines
- Socket API compatible with standard socket programming
- Support for routing between multiple virtual interfaces
- ARP cache for efficient address resolution
- TCP connection state management following RFC specifications
The project uses Make for building:
# Build the entire stack
cd src
make
# Build specific components
cd src/link
make
cd ../network
make
cd ../transport
make
# Build test applications
cd ../test
makeVarious test applications are provided to verify the functionality of each layer:
- eth_sender and eth_receiver: Test Ethernet frame transmission
- arp_sender and arp_receiver: Test ARP protocol functionality
- ip_sender: Test IP packet transmission
- router: Test routing capabilities
echo_clientandecho_server: Test TCP connection and data transfer
- libpcap
- POSIX threads library
- Standard C library
This project is an educational implementation of networking protocols.