network switch vs router code example Example: router vs switch switch connect hosts, router connects switches to networks beyond