Difference between a router and switch

ouzo

Junior Member
Jul 2, 2001
9
0
0
Can somebody explain what is the difference between a "router" and a "switch" ? Does the switch work similar to a router ? Or is it totally different ?

Thanks
 
Nov 4, 2002
84
0
0
A switch in a network sense, is a device used to connect two or more computers within a network. A router is a device that splits an ethernet internet connection between two or more computers.
 

Dug

Diamond Member
Jun 6, 2000
3,469
6
81
On the mass consumer side (~$50), a router connects two seperate networks (usually with NAT), and a switch connects within the same network.

On pro side they can become very close to each other in function. (Obviously depends on brands and model numbers.)

There are entire books written on the subject, so I won't get into it here.

Check out Cisco for more information
 

TheWarden

Member
Jan 7, 2004
26
0
0
In layman's terms...

If you had three computers that you wanted to network together, you would plug them into a switch, so that any computer could talk to any other computer.

If you also wanted to share an internet connection between all three computers, then you would plug them into a router instead. A router is just like a switch, but it has an additional port on it just for your incoming internet connection. The router would then perform NAT (Network Address Translation) between the internet and the computers on your network. This keeps your computers isolated from the internet so the whole world doesn't have direct access to them.

In theory, you could just use a switch, and plug the internet into one of the ports just like it was a local computer. This would allow all your computers to access the internet alright, but it would allow other people on the net extremely easy access to your computers. Very bad. If all you have is a switch, and you want to share an internet connection with it, then the correct way to go about it is to put two network cards into one of your computers. One would receive the internet connection while the other would plug into the switch. This computer then would act as a router, or gateway, performing NAT and keeping the rest of the computers on your network relatively safe. Just don't put anything valuable or sensitive on the gateway computer.

Cheers,
Warden
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
The difference between a router and a switch is what level of the protocal stack they operate at.

You see how a network works is a very multilayered thing. Each layer is a different level of abstraction.

Check out the osil stack for details

What we will take a look at is how a basic Ethernet setup using TCP/IP works.



The bottom layer is the PHYSICAL LAYER.

In a ethernet setup this is the actual CAT5 (or CAT6 or thinnet or thicknet, those are different protocols) wires, your nic cards and the protocols for how the electricity flows thru the wires.

A example of a device that operates at the bottom layer is the HUB.

A hub is simple device just for connecting a bunch of wires together. The advantage of this device is that:
1. it's cheap.
2. you can take one very long wire, plug it into a port and have another very long wire and plug it into another and have a total length of wire much longer then you can get otherwise.
3. Makes it easier to route cables and have more then one computer hooked up together.

The major disadvantage is that it creates a very large "collision zone". Since it effectively makes a network one gigantic wire, any signals that get transmitted get transmitted to ALL computers on the hub. So it can slow things down if you have a lot of stuff going on.



The next layer is the DATA LINK.

This is still part of ETHERNET setup.

In this layer it provides the very basic ways to identify devices.

Devices are identified by a MAC address. Each nic card or any ethernet device has a unique number called the mac address assigned to it.

That way each network device (network printer, router (but not hub or switch!)) can identify each other.

For example my nic card's Mac address is: 00:D0:09:EC:F0:98
My router's address is: 00:60:08:b0:f3:6

So if I want to send a ethernet "packet" from my computer to the router, My computer will say "I am 00:D0:09:EC:F0:98, I am sending these signals to 00:60:08:b0:f3:6. Everydoy else ignore it."

A switch operates on this level. It keeps track of each MAC address and knows which port to send those signals to reach each computer.

They have all the advantages of a hub, PLUS:
1. The reduce collision zone. Each wire is split up into it's own little "zone" represented by the MAC address. That way a signal sent from 00:D0:09:EC:F0:98 to 00:60:08:b0:f3:6 won't go to 00:02:44:0a:1b:7a's wire.

This increases network performance, because you can have 2, 4, 6, 8 etc machines talking to each other AT THE SAME TIME. Since the electical signals don't cross over each other (or "collide" or cause a "collsion").

