A Java implementation of a learning switch that optimally forwards packets based on link layer headers and a router that updates and forwards packets based on network layer headers.