Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Hub, switch, router

  1. Mar 20, 2015 #1
    In my computer textbook, on one page, its given that switches can't stop traffic from travelling to all other LAN segments.
    WP_20150320_19_46_45_Pro.jpg
    On the next page, it says that switches send traffic only to appropriate connections.
    WP_20150320_19_51_53_Pro.jpg

    On a YouTube video, it says both will happen. First it send the packets to all workstations, learns the address, and then next time, sends data only to the required destination.

    I am totally confused. Everyone has their own definition for a switch. Can someone give the actual working of a switch?
     
  2. jcsd
  3. Mar 20, 2015 #2
    It definitely will help you if you know something about the OSI model of communication, as they all work differently because they all work on different levels of it (the OSI).
    I would recommend starting here. The book should have mentioned this first, or possibly it's about to.
    Hubs work on a very low level, the physical level, as does USB devices. Switches and routers have software built into them. This allows them to work sooooo much differently than a hub, and they're much better at everything they do.
    I hope this helps a bit.

    http://en.wikipedia.org/wiki/OSI_model
     
  4. Mar 20, 2015 #3
    Ok. But how does a switch work? Everyone seems to have their own definition and mechanism gor switch.
     
  5. Mar 20, 2015 #4
    Think of a switch (layer 2 device) as a device that connects things on a network (hubs (layer 1 device) are too simple for that task nowadays). Switches know addresses of devices because they remember MAC addresses, and can transmit information from device to device, like a computer to a printer, computer to computer, etc.

    A router (layer 3 device) will be attached to a switch, but the router connects everything to a WAN (ie. the internet) The internet needs at least a layer 3 device to talk to it.

    If you run out ethernet ports to use on a router, you can buy a switch and connect it to one router port, and then share that one port with more devices that are connected to the switch.

    Really, a switch is like a router, except the router connects to a WAN.

    Does this help?
     
  6. Mar 20, 2015 #5
    One question.(my only question)
    Does a switch transmit data to the required LAN segment or does it replicate the signal and send it to all LAN segments like a hub?
    My book says it does and also says it doesn't :(
     
  7. Mar 20, 2015 #6
    Here is another pic. They say switch sends packets only to the target LAN. But they also state that switch sends packets to all LANs like HUB. Soon, I am going to get mad because of this confusion. Please help.
    WP_20150320_23_02_47_Pro.jpg
     
  8. Mar 20, 2015 #7
    Here is another picture in the next page of the same book.
    WP_20150320_23_07_24_Pro.jpg
     
  9. Mar 20, 2015 #8
    The book is correct, but a bit vague.

    A basic switch will send data packets to all LAN segments, but they won't do what a hub does and keep sending to all devices/connections on that switch. The switch will not send data to all devices PAST itself.
    So if you are a switch, and you receive packets from another switch, you will look to see if you have a matching address. If you don't, you'll ignore it. If you do, you will pass it on to the appropriate device.

    Btw, it should say MAC address, not MAL address. There are a lot of spelling mistakes in that textbook.
     
  10. Mar 20, 2015 #9
    So you say that Switch does not send the packets to the appropriate segment. But look at the comparison given between hub and switch. It says it sends packets only to appropriate connections.
     
  11. Mar 20, 2015 #10
    Yes, it's correct because it doesn't send packets to each computer behind the switch, only the correct computer behind the switch.
    It doesn't send packets to every single device on every single LAN segment. It sends to all LAN segments, but not every device on every LAN segment.
     
  12. Mar 20, 2015 #11
    Switch sends signals to all LAN segments.
    Switch stores the MAC address.
    Once the signal reaches the LAN segment, then which device filters it?
    It should know if the packets received belongs to its segment.
     
  13. Mar 21, 2015 #12
    A switch only knows about the devices connected to it. (they OWN the devices, so to speak)
    A switch doesn't know about devices connected to other switches. (computers and printers connected to other switches)

    Example:
    If a computer behind switch A wants to print to a printer that is behind switch F, switch A will need to send the request to all of the other switches it knows, so switches B, C, D, E, and F. Only the switch with that printer behind it will be able to act on the request. The other switches (B, C, D, E) will ignore the request.
     
  14. Mar 21, 2015 #13

    Svein

    User Avatar
    Science Advisor

    The answer is yes - and no.
    When the switch is powered up for the first time, it does not know what devices are connected to its ports (it does, however know whether or not a powered-up device is connected to a port). Then a packet comes in on one of the ports. The switch does two things:
    1. It stores the sender address and the port number in a device list
    2. It then transmits the packet onto every port except the port it arrived on (this is called "flooding")
    This behavior continues until a packet arrives where the destination address is already in the table. Then the switch "knows" what port the packet should be transmitted on and only transmits the packet on that port.

    After a (short) while, the device list contains the address of all live devices in the system and does not need to use flooding anymore - with two exceptions:
    1. If a new device is powered on, the switch has to learn the address of that device in the same way
    2. The switch also has an internal clock. Every time a packet arrives, the clock value is stored together with the address and port number in the device list. Every minute (or so), the switch looks through the device list and deletes devices it has not heard from for a long time (2 - 5 minutes). This allows devices to be disconnected and reconnected somewhere else in the system.
     
  15. Mar 21, 2015 #14
    Finally. Thank you @Svein and @cptstubing for helping me.
    @cptstubing , sorry for troubling you with so many doubts. Now i know how a switch works. Thank you.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook