I'm confused...

Auryg

Platinum Member
Dec 28, 2003
2,377
0
71
Topic summary just kinda says it all. I'm trying to make a report for college on routers, and I'm having a hard time wrapping my head around things. I get what NAT does just fine, but I've read that a router doesn't necessarily have to use NAT (at least, the high grade ones)-so what I'm trying to understand is how a router..routes? It uses routing tables I know, and I'm assuming the router uses those to tell a packet where to go? Even then, if you're not using NAT, does every computer on your network get it's own IP address?


On top of that, where do switches fit in?

I know school type questions are usually frowned upon, but I could just whip up a report that glazes over things and get a decent grade. I just really want to know :)
 

jlazzaro

Golden Member
May 6, 2004
1,743
0
0
yes, routers reside at layer 3 and use their routing table to forward packets along to different destinations. not every router is a border router, so they wouldnt all use NAT. the device performing NAT (either router, firewall, etc) is typically at the edge of the network, with one interface in your private LAN and the other the going to the public internet. if you're not using NAT at all, you would need a routable, public address for each and every computer.

switches operate at layer 2, and forward frames based on learned mac addresses. this is where your clients physically connect to and is considered the edge of your network.

OSI model
Routers
Switches
 

QuixoticOne

Golden Member
Nov 4, 2005
1,855
0
0
Few people use correct terminology these days, even hardware vendors, so it's no wonder you're confused.

Many things sold as 'gateways' , 'routers', 'access points', 'switches', 'firewalls' may or may not actually do the thing that you'd expect them to do based on their name depending on their actual configuration and the network topology in use.

ETHERNET HUB: basically this typically implies something stupid that isn't aware of the content going through it, which has little or no mechanism to or need to filter or selectively route any traffic. It is basically a way of almost just physically twisting all the wires together without REALLY doing that... Any data packet coming in on ANY port of the hub will generally be sent on to ALL of the other connections on ALL of the ports of the HUB.

