07-27-2003, 07:26 PM | #1 (permalink) |
Junkie
|
What's the difference between routers, hubs, switches and Proxy Servers
I just posted this to another board. As it took about 30 minutes to type, I thought some of the boardmembers here might enjoy it.
By necessity, this explanation is simplified, but it should give a good idea of the difference between switches/hubs & routers. I also include a little about proxy servers. How do routers & switches work? Think of computer networks as being made up of several different layers. There is a international standard that defines these layers; the OSI 7 layer model. This definition is conceptual, but it is very useful in discussing or defining networks and how they work. The seven layers are A - Application P - Presentation S - Session T - Transport N - Network D - Data P - Physical For our purposes, all we need to worry about are the bottom 3 layers. Layer 1 - Physical Layer This is literally the layer that the covers the physical electrical signals on the wire (or the radio signals in a wireless network). This layer is concerned with how to transmit raw bits over the communications channel (ie, wire or radio). How many volts represent 1 and 0, how long the signals should last etc. As a user, you never have to worry about this. Hubs work on this layer, as they repeat (or retransmit) EVERYTHING they receive on any port on every port. Layer 2 - Data Layer This is where the bits are grouped in frames. There are two "sub-layers" on the Data Layer - MAC (or Media Access Control) and LLC (or Logical Link Control). Most users will be familiar with the term MAC address. This is effectively the physical, burned in address of your network card. Switches work at this layer. They switch the packets (or frames) between what are called 'collision domains'. Ethernet is known as "CSMA/CD - Carrier Sense, Multiple Access / Collision Detect" network. This means each device first listens (Carrier Sense) and if the line is clear sends its packet. However, there are other devices other doing the same (Multiple Access), so sometimes two devices listen at the same time, think the line is free, and transmit at the same time. Their transmission (remember, all a frame or packet is, is some rapid changes in voltage on the cable) "collide" and nothing gets through for either station or device. The senders know this has happened as the recipient of the frame they sent did not reply with an OK. In other words, the station transmitted but didn't hear anything back, so it knows there was a collision. It waits a random amount of time and then starts again. Listen, transmit, wait for acknowledgement. So this explains what a Collision Domain is. In Ethernet, when you transmit a packet, every device on that network (or collision domain) can hear or receive that packet (as described above). In large networks, with many devices, this becomes a problem because more and more computers or devices are trying to transmit at the same time. More and more collisions occur and the general network performance degrades. This is why network hubs, which connect all devices to one big collision domain, are not great for busy or large networks. When a PC on Port 1 sends a packet/frame, it is retransmitted on every port on the hub, even if the intended target is only on a single port. Switches on the other hand are desinged to address this problem. On a switch, each port is a seperate collision domain. This means that when a PC on Port 1 wants to talk to a PC on Port 8, the frames (and therefore the signals) are only sent to the destination port. All the other ports (and the computers connected to them) do not "hear" the transmission. They can continue to send and receive normally. The number of collisions is greatly reduced, and network performance is increased. So... Switches work on Layer 2, as opposed to Hubs which work on Layer 1. They handle the way Ethernet frames are sent along the wire, and what devices can "hear" them. Routers, on the other hand, are an entirely different kettle of fish. Layer 3 - Network Layer Routers work on Layer 3. We have seen how computers on an Ethernet network can use hubs and switches to communicate. However, Ethernet is a low layer protocol. Computers also need a higher layer protocol. Most computers today use TCP/IP (Transmission Control Protocol / Internet Protocol). TCP/IP is actually a suite of many protocols. Most users only need to know about the IP part; the Internet Protocol. Without going into too much detail, IP is a protocol that allows computers to talk to each other, whether they are on the same network or on a seperate network. The term "network" here is different from "collision domain". We are talking about a virtual collection of devices that could be on seperate switches or routers (ie throughout a large building), but are on the same network. The difference is subtle but important. An IP address is divided into two parts; a host ID and a network ID. They are usually shown in decimal format, like the following 123.123.123.123. In otherwords, four numbers seperated by a period. The numbers can range from 1 to 255. You also need two other series of numbers. A Subnet Mask and a Default Gateway. So, a computer on a typical network, with a proper IP address (ie, Layer 3 address) looks something like this: IP address: 64.104.195.151 Subnet mask: 255.255.255.0 Default gateway: 64.104.195.1 How can you tell which part of the IP address is the host address and which is the subnet address? By using the subnet mask. This tells you which parts of the numbers are the network ID and which part is the host ID. This is not concrete and can change from IP address to IP address. In the example above, you can see the subnet mask has "maxed out" the first 3 sections of IP address. Remember, the decimal numbers can only range from 1 to 255. The first three sections are set to 255.255.255 and the last one is a zero (meaning it's blank). This means that the "network address" is the first 3 parts of the IP address, ie 64.104.195.151, and the "host address" (my computers address) is the last part of the IP address, ie 64.104.195.151 A computer can talk to another computer on the same network with no problems. In my example, I can talk to a computer on the 64.104.195.xxx with no difficulties. Say I have a second computer with the address 64.104.195.100. It may be in a different room (or even a different building), but because it is on the same network (ie, the network address, the first 3 numbers as defined by my subnet mask, are the same), then I can communicate to it easily. The IP protocol handles this easily. I don't need a router. Things get a bit more complex when the computer wants to talk to another computer on a DIFFERENT network. Typically, this means something on the internet, or across a large companies network. The IP packets need to be routed to the correct network, and then the correct host (ie, destination computer). How does this happen? Well, this is where a router steps in . When my computer realizes I want to talk to another computer with a different network address, it has no idea where to send the packets. What does it do? Well, it simply forwards them to the Default Gateway. Effectively, your computer is saying "I have no idea of where this is, you handle it"... The Default Gateway is always a router. The router usually knows about its neighbours (ie, your network, because you're connected to it and whatever is down the line; for home users, this usually means the ISP). Chances are you don't want to just talk to a box in your ISP's building, so the router forwards the packet onto the "next hop". This will be another router, that looks at the packet and, if it doesn't know where it is, forwards it again, up the line. It's saying "I don't know where this is either, let me send it on to my neighbour who is connected to more networks and might know". This goes on until the packet reaches a major internet router that knows about loads of networks. Eventually it will come to a router that 'recognizes' the network address and says "OK, I know where this is, go down this path and you will get there". The packet goes down the correct path until it finally reaches the correct network. The last router it talks to (which, is the Default Gateway for THAT network) says "Yeah, this network address is me! Let me transmit this packet out on the wire and the recipient will no doubt hear it and respond" The packet is transmitted onto the correct network. Every computer hears it but only the recipient responds (it could be another PC you are playing CounterStrike with, or it could be a webserver and your browsing a webpage). Eitherway, your packet has reached its destination and it sends back a reply. The freaky thing is that this all occurs in milliseconds. So... Routers are usually pieces of hardware (though PCs can "act" as a router in some circumstances) that handle how IP packets are sent from network to network. They work in Layer 3 and above. Hubs and switches are always pieces of hardware then physically handle how Ethernet frames are sent along the wire to the correct physical network card. IP (ie, Layer 3) runs "on top of" Ethernet (or 802.11b for wireless etc) which is Layer 2. Finally... Proxy Servers are used to "disguise" where you are coming from when you browse the internet. As we can see from above, your IP packets traverse the internet eventually getting to their destination. The thing is, once they get to where they are going their original starting point is included in the packet. How else would your destination (PC, website etc) know how to send the data back again?! This is normally not a problem, but when websurfing some people don't WANT their location (or original IP address) to be known. This can be for security reasons for for anonyminity or privacy reasons. You don't want someone knowing you're surfing the "Big Beautiful Women in Uniforms" website etc... So, you surf the internet through a Proxy Server. This 'strips' off your original IP address and sticks its own in there before sending the packet on its way. When the response comes back, the Proxy Server knows that you were the one transmitting to that IP address and sends the reply to you. Anyone intercepting the packets along the way and analyzing them only knows that the traffic is between "www.bighotwomen.in-uniforms.com" and the proxy server. They don't know the packets came from you. Some companies use Proxy Servers for security, as it also prevents hackers trying to intercept packets and use them as a backdoor into the companies network (complicated, so I won't go into detail here). There are also public Proxy Servers out there. http://www.anonymizer.com/ is a famous one. I hope this helps to explain. I have deliberately simplified a lot of the issues to make it easier to understand. I'm sure someone will step in and make some pedantic correction... :-) But this is for beginners and it gives a good overview of the differences between switches, hubs and routers and how Proxy Servers work. Mr Mephisto Last edited by Mephisto2; 07-31-2003 at 12:58 PM.. |
07-28-2003, 01:45 PM | #5 (permalink) |
I am Winter Born
Location: Alexandria, VA
|
Excellent work on writing this up. I've been working with stuff for over 6 or 7 years now, so it's very familiar to me, as well as having a refresher course studying for the CCNA exam, so I was pleasantly surprised to see how in depth you went.
__________________
Eat antimatter, Posleen-boy! |
07-31-2003, 09:58 AM | #8 (permalink) |
Junkie
|
Juanvaldas,
No I don't. Like I said, it was a response a question on the differences between routers, switches and proxy servers, NOT as a guide on how to "plug in" a router. And, just out of curiousity, in exactly what circumstances would you recommend to a user to just "plug in" a router? Finally, I don't think it's that technical! I tried to use "plain English" as much as possible... Mr Mephisto |
07-31-2003, 07:05 PM | #14 (permalink) |
Junkie
|
PS - Check out my "Introduction to WLANs" if you have interest in that area too...
http://www.tfproject.org/tfp/showthr...threadid=19245 Mr Mephisto |
08-01-2003, 01:51 PM | #16 (permalink) | |
Banned
Location: 'bout 2 feet from my iMac
|
Quote:
very nice, you summarized a semesters worth of class in one post. I'm impressed |
|
Tags |
difference, hubs, proxy, routers, servers, switches |
|
|