Router vs Switch - I am still confused - eviltoast

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
    ·
    1 year 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
      ·
      1 year 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
        ·
        1 year 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
        ·
        1 year 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
          ·
          1 year 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
            ·
            1 year 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
              ·
              1 year 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.