What's the difference between a switch, a router, and a modem?
5 Answers
Routers: these devices connect different networks, operating at Layer 3 (the network layer) of the OSI model. They maintain routing tables which map IP addresses (more correctly, IP prefixes) to an outgoing interface. Note that an interface may contain one or more ports (See below).
Switches: these maintain forwarding tables which map MAC addresses to physical ports, operating at Layer 2 (the data link layer) of the OSI model. This is not necessarily a one-to-one mapping; many MAC addresses can be bound to the same physical port. This is the case where you have multi-layer switched networks (think a Netgear or Belkin switch plugged into your office or university network), or a hub connected to a switch port.
Hubs: these are essentially multi-port signal repeaters, operating at Layer 1 (the phyiscal layer) of the OSI model. They can be either unpowered (simply providing a physical connection for the existing signal to propagate along), or powered, where they actually regenerate and/or amplify the signal they receive. The point to note here is that hubs are a single collision domain. A collision domain represents a set of devices all connected to the same physical transmission medium, such that only one of them can transmit at any given time (ignoring multiplexing technologies like wavelength division multiplexing, frequency-division multiplexing, time-division multiplexing, etc etc.).
In practice, hubs are found less and less in today's data networks, as they have poor performance (as only one user can transmit at a time) and poor security (anyone connected to the same hub can hear everything all other users transmit and receive).
Modems: MOdulator-DEModulator. Responsible for establishing a digital channel over an analogue medium, most commonly the telephone network. Modems again operate at Layer 2 (the data link layer), but use different protocols than Ethernet to communicate. They then offer protocols such as PPP to the network layer, to allow IP traffic to flow over their links.
- 385
- 5
- 13
- 10,166
- 8
- 40
- 62
-
Great answer. Well thought out. Though, the PPP link is established over that digital channel, it is the channel itself. – GreenKiwi May 25 '09 at 03:42
-
Someone correct me if I'm wrong, but my understanding is that Layer 2 networks (or at least ethernet networks) have a tree structure (exactly one path between any two endpoints) and thus don't have to do any routing to find an optimal route. If so, this would be a fundamental difference between switches and routers. – Kevin Wheeler Sep 08 '15 at 19:48
-
@MuraliSuriar Over servervault I am seeing conflicting information on which layer a modem belongs in, most references placing it into layer 1. https://networkengineering.stackexchange.com/questions/16636/which-layer-does-modem-operate-and-are-they-still-used – Copy and Paste Apr 20 '17 at 17:37
Hmm... For get a good understanding you will need an understanding about OSI model. But I will try to explain them as simple as possible.
Basically any networked transmission is going through the indicated path. In simpler words the data you sent is converted into electrical signals to transmit over physical link.
The bottom layer just has an idea about electrical signal not about any bits or bytes. The layer 2, Data link layer has an awareness about MAC addresses. When we are coming to layer 3 - Network layer we have some more high level approach, it can process IP addresses as well.
When we are talking about a router, router is a Layer 3 device, that can work with IPs. It can take decisions based on IPs. as an example route a packet based on IP or filter packets.
But Switch is just only a Layer 2 device. I just worries only on Physical addresses. (MAC addresses) and all the data communication is done using MACs.
Oskar Duveborn has given a more straight forward answer on that..
Directly addressing your comment the router works with IP addresses while switch works with MAC addresses. I have no good idea about the internal architecture of a modem. Sorry buddy :(
This short article has explained some of the visible differences between the device types. It may be useful to you.
- 118
- 5
- 1,063
- 1
- 11
- 16
I really like Chathurangas answer ^^
But here's an attempt at using layman's terms, which will skew reality and leave important bits out:
- Modem: translates between different kinds of signals/media, like when you go from a phone line to a local ethernet network.
- Router: forwards (routes) traffic from one network to another, doesn't care about the media. Consumer-level routers are often built into modems and switches which can handle the physical connections say between ethernet networks and the outside world phone lines on the way to the internet service provider.
- Switch: forwards traffic within a single network (traditionally). Used to connect networked devices together within a single network.
Put together with the OSI layer diagram, this could be enhanced a lot I guess... this could be the Serverfault version of that famous Stack Overflow question that seemed ridiculously simple on the surface, but spawned a lot of highly detailed answers.
- 10,740
- 3
- 32
- 48
-
Thanks ^^ ...I'm pondering about trying to remove the terms ethernet at the very least to make it simpler... but... somehow this french ale have made me lazy – Oskar Duveborn May 24 '09 at 18:03
-
According to this.. Can we categorize the modem and the other devices into same group? Can we put the modem in to a certain layer in OSI? Layer 3? – Chathuranga Chandrasekara May 24 '09 at 18:06
-
a modem doesnt needs to even use TCP technically, so the current definition he uses is acceptable by me – username May 24 '09 at 18:10
-
Yes. I just asked to get to know because i felt it is worth to know :) – Chathuranga Chandrasekara May 24 '09 at 18:39
-
ok sorry, i'm being somewhat hypocritical i realize, since i insisted on MAC address and IP for the other two, and then i said we don't need to tie modems to TCP – username May 24 '09 at 18:41
-
I guess a modem would be layer 1-7 - which brings me to the problem with the OSI layer model ^^ (though the bare basics would be layer 1-2 for a modem I guess) – Oskar Duveborn May 24 '09 at 18:51
-
I would consider a modem to be a bridge between two distinct physical mediums, e.g. fibre-optic to RJ45, DSL to RJ45, microwave to RJ45, etc. Therefore, I would place modems in the upper part of Layer 1. – StockB Jun 24 '15 at 19:43
Layer 2 Switch - forwards ethernet frames between switches on a local campus. in addition some switches support static and default routing.
Layer 3 Switch - forwards packets between VLANs and subnets on local campus network. Supports static, default and dynamic routing.
Router - forwards packets between subnets across a WAN and between routers and switches.
Cable / DSL Modem - translate between Ethernet interface at a desktop or router and Cable (DOCSIS) / DSL broadband signaling.
- 46
- 3
Routers: (Layer 3/IP)- It is an electronic device that connects atleast two networks and exchanges packets among them according to the information provided in the headers of these packets and the routing tables.They are designed to join together multiple local area networks (LANs) with a wide area network (WAN).They are smarter than Hub or switches. Routers serve as intermediate destinations for network traffic. They receive incoming network packets, look inside each packet to identify the source and target network addresses, then forward these packets where needed to ensure the data reaches its final destination. Neither switches nor hubs can do these things.
Switches(Layer 2/Ethernet): They are smarter than Hubs.Instead of Broadcasting the packets to all the hosts in the network like hub, switches first determine which device is the intended recipient of the data and then sends it to that one device directly. Switch does this by creating a domain and prevents the packet from sending it across the switch to other networks if the destination is in the same domain.If its outside the same domain, then a request is broadcasted to all the domain if flooding is required(i.e when table is not maintained with corresponding port to mac address).It requires the creation of switch table inside the switch, which maps the destination mac address to output ports inside the switch. The initial request will update the empty table with port and mac address of the originating domain. Learning switch: first it floods the frame with request and then updates the switch table based on the request and response.
- 1
- 1