2. Because each wire is dedicated for one computer/device you can go "full duplex". Since you only are dealing with a one on one basis the Ethernet protocol down their on the "physical layer" allows you to effectively double the bandwidth!

So a 100MB/s ehternet network becomes a 200MB/s network!

3. Security is increased. Hackers/computer techs use "packet sniffers" to find out information. On a hub every signal gets recorded, so that you can (for example) record a telnet password, from 2 machines talking to each other. On a switch the signals only go from one computer to another, a third computer can't record their conversation.

The bad things are:
1. Slightly more expensive then a hub.
2. adds a small amount of latency.

Both these are immaterial nowadays. A switch is 150% more desirable then any hub.

Basicly switch does the hub's job + some extra stuff to increase performance.



The next layer is SESSION.

This controls the packets and quality of service and makes sure the everything is being sent correctly.



The next layer is TRANSPORT

This provides a way to make sure that all 3 lower layers are doing their job. THis provides a level of "abstraction".

That way layers above this are isolated. Programmers working on the upper layers don't have to worry about the lower layers, makeing their job easier. Just as long as it works.

For example TCP/IP works on ATM networks, Token Ring networks, PPP networks, Ethernet networks.

Now you don't need to create a new TCP/IP program for each type of network, the same TCP/IP packet gets "encapsulated" OR put inside a network "FRAME".

That way the bottom 3 layers don't have to worry about TCP/IP, just as long as they do what they are suppose to do. They don't give a damn weither or not it's TCP/IP, Netbuie, IPX/SPX or any other number of "ROUTED" protocols. (protocols that get routed from one network to another, netbuie realy doesn't fit into that catagory though.)




The next layer is NETWORK.

This is were routers operate. They are MUCH MUCH more complex then any switch or hub. (although nice switchs usually have some routing abilities built in for conveinence)

This is were stuff like IP addresses happen. This is were Routing happens.

Routers operate like hubs a little bit and they operate like switch. But they also ROUTE packets. They have ROUTING TABLES.

So a router can be a hub. A router can be a switch. A router can be a router


but a switch can't be a router.

So this statement is wrong(well not wrong, but misleading.)
In theory, you could just use a switch, and plug the internet into one of the ports just like it was a local computer.



It can't go: I need to find IP address 192.168.1.10, or a website on 216.239.53.99.

It can't go I need to find a way to get thru router 1 to get to router 2 to get to router 3 to get to router 4 to get to the webserver.

Because it has no CLUE what a IP address is and it doesn't care. It does it all thru MAC addresses which are much more primitive/lower. MAC addresses can't be routed.

Plus your going thru a Cable line or a DSL, or ISDN or T1 network. They don't even use MAC addresses!!

You need a router to go from one type of network to another. You can't use a switch to go from Token ring to Ethernet to ATM, but a router can do that.

You need a router to go from one LAN to another. If you have a switch connecting 2 LANs, then they become 1 big LAN, because it can't seperate them like a router can.

EDIT:

Note that Cablee and DSL modems ARE NOT modems, They are more like a connection between 2 different digital network types.

Modem are designed to go from analog to digital and visa versa. (MODulate DEModulate)

You can connect a switch to a Cable Modem (for instance) and the "modem" will translate that from the Ethernet network to a cable network.

But a cable modem is not a Router OR a switch. It's something different, its sort of a half switch and a half router.

So then what happens is that you home network becomes part of the Cable company's network. You gateway becomes the Cable Company's router. That way you still have a router moving your packets around, it's just the Cable company's and not your own.

The bad thing then is that everybody in that cable network segment has access to your LAN inside your home. They can access your computer directly. A router at home can seperate your computer from the rest of the Cable company;s network, thus protecting you from hackers and viruses. THIS IS A VERY GOOD THING.
 

Dug

Diamond Member
Jun 6, 2000
3,469
6
81
Unless you look at layer 3 switches. Which you should, before giving out information.
 

eLinux

Member
Mar 6, 2003
191
0
0
@drag:

Ummm...OSI model has 7 layers. (from top to bottom: Application, Presentation, Transport, Session, Network, Datalink, Physical).