ETHERNET SWITCH: This implies something that's a little more selective than a HUB and it gains its efficiency from its selectivity. Imagine you have switch ports A, B, C, D.
There are computers (1), (2), and (3) , with (1 = A), (2 = B), (3 = C) being the ways those computers are plugged into the switch ports.
If any computer let's say (1) for example wants to send a broadcast message to EVERYONE on the network then the switch recognizes it as a BROADCAST and takes the packet from (1) coming into switch port (A) and forwards it ASAP out on both switch ports (B) and (C) so computers (2) and (3) will both get the BROADCAST.
In that case it is working basically like a HUB -- one packet in, many packets out to all possible listeners on the various ports.
However let's say that (1) has some private conversation traffic for (3). In that case the switch will see a packet from (1) on port (A), and it'll look at the destination address of the packet (as a postman would look at an envelope sender and destination address to see who it's from and where it's going to to figure out how to deliver it). The switch sees that it recognizes the destination address of PC (3) and realizes that PC (3) is on its port (C). So the switch sends the packet from (1) ONLY out to port (C) which PC (3) is listening to. PC (1) and PC (2) do NOT get copies of that packet because the switch didn't need to forward it out ports (A) and (B), only (C) was the port with the destination computer on it. So by doing such selective forwarding of packets it cuts down on traffic because it'll come in on one port and go out on (typically unless it's a broadcast) only one other port, so the other ports have more free time/bandwidth to send traffic of their own because they're not innundated with copies of traffic to/from ALL other PCs.

IP ROUTER: This is sort of like a switch in that it looks at source addresses and destination addresses of packets, though it is mainly operating at the TCP/UDP/IP level (a higher more abstract level) than the ETHERNET link level. Additionally a router has either explicit configurations the user sets about routing / delivery logic, or it uses various routing protocols and heuristics to route things semi-automatically or intelligently. Routing is like, for instance, sending a package via FEDEX or booking an airline ticket.
Let's say you're from Boston and you'd like to go to Phoenix. You'd set up a packet with a source address of David in boston, a destination address of Lisa in Phoenix. But there aren't direct connections between boston and phoenix. There are connections from Boston to Manhattan, Dallas, San Francisco. Let's say there are connections from Dallas, and San Francisco to Phoenix. Let's also say there's a connection from Manhattan to Miami and one from Miami to Phoenix.
So you could route your packet:
Boston -> Manhattan -> Miami -> Phoenix
Boston -> Dallas -> Phoenix.
Boston -> San Francisco -> Phoenix.
Any of the routes would WORK, but let's say Boston -> Dallas -> Phoenix
is quickest and cheapest, so that's the preferred choice.
Maybe the route through Manhattan -> Miami -> Phoenix and the
route through San Francisco -> Phoenix cost the same money, but the one through
San Francisco is much faster.
So basically a router is something that can be manually configured to or sometimes programmed to automatically to make routing decisions about how to get 3rd party traffic from one place to another in a sensible way.
In the above case you could say you have a manually configured 'static route' so that packets with Boston Origin, Phoenix Destination are always routed to Dallas as the next step. Another router in Dallas would see a packet whose Origin = Boston, whose last relay point was also Boston, and whose Destination was Phoenix. That 2nd router would just be programmed to send it directly to Phoenix from Dallas.
However you can sometimes program in multiple routes into a routing table with various 'costs' associated with them, and even sometimes tell a router to use a protocol or heuristic to automatically adapt routing if needed.
So what happens in the previous case if Dallas can't accept traffic because of a hurricane or network outage or something? Maybe the router in Boston would see that Dallas is the preferred route, but can't be used, so it'd send the packet to San Francisco as a secondary choice route instead. If San Francisco was also not reachable, maybe it'd be programmed to send it through Manhattan and Miami instead as a last resort.

So basically routing is taking traffic matching a specific source address / network and going to a specific destination address / network and making ONE (of a possible many) decision about WHERE to send that traffic as a NEXT STEP. After the packet gets to the NEXT routed step, that would either be another router or would have to be its final destination. So you could have 20 steps of routing to get a packet from Dallas to Beijing, for instance, and traveling through 10 different networks. Typically at any major network there will be multiple possible routes to send a packet along, so decisions about speed, cost, availability, etc. influence your routing decisions.

In a home network a 'router' is really typically much simpler in that there are usually few possible places TO route the packet to. Basically any packet that is NOT going to one of the other PCs in your home goes to your ISP's gateway address, so the router just says "take anything destined to an address other than my local area network and route it to my ISP gateway address, oh, and possibly apply a NAT to it, but that isn't necessarily REQUIRED. Routing isn't NAT, and NAT isn't routing, they're two different things.

A NAT is just a translation of addresses. So if you're in college and you're in
Dorm Building 6, Room 19, you could send intra-campus mail just addressed from Rick @ Building 6, Room 19 to Prof. Li, Evans Hall, Room 17 and it'd get there.
But if you wanted to send a letter to another university the source address of just "Building 6, Room 19" wouldn't do because it's not unique on a global network (there are lots of campuses with Building #6 with Room #19). So maybe your campus mail room would take your letter going to Oxford Building 7, Room 12 and stick it in a FEDEX envelope labeled: From UCB, Building 6, Room 19, To Oxford, Building 7, Room 12, and send it on its way. It just translated an ambiguous or 'private' source address into an return address that the recipient on a different campus / network could actually understand and reply to. Whereas a NAT wouldn't be needed for purely local traffic within your own campus / private subnet.

Typically PCs on private LANs get addresses in blocks of one of several 'private' address spaces that are only for use within that LAN and which never are valid internet addresses. So millions of people on AOL or COMCAST or whatever might have their home PC on the private IP address of 10.0.0.2 with their cable gateway router on LAN address 10.0.0.1, but also on the 'global' side of its connection on a 'real' global IP address of 141.32.6.2 or whatever. So to the whole internet world your PC's address is 141.32.6.2. But to your computer it thinks of itself as on a local address 10.0.0.2, and if your wife had a PC also in the house, hers might be 10.0.0.3, etc.
But when either of you email out to the world both of your PCs 10.0.0.x get NATed so their source address translates to 141.32.6.2 before the packet is ROUTED to the ISP's gateway IP for routing out to the rest of the world. That way when the rest of the world sends a reply back to the sender address it'll get to your real address of 141.32.6.2 which your router is listening to, it'll realize it's a reply back to your wife's LAN PC 10.0.0.2 so it'll forward it there.

 

Kelemvor

Lifer
May 23, 2002
16,928
8
81
IN layman's terms, this is how I normally explain it to your average end user.

Hub is the dumbest piece of equipment around. It just takes incoming data and sends it out to all of its ports and takes the data coming in from the ports and sends it back down the line to wherever it came from.

Switch is somewhat a hub with a brain in it. It takes the data coming in and knows which of its ports that data needs to go to and sends it to that port instead of just spamming it to every port. More advanced switches let you log into them and do more fancy configuration but that's not something most people would do.

Routers take the functionality of a switch but also add in the ability of the DHCP system to assign IP addresses to devices, having a firewall built in, forwarding ports, things like that. Also you can add in Wireless connectivity as well.

If you take a router and turn off the DHCP server, you basically end up with a fancy switch.

You normally dont' want to have two routers on the same network trying to assign IPs to other things unless you specifically want to segregate things that way for whatever reason.

I'm sure some of that isn't totally accurate but it gets the main point across.