Skip to content

emptybulebox1/EtherToTransStack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EtherToTransStack

Overview

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.

Architecture

The stack is organized in a layered architecture:

Link Layer

  • Ethernet frame handling
  • Device management for network interfaces
  • Support for sending and receiving raw Ethernet frames
  • MAC address resolution

Network Layer

  • IP packet processing and forwarding
  • ARP protocol implementation for address resolution
  • Custom routing protocol (similar to RIPv2)
  • IP fragmentation and reassembly

Transport Layer

  • Complete TCP implementation
  • Connection establishment and termination (SYN, FIN sequences)
  • Flow control with sliding window
  • Retransmission mechanisms
  • Socket API for application integration

Key Features

  • 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

Directory Structure

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

Implementation Details

  • 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

Building and Running

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
make

Testing

Various 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_client and echo_server: Test TCP connection and data transfer

Dependencies

  • libpcap
  • POSIX threads library
  • Standard C library

License

This project is an educational implementation of networking protocols.

About

A complete network protocol stack built entirely from scratch, covering Ethernet link layer through TCP/UDP transport layer. Features low-level frame parsing, IP packet routing, TCP's reliable transmission (handshake, congestion control, retransmissions), and UDP datagram services.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors