Probably a very basic question but confused the hell out of me - say if I have 100mb internet at home, and scenario one, a router with 100mb port speed and I connect two PCs to it, each has a 100mb NIC card, is it true that ignoring other factors I should be able to get close to, if not 100mb connection on each of the PCs? On the other hand, scenario 2, if I have a (unmanaged) switch and I connect the PCs to the switch I would only ended up getting 50mb each on each of the PCs (i.e., the switch essentially “halved” my internet speed if I connect 2 PCs to it, 1/3 if I connect 3 PCs to it, etc)?

  • NavySeal2k@alien.topB
    link
    fedilink
    English
    arrow-up
    2
    ·
    11 months ago

    Ok I guess we have to start way in front of your question to not just answer your question but give you an understanding.

    First of all, what does a switch do: A switch has for example 24 ports and all ports are connected to the CPU of the switch. When a pc connected to the switch wants to reach the router to access the internet he asks the switch to really the data to the router but the switch doesn’t know where the router is so it sends on all ports „Hey are you 192.168.0.1(for example if it’s the gateway in your network config)“ then on one port the router answered „yes“ and the switch makes a note on a list that this up is on port x. So over time the switch knows who is where and what speed does the port support. Because said CPU has a bandwidth normally greater than the sum of all ports (rock a Unifi 24 port switch by chance and it had 26gbit bandwidth) it can for example connect 2 pcs transfering files with a full gigabit all while running a download from the internet router to a third pc with no problem. So as long as you don’t want to access one ressource with multiple PCs you have full speed and if you do the packets are stored in a small buffer and if it is full the PCs are told to wait a millisecond and it is transfered in a first come first serve method so everyone can get data through.

    All a router does extra on top is have an extra list if he doesn’t find the receiver of the packets internally he notes the address of the PC that asked and sends the request to the wan port and when someone responds he know who to send the response internally.

    • zhuanyi@alien.topOPB
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 months ago

      Thanks for the detailed explanation - so if I understand this correctly, basically there is a port speed and there is an internal bandwidth speed - a port speed could be 100M, 1G, or 10Gbit, for example, but the internal bandwidth should be much much larger than that.

      My follow up question is then: if I have a ISP modem -> router A and ISP modem -> switch -> router B connection set up (both connecting from the same ISP modem but using different ports on the modem) and all my PCs/game consoles/smart TVs are connecting to router B and all my IoT devices are connecting router A, in terms of the speed for devices connected to Router B it should, at least in theory, enjoying whatever bandwidth that’s not used by the IoT devices in router A (which I assume would be minimum) and if I only have one PC turned on and that’s the only device connecting to router B then my PC should almost have the same speed as the minimum of all port speed and my internet speed? Is that correct?

      • NavySeal2k@alien.topB
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 months ago

        The first part is correct, mostly it isn’t “much much” higher because it is wasted performance but you could hace a 24port switch with the CPU of a 48 port switch and you could have over 50GBit internal switching bandwidth for the 24 ports.

        The Second part is a bit strange for me. Probably because of the wording. When you say modem it is probably already a router because you have multiple LAN ports. A Modem normaly only supports 1 WAN and 1 LAN Port at consumer level devices.

        You can have routers behind routers but unless manually configured correctly on the main router and the 2 routers WAN the 2 LAN Networks behind each router can’t reach each other, like you cant easily reach your neighbors PC unless he opens a connection to it specifically.

        Whats the model number of the thing you called a Modem?

        Can you extend on what you meant when you statet “which I assume would be minimum”

        And without and even in some cases with expensive load balancers you cant say stuff like “use bandwidth that is left by IoT” for example. It is very random who gets more or less bandwidth of a connection when it is at full capacity. Because of the way TCP was designed in the beginning. Resiliency was much more important than fairness ;)

      • mlcarson@alien.topB
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 months ago

        Link speed is your hard limit – you can’t go faster than that. Nothing gets divided up just because a device is on. The concept of bottlenecks is what’s important. If you had a 100Mbs switch (with 1Gbs uplink) and a 1Gbs router with a 500Mbs ISP speed, a PC on the switch will be bottlenecked at your 100mbs switch port – it won’t be able to go beyond 100mbs. If you have 5 PC’s on that 100Mbs switch all trying to do 100Mbs each (since that’s the bottleneck of the switch), each PC will be able to do 100Mbs and since you have a 500Mbs speed connection – each PC should get 100Mbs. The switch uplink will pass 500Mbs/1000Mbs and the router will pass 500Mbs to the ISP. If you add a 6th PC trying to do 100Mbs then it gets bottlenecked at the ISP link since it can only do 500Mbs even though the router can do 1Gbs.

        If your 100Mbs switch had no 1Gbs uplink then the fastest switchport to the router would be 100Mbs. In the first scenario of 5 PC’s trying to do 100Mbs each, they would all be throttled to roughly 20Mbs since the total connection out of the switch would be 100Mbs. If only 1 device tried downloading, the limit would be 100Mbs for that device since the limit would be the link speed of the switch to the router.

        If you had a PC directly connected to your router at 1Gbs bypassing any 100Mbs switch limits, the bottleneck would be at the ISP of 500Mbs. If you had devices on the 100Mbs switch (with 100Mbs uplink) trying to download at max capacity while your PC was directly connected, your expected speed would be 400Mbs since 100Mbs would be going to the switch.

        The concept of a 24-port Gigabit switch with only 1Gbs uplink works because no device is expected to be constantly utilizing 1Gbs for a sustained period of time. They also supply full bandwidth to ports across the switch that don’t have to go across a common uplink. PC A and PC B can talk to each other at 1Gbs if on the same switch while PC C is talking to the Internet at 1Gbs. As long as the devices aren’t utilizing a common port at the same time, there’s no bottleneck.

        • NavySeal2k@alien.topB
          link
          fedilink
          English
          arrow-up
          1
          ·
          11 months ago

          No switch or router does load balancing, you wont get 5 times 20mbit it will be all over the place…

          • mlcarson@alien.topB
            link
            fedilink
            English
            arrow-up
            1
            ·
            11 months ago

            You could actually expect less than 20Mbs because of congestion issues assuming no QoS and you’re right that any port might get more at any particular moment of time. This is mean to be an illustration of bottlenecks and not an implication of layer-2 load balancing. The traffic just can’t be more than what the bottleneck will allow.

            • TheEthyr@alien.topB
              link
              fedilink
              English
              arrow-up
              1
              ·
              11 months ago

              There’s another variable here, which is the behavior that TCP and UDP flows have on each other. There are a number of TCP congestion management algorithms that have been developed over the years. This paper, for example, shows that BBR congestion control is very unfair to CUBIC. IOW, if one PC is using BBR and another CUBIC, the first PC will hog most of the bandwidth.

              Similarly, QUIC, which is a UDP-based alternative to TCP originally developed by Google and used a lot by Chrome, is quite unfair to TCP as the images show.

              Anyway, this is a bit off topic. The main point that the network is only as fast as the slowest link is correct.

  • mcribgaming@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    Scenario 2 is more accurate for BOTH cases, but not because you used a switch. Scenario 1 is false.

    It’s the ISP provided speed that is the limited resource. You have 100 Mbps of Internet service, which can be consumed by any single connection. If multiple connections want to use Internet, that speed gets split up between all the devices trying to use it simultaneously.

    It does not have to be in equal pieces. If one connection only wants 20 Mbps of Internet, another connection can use the other 80 Mbps remaining.

    Using a switch does not affect the consumption of Internet from devices unless the switch port speed itself is lower than your maximum ISP speed. This isn’t true in your example.

  • ElevenNotes@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    No. In all cases all devices have maximum speed of your network equipment and themselves. I think what you meant to ask if a switch would reduce the bandwidth available to the devices, which is also a no. Both PC’s using the internet at the same time will reduce the bandwidth, but not 50:50. A normal unconfigured router will give 100% of the bandwidth to each connection, meaning, if PC A is downloading a 1GB file that takes 10’ to download, the internet for all other devices for the next 10’ would appear to be very slow, till that download is finished. A more advanced router, would reduce the bandwidth of PC A to like 70% so that 30% can be used by PC B. In any case, the network equipment you use, as long as it is faster or the same speed as your internet connection, and not connected by dozens of switches, will not slow down your internet. Multiple clients do. I have a network of over 250 clients at home, so there are rules in place to guarantee the bandwidth needed for certain devices (like TV’s for streaming) where as other devices (like phones or tablets) are less prioritized.

    • zhuanyi@alien.topOPB
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 months ago

      Thanks a lot, yes indeed that’s the question I have but I wasn’t just not sure how to ask it. So if I understand it clearly, roughly speaking if there is a device on the switch that saturated the pipeline then all other devices are slowed, but in router with the QoS settings you could guarantee a minimum bandwidth for each of the device? So if I do not use any sort of QoS settings would that essentially make router almost like a switch in terms of routing traffic? I understand obviously routers these days have a lot more functionality like VPN gateway or printer server but let’s just ignore those for the sake of discussion.

  • egoalter@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    The difference between switches and routers used to be very clear. Today what is sold to consumers as routers have built-in switches. And some advanced switches can do routing. But since your topic isn’t really related to your question, it’s not here or there.

    Ethernet - the cables and nics that are commonly used today, is a broadcast network. Meaning every device on the wire can talk without waiting. In the olden days, there was just a wire between all the PCs, no switch - and because there was a limit to the length of that wire, we had “cheap” devices called hubs that simply took X number of plugs and connected them electrically as if it was one long wire. On that wire, only ONE pc could talk at a time. While it talked, everyone else had to listen and wait for silence; then it would try and if nobody else talked it would continue to transmit.

    Switches fix that - instead of electrically making it one long wire, it splits each port into its own little network. It’s quite normal that only one PC/server is on that line - but it’s not really required. It means each PC while still listening to see if there’s traffic on the wire before talking, doesn’t have to contend with other PCs talking as long as they’re not talking to it. A great advantage of this is that you get close to the physical speed limit on each port - the switch having a lot of electronics (a small computer) can forward signals from one port to another. To do this, the switch notes which MAC addresses are present on each port, and it looks at the header of the packages to determine its MAC destination and hence what port to use. The switch, even the ‘cheap’ ones, can easily forward 100Mbps from one port to another at 100Mbos both ways.

    But here’s the crock of it - not every device you attach to a switch talks at the same speed. With TCP each package has to be acknowledged, so when a PC isn’t ready there’s no ACK and hence the sender has to wait. So it may have plenty of bandwidth but it’s not going anywhere until the receiver is ready.

    If you have a single port on your switch that everything else wants to “share” and transmit through, when that port’s bandwidth is at its limit, the senders will be told to wait. It doesn’t have to be your cable modem - it can happen if you have a file server on one port, and have everyone in your family trying to view pictures on it at the same time. It’s like a water pipe - you can only push a certain amount of water through at a time. It doesn’t matter if you split it into several more pipes - if the water has to go through that single pipe, that’s your limit.

    In advanced networking we can do a lot of things to help determine which traffic should have priority; but the limit is still the limit. It can be made to appear as not making everything slow, by giving priority to the short bursts from user-interactions, while down prioritizing long file transfers and similar.

    A gateway is a device that moves traffic between networks - but it’s still bound by the same bandwidth issues. Switches are only able to stay within the networks connected to it. A gateway knows which system to send traffic to/via to get to the final destination. They often have few ports - where switches can have a lot - 24, 48 or even more. Gateway devices typically have less than 10 and often less than 5 ports. Unless you have them combined with a switch internally.

    Consumer grade devices rarely have advanced features - so it’s first come, first serve. As you get more and more smart devices, streaming etc. in your home you’ll find you need more advanced networking equipment to avoid issues with everyone wanting to go online at the same time.

  • AlexisColoun@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    You have one pipeline to the Internet that is 100 Mbps wide and it doesn’t matter if you put the split of this bandwidth in your router or your switch. At some point all your systems will have to share this 100 Mbps between them.

    And this shares are dynamic. If one device currently only uses 10 Mbps, the remaining 90 are free to be used by all the other devices. (highly simplified)

    And actually, if your router has more then one lan port, chances are high that this is a switch within your router.

  • no_step@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    You have a 100mb internet connection, so your local network splits that between various devices

  • RScottyL@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    Even if you only have 100 Mbps internet, you still want to make sure your router and switches are 1 Gbps…

    it will give you enough overhead in the connections, especially if you still want to transfer data from one device to another on your network.