Where'd you get those layers?
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: eLinux
@drag:

Ummm...OSI model has 7 layers. (from top to bottom: Application, Presentation, Transport, Session, Network, Datalink, Physical).

Where'd you get those layers?

DOh.
Your right.

I got a bit mixed up. Sorry.

It goes physical -> data link -> Network then the other OSI stuff. Sorry. Stuck session and transport in the wrong spot. Don't know what I was thinking.


Anyways
Layer 3 switches are switches with routing functions.

Which I actually alluded to if you noticed. When I said that nicer switches often have routing functions.

(although nice switchs usually have some routing abilities built in for conveinence)


I didn't elaborate because I didn't want to cloud the issue. (which I failed to do anyways since I got 2 of the layers stuck in the wrong spot)

Generally a switch only deals with Data Link. The act like a bridge and isolate collsion zones for security and performance. Anything beyond that is extras.

A router deals with network layer and Routed protocols. Switches don't deal with routed protocols. IP addresses and network topology is immaterial to a switch exept thru what port to reach what Mac addresses. (unless is a switch with extra level 3 stuff built in.. Which kinda makes it a super switch or whatever)
 

TheWarden

Member
Jan 7, 2004
26
0
0
Originally posted by: drag


So this statement is wrong(well not wrong, but misleading.)
In theory, you could just use a switch, and plug the internet into one of the ports just like it was a local computer.



It can't go: I need to find IP address 192.168.1.10, or a website on 216.239.53.99.

It can't go I need to find a way to get thru router 1 to get to router 2 to get to router 3 to get to router 4 to get to the webserver.

Because it has no CLUE what a IP address is and it doesn't care. It does it all thru MAC addresses which are much more primitive/lower. MAC addresses can't be routed.

Plus your going thru a Cable line or a DSL, or ISDN or T1 network. They don't even use MAC addresses!!

You need a router to go from one type of network to another. You can't use a switch to go from Token ring to Ethernet to ATM, but a router can do that.

You need a router to go from one LAN to another. If you have a switch connecting 2 LANs, then they become 1 big LAN, because it can't seperate them like a router can.

EDIT:

Note that Cablee and DSL modems ARE NOT modems, They are more like a connection between 2 different digital network types.

Modem are designed to go from analog to digital and visa versa. (MODulate DEModulate)

You can connect a switch to a Cable Modem (for instance) and the "modem" will translate that from the Ethernet network to a cable network.

But a cable modem is not a Router OR a switch. It's something different, its sort of a half switch and a half router.

So then what happens is that you home network becomes part of the Cable company's network. You gateway becomes the Cable Company's router. That way you still have a router moving your packets around, it's just the Cable company's and not your own.

The bad thing then is that everybody in that cable network segment has access to your LAN inside your home. They can access your computer directly. A router at home can seperate your computer from the rest of the Cable company;s network, thus protecting you from hackers and viruses. THIS IS A VERY GOOD THING.

I gathered from another post that ouzo made that he was wanting to network his 3 home computers together and share an internet connection between them, which I presumed was either cable or DSL, so my remarks were aimed in that direction. I wanted to warn him away from plugging his cable or DSL modem into a switch and using that in place of a router, because as you explained in much more detail, that's a bad idea. :frown: Anyway, I realize my remarks were greatly simplified, but hopefully, given this context, they made sense. :)

Cheers,
Warden
 

Zepper

Elite Member
May 1, 2001
18,998
0
0
I look at a router as a switch with protocol conversion to connect and translate between networks running different protocols, but there are lots of variation in function.
.bh.
 

Kingofcomputer

Diamond Member
Apr 6, 2000
4,917
0
0
Are you looking for something to share internet at home?
Just buy the thing called "dsl/cable sharing router with built-in 4 port switch". As cheap as $20-30 after rebate from online or local.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: Kingofcomputer
Are you looking for something to share internet at home?
Just buy the thing called "dsl/cable sharing router with built-in 4 port switch". As cheap as $20-30 after rebate from online or local.

Definately.