This project implements a personal local area network (LAN) entirely in Java by simulating real networking components and protocols. Virtual hosts, switches, and routers communicate across multiple machines to model how data moves through a real network from Layer 2 to Layer 3.
The system integrates multiple core networking algorithms, including the Ethernet Learning Switch algorithm, IP Forwarding, and Distance Vector routing using the Bellman-Ford equation, resulting in a fully functional, distributed virtual network.
For this project, a local area network was constructed by implementing virtual switches, hosts, and routers within Java on three different machines. It also implements several different algorithms (Ethernet Learning Switch algorithm, IP Forwarding algorithm, Bellman-Ford equation) along with distance vector routing.
- Simulate a real-world local area network in software
- Implement core networking components across multiple machines
- Demonstrate packet forwarding from Layer 2 through Layer 3
- Implement distributed routing and route convergence
- Understand how control-plane and data-plane logic interact
The virtual network supports end-to-end message delivery across multiple subnets by combining:
- Ethernet frame switching
- IP packet forwarding
- Dynamic route discovery and optimization
Each device communicates using UDP sockets while maintaining virtual MAC and IP addressing, closely modeling real network behavior.
- Dynamically learns MAC address → port mappings
- Forwards frames selectively when destinations are known
- Floods frames when destinations are unknown
- Operates at Layer 2 (Data Link Layer)
- Routers inspect destination virtual IP addresses
- Routing tables determine the correct outgoing port or next hop
- MAC addresses are rewritten at each hop
- Enables inter-subnet communication
- Operates at Layer 3 (Network Layer)
- Routers exchange distance vectors with immediate neighbors
- All links use a uniform cost of 1
- Bellman-Ford equation computes shortest paths
- Routing tables dynamically update and converge
- Enables automatic route discovery without hardcoding paths
- Multiple hosts generate and receive user messages
- Switches forward Ethernet frames using MAC learning
- Routers forward IP packets and exchange routing updates
- Each device runs as an independent Java process
- Devices communicate across three different machines
Routers distinguish between:
- User packets (data traffic)
- Routing packets (distance vector updates)
- Each device (host, switch, router) is started as a separate Java process.
- Devices read a shared configuration file describing:
- Physical addresses (IP + port)
- Virtual MAC and IP addresses
- Network topology
- Switches and routers initialize first.
- Hosts send messages using virtual IP addresses.
- Packets traverse the network using learned MAC tables and routing tables.
- Routers dynamically converge on optimal paths using distance vector routing.
- Multi-hop packet forwarding
- Dynamic routing convergence
- MAC address learning and flooding
- End-to-end message tracing
- Realistic simulation of layered networking behavior
- Java
- UDP Sockets
- Ethernet Switching
- IP Forwarding
- Distance Vector Routing
- Bellman-Ford Algorithm
- Layered network design (L2 & L3)
- Distributed systems
- Routing convergence
- Control plane vs data plane logic
- Protocol-based communication
- Network simulation and debugging