Ethernet Hub (switch) Design - Page 1
Forum section: electronics / projects

author: palpurul
author_rank: Regular Contributor
timestamp: January 09, 2024, 12:31:06 pm
content: Hello guys!We have an application where we have to implement an ethernet switch.As I am fairly new to ethernet applications I have a few questions and some of them might be stupid, so bear with meApplication:What we need is basically 3 ethernet connections. We have a SOM with ethernet connection, an android phone that's connected to a USB-to-Ethernet bridge (LAN950x) and an external RJ45 ethernet that we get the internet connection from. The idea is to connect all of these ethernet connections together withKSZ8794CNXchip. We want to share the internet from the RJ45 connector to SOM unit and also establish communication with the phone over the switch and over the USB-to-Ethernet switch. Is it possible?I've been doing a little bit of research, but I don't think I understand ethernet protocol on a basic level.A few more questions:Is there a concept of master/slave in ethernet as well? In USB we have device and host, I am not sure if that's applicable to ethernet protocol as well.I do not need the RGMII/MII/RMII Interfaces in KSZ8794CNX, Can I omit them?The datasheet of KSZ8794CNX mentions that the port with RGMII/MII/RMII Interface is the uplink. I really don't understand what it means. Is it the master (or host) of the switch? I've been researching about this and I always get mixed answers. From reading some of the tutorials, it feels like every port on an ethernet switch is the same, but some of them has different properties.Thanks in advance!PS: I also posted the same question on microchip's forum, but didn't get a respond yet

author: wasedadoc
author_rank: Super Contributor
timestamp: January 09, 2024, 01:03:15 pm
content: Quote from: palpurul on January 09, 2024, 12:31:06 pmNo.Be aware that a hub and a switch are different. A hub sends incoming packets to all the other ports. A switch sends an incoming packet only to the port that the intended recipient is connected to.

author: 2N3055
author_rank: Super Contributor
timestamp: January 09, 2024, 01:12:02 pm
content: Quote from: palpurul on January 09, 2024, 12:31:06 pmThere are other documents in addition to datasheet on Microchip web site page for KSZ8794CNX ..Browse through them, there are interesting ones answering your questions in detaill..

author: CaptDon
author_rank: Super Contributor
timestamp: January 09, 2024, 01:56:33 pm
content: A hub is sort of the electronic equivalent of hooking all the wires together, no matter where the input came from it is sent out on every port. The switch looks at the I.P. / MAC and sends out only to the port expecting that packet. The switch learns about each user connected to each port. There are firmware applications available for download when you use an FPGA controlling several 'PHY's to create your own custom Hub, Switch or Router. Be aware of the short falls of self-design with the likes of packet formatting to conform to standards of transmission. We went crazy trying to do the 'Ethernet Control Buss' on locomotives and ran into terms like 'Jabber' and 'Runts' We were simply trying to squirt raw data through the PHY's to take advantage of the robustness of ethernet signalling. The PHY's were too smart and said "No you won't, we have rules here"!

author: soldar
author_rank: Super Contributor
timestamp: January 09, 2024, 02:16:36 pm
content: Is there a reason you do not want to use a commercial switch? You can get one pretty much for free.I have several in my junk pile. Now that ADSL has pretty much disappeared you can get old routers for free and just use the switch part.

author: palpurul
author_rank: Regular Contributor
timestamp: January 09, 2024, 02:49:09 pm
content: Quote from: soldar on January 09, 2024, 02:16:36 pmI need to integrate into a product, so I selected these chips, but I am not sure if I am doing anything completely wrong.

author: madires
author_rank: Super Contributor
timestamp: January 09, 2024, 03:00:47 pm
content: Quote from: palpurul on January 09, 2024, 12:31:06 pmYes! Connecting multiple ethernet devices is the job an ethernet bridge chip. The IP (network) layer is a different story.Quote from: palpurul on January 09, 2024, 12:31:06 pmBasically there are data frames with a source and destination address (MAC), and a payload (mostly IP). Any connected device can send a frame at any time, but some clever rules help to prevent multiple devices from sending at the same time.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 09, 2024, 03:01:06 pm
content: Quoteno, all nodes are equalQuoteYesQuote"Uplink" is a bit of an artefact from when ethernet didn't use auto-MDX to allow port direction to be ignored. May also be relevant for higher-end systems where one port is expected to have much more traffic or run at higher speed (as is the case with the KSZ8794, where only this port can do 1gbit), but in most cases it can just be regarded as another normal port

author: madires
author_rank: Super Contributor
timestamp: January 09, 2024, 03:16:47 pm
content: Quote from: CaptDon on January 09, 2024, 01:56:33 pmThe classic ethernet switch (bridge) looks at the destination MAC. When it's also lookting at the IP destination address it would be a so-called layer 3 switch (switch and router in one box/chip). The differentiation is based on the OSI reference model (ethernet = link layer, IP = network layer).Quote from: CaptDon on January 09, 2024, 01:56:33 pmIf you want to create your own protocol on top of ethernet it has to be done at the network layer (ethernet's payload).

author: palpurul
author_rank: Regular Contributor
timestamp: January 09, 2024, 03:19:15 pm
content: Quote from: mikeselectricstuff on January 09, 2024, 03:01:06 pmThank you for your response, that was very helpful.Do you have any recommendation for ethernet PCB design. Terminations, magnetics and everything is bit confusing. It seems like each connector is a bit different (some of them have magnetics and terminations, some of them have none, some of them have termination or magnetics etc.), and there are also different things on the chip side as well. Some chips have terminations, and some chips don't. I am looking for a document or tutorials that kind of covers termination, magnetics and everything else. If you have anything for me please let me know.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 09, 2024, 04:00:25 pm
content: Quote from: palpurul on January 09, 2024, 03:19:15 pmsee if you can find appnotes or reference designs for the switch chip or anything similar. 100M isn't too critical for PCB layout etc.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: January 09, 2024, 06:47:45 pm
content: Quote from: mikeselectricstuff on January 09, 2024, 03:01:06 pmBest I know, the "Uplink" is also used for packets the switch does not know what to do with such as incoming DHCP requests. Although a switch may also work on the ethernet layer and not look into TCP/IP packets at all. There are also different sorts of switches. Have a look at "Managed switch" for the more advanced versions.True Hub's probably don't exist anymore (for Ethernet). They were a thing in the 10Mbps era when electronics was a lot more expensive, but that was ages ago.Maybe it is a good idea to use a commercially available switch and then open the housing and just use the PCB. I also have vague memories of very small USB hubs that just have solder pads and are meant to permanently put into 3rd-party equipment. (I think I saw them on Hackaday / Tindie) Maybe something similar exists for Ethernet.

author: magic
author_rank: Super Contributor
timestamp: January 09, 2024, 07:12:45 pm
content: A switch does work at Ethernet layer and does not care about IP addresses and protocols like DHCP...Some advanced switch ICs can do other things, for example VLANs or even layering violation like IPv4 NAT offload, but such functionality must be specifically enabled and configured by out-of-band means (i.e. non-Ethernet pins on the chip).A physical box which contains a switch may also contain other things, for example a simple Ethernet and IP host capable of monitoring and configuring the switch, or a router. These are logically separate components and usually separate chips.A switch IC may or may not have some dedicated ports meant primarily to connect with such on-board hosts (rather than external RJ45 jacks).

author: mariush
author_rank: Super Contributor
timestamp: January 09, 2024, 07:28:30 pm
content: Could you live with just 100 mbps?LCSC has cheap 5 port switch chips like RTL8305 :https://www.lcsc.com/product-detail/Ethernet-ICs_Realtek-Semicon-RTL8305NB-VB-CG_C3010343.html1.2$ for one, 0.75$ for 100 ..some notes about the eeprom for optional configuration :https://github.com/tomazas/RTL8XXX-Switch/tree/masterand some application note for one of the switch chips :https://www.yumpu.com/en/document/read/50509937/realtek-rtl8305sb-port-4-application-noteThere's also 5+2 gigabit switch RTL8367s for around 2.5$ :https://www.lcsc.com/product-detail/Ethernet-ICs_Realtek-Semicon-RTL8367S-CG_C2760849.html.. and a 8 port gigabit switch IC RTL8370 for $4.1 a piece (and not much discount in higher volume) :https://www.lcsc.com/product-detail/Ethernet-ICs_Realtek-Semicon-RTL8370N-VB-CG_C2803243.html

author: palpurul
author_rank: Regular Contributor
timestamp: January 10, 2024, 03:46:42 pm
content: Quote from: mariush on January 09, 2024, 07:28:30 pmYep, I think I've seen those chips in some of the teardowns. They are quite common for switch design I think. I definitely don't need gigabit, 100Mbit is fine to me.Thanks for the info!