8 ms·
Show HN: I made an Ethernet transceiver from logic gates
- systems_glitch 4y agoNice work! Now do thicknet :P
- bogomipz 4y agoWow, this is fantastic! I had a couple of questions. The author states: >"According to the 10BASE-T spec, each frame starts with a fixed synchronization sequence of 64 bits, first 62 of which are alternating ones and zeroes and the last two are ones." I believe the intention of the "preamble" is to provide clocking and synchronization for the circuit so that it knows where to find the start frame delimiter and subsequent fields. Is that correct? My other question is at what point does the circuit drop frames that are not intended for it? Does that happen in layer 1 or layer 2? I realize this happens less in modern switched Ethernet networks but it is still possible for a host to get an Ethernet frame for where the destination MAC address does not match any of those burned-in addresses on the Ethernet adapter. Does the transceiver always read the entire Ethernet frame even when the destination MAC address field it reads is incorrect? The maximum Ethernet frame size is 1518 bytes which seems like a lot of data read if the MAC address is not valid for the host.
- ynoxinul 4y agoThe preamble is intended for synchronization, the last two consequtive ones indicate the start of the data. My circuit doesn't drop any frames, it simply converts serial Ethernet signal to SPI. FCS and MAC checking is done in software after receiving the whole frame. You absolutely can get frames not addressed to you. Wireshark lets you do that. I debugged my adapter this way: I connected it to a dumb switch together with my computer and ran Wireshark on the computer which captured all frames regardless of their intended destination. On Linux you can even disable FCS checking and receive all rubbish from the wire.
- bogomipz 4y agoThanks, I had another question after a second reading of your post: >"The first bit of an Ethernet frame is always one, which means there might or might not be an extra edge in the beginning depending on the idle state of the amplifier. This extra edge, if it comes, needs to be filtered out." Practically speaking what is the cause of the "extra" edge here? Would it be that the last bit of the FCS from the previous frame caused it to be a 1 and then the transceiver is immediately getting another edge from a preamble on a new Ethernet frame? Or am I confusing bits and edges?
- ynoxinul 4y agoA manchester-encoded bit 1 is a low-to-high transition: there should be "low" on the line which will change to "high". Before the "low" the line was idle (zero voltage difference), this state is interpreted by the differential amplifier as "high", so it's "high-low-high" at the beginning, but we are interested in the "low-high" edge and not in the "high-low" one.
- zamadatix 4y agoImagine you had 2 transceivers you wanted to bridge - if the transceiver dropped all unicast MACs but its own indiscriminately then it would not function properly. There is also a litany of other features that would not want this kind of offload always running (general MAC spoofing, packet capturing for debug/troubleshooting purposes, VMs, some IP redundancy protocols that keep the virtual IP's MAC consistent after failover, and the like). Offloads such as this or other more advanced ones are implemented as optional hardware features (if at all) controlled by upstream signaling. This is usually a driver signaling things over a PCIe bus on modern systems but it can be anything including just "upstream logic gates". That way if it's a normal client-only PC not running e.g. Wireshark or VMs the CPU doesn't have to be interrupted for the types of traffic you mention but the other use cases can still work too.
- bogomipz 4y agoThanks, that makes perfect sense about things like VRRP and proxy arp, indeed they wouldn't work if the transceiver filtered on the destination MAC field of the Ethernet frame. I'm guessing this is exactly why this stuff is handled at L2 and in the kernel module for the NIC? I didn't understand your first example though: >"Imagine you had 2 transceivers you wanted to bridge - if the transceiver dropped all unicast MACs but its own indiscriminately then it would not function properly" I'm not understanding why bridging makes a difference. In the case of a bridge a host would send out a broadcast i.e a frame with destination MAC ff:ff:ff:ff:ff:ff which is valid for all Ethernet adapters, this is similar whether it's a switched or bridge network no? Maybe I'm missing something obvious? >"Offloads such as this or other more advanced ones are implemented as optional hardware features (if at all) controlled by upstream signaling." Which offloads are you referring to here? Just general TCP offload engine stuff? How does that relate?
- zamadatix 4y ago> Thanks Thank you! I love talking about bits and bytes on the network wire and it feels like I get to do it less and less the farther I get into my career... funny how that works. At least I haven't been moved into management yet! > I'm guessing this is exactly why this stuff is handled at L2 and in the kernel module for the NIC? Yep, generally the OS driver has a backup version of logic to handle everything beyond "packet receive" and "packet send" for exactly these kinds of reasons. On Linux you or any program with the rights can disable NIC filtering offloads by setting an interface to promiscuous e.g. "ip link set eth1 promisc on" and the packets all get punted to the CPU like it was a base level dumb NIC. Pulling an example early here is a patch making sure the broadcom driver for the NIC in the Raspberry Pi actually listens to this declaration and disables the ARP & ND filtering offloads https://patchwork.kernel.org/project/linux-wireless/patch/1510148197-17851-3-git-send-email-arend.vanspriel@broadcom.com/ https://patchwork.kernel.org/project/linux-wireless/patch/15... > I'm not understanding why bridging makes a difference. In the case of a bridge a host would send out a broadcast i.e a frame with destination MAC ff:ff:ff:ff:ff:ff which is valid for all Ethernet adapters, this is similar whether it's a switched or bridge network no? Maybe I'm missing something obvious? You're only thinking about broadcast MAC destinations but bridges also handle unicast MAC destinations. E.g. imagine NIC 1 (local station assigned MAC 0a:0a:0a:0a:0a:0a) and NIC 2 (local station assigned MAC 0e:0e:0e:0e:0e:0e) are bridged and no state has been learned yet. Off NIC 1 an unknown unicast MAC flood from source MAC 02:02:02:02:02:02 to destination MAC 04:04:04:04:04:04 is received. If the NIC just drops the frame when received on NIC 1 because the destination unicast MAC is 04:04:04:04:04:04 instead of 0a:0a:0a:0a:0a:0a the bridge is non-functional. Letting the broadcasts through is only half the story of bridging. Ideally the device (either NIC offload or upstream OS/further hardware logic) does some MAC learning as the above conversation goes on so things don't always remain unknown flooding past the first exchange but technically just forwarding the frame out all interfaces in the bridge group is valid too (just extremely inefficient). It's also worth noting usually in the real world higher layer discovery (like 2 IP addresses ARPing for each-other) triggers the unicast MAC learning with the ARP broadcast and unicast response but that's just a nicety of how things typically work, it's not always the case with any conversation between 2 Ethernet endpoints. Just knowing the MACs beforehand and not sending any broadcast is technically just as valid a way to do things at the Ethernet layer, albeit extremely rare in the world of IP. > Which offloads are you referring to here? Just general TCP offload engine stuff? How does that relate? More directly things like ARP and WoL offload so the CPU doesn't get interrupts every time some device in the subnet sends an ARP/WoL broadcast, particularly when it ends up being a broadcast intended for a MAC not owned by the local station. Both of those offloads are pretty common in consumer stuff too which is nice and that link I sent above shows a code change related to it for the Raspberry Pi adapter (albeit the Wi-Fi one, which has a whole different world of filters at the Wi-Fi layer before we even get to Ethernet filtering). TCP offloading and whatnot can be examples as well but the level of abstraction (and varying levels of "what exactly is offloaded") makes it more difficult to discuss than the above examples which can stay within the Ethernet layer (as far as forwarding goes, the payloads may have information beyond that to deal with once delivered). That said I'll leave TCP offload with "the NIC may still need to know the VLAN tag and p-bit to put in the Ethernet header, as well as get the destination MAC of the next hop which could be a gateway or the destination client itself" but skip the examples or further corner cases/combinations since it can get hairy very fast and that already gives enough of an idea about Ethernet bits getting set by the offload too :).
- rasz 4y agoSync pulses are for PLL to sync with transmitter clock. Floppy sectors also start with a train of 64 sync pulses https://info-coach.fr/atari/hardware/FD-Hard.php#FDC_PLL https://info-coach.fr/atari/hardware/FD-Hard.php#FDC_PLL
- verisimi 4y agoHow is this fairly nerdy piece, that no one has commented on, top of hn? What am I missing?
- db48x 4y agoThe very best things speak for themselves, and need no amplifying comments.
- deleted 4y ago[deleted]
- tintedfireglass 4y agothe HN algorithm is a bigger mystery than the universe itself
- revskill 4y agoNo, i think most of its part is manual update database to set the rank of a post.
- stavros 4y agoIt's super cool.
- Myrmornis 4y agoThat it's impressive.
- omeze 4y agoIts been way too long since I touched a breadboard, but what software was the post using to simulate this? I would expect that the requirement for ~ns precision (microwave frequencies) would involve a lot more tedious calculations for designing the circuit.
- ynoxinul 4y agoI used Falstad curcuit simulator (https://www.falstad.com/circuit/circuitjs.html https://www.falstad.com/circuit/circuitjs.html) to try out some subcircuits (monostable, for example) and then tried them out on a breadboard.
- Evidlo 4y agoA mistake: you refer to C9 in the monostable section, but it should be C5
- ynoxinul 4y agoThanks, fixed it.
- exmadscientist 4y agoAnother mistake that doesn't deserve a top-level comment: the unit abbreviation for "second" is "s", not "S" (that one's the siemens = inverse ohm = former mho, which was a way better unit than the siemens, but that's another discussion...). Thus, "ms" and "ns" rather than "mS" and "nS". This may sound incredibly pedantic, and it is, but it's also one of the tests for attention to detail that I use when interviewing and evaluating an EE candidate, so, y'know, maybe worth learning to get right. Or not, life's short and building stuff out of discretes is more fun. Your call!
- ynoxinul 4y agoThank you, fixed.
- unwind 4y agoHadn't heard of "mho" for conductivity, is that from when Bourne worked with electronics? :) I would oppose a unit that starts with a prefix symbol (m=milli=0.001) on principle.
- exmadscientist 4y ago> I would oppose a unit that starts with a prefix symbol (m=milli=0.001) on principle. The unit name isn't usually important. I think you're talking about the symbol? That's "℧", which has its own problems. But at least it's in Unicode now! Altogether I think the "℧" caused much less trouble than the "S" has. "S" is just stupid... as evidenced by this whole subthread. And, yes, I have read datasheets wrong because of this. Thanks, 14th CGPM!
- deleted 4y ago
- userbinator 4y agoHowever, some hardware I have sometimes produced longer preambles How long were they, and did they happen to coincide with short frames? It's been a long time since I've worked with 10M Ethernet PHY but I vaguely remember some non-standard implementations would lengthen the preamble instead of padding the "tail" of the frame.
- oakwhiz 4y agoIt's possible that some PLLs might fail to lock in within a normal amount of time to acquire the full preamble. In which case varying the length of the preamble slightly shouldn't negatively affect receivers that are well designed to tolerate unusual conditions.
- ynoxinul 4y agoThe preambles were longer by a few bits (even less than 8). I didn't check which frames excatly caused this, but it happened only with one old 10 MBit switch.
- mgsouth 4y agoCool! Have you submitted to Hackaday?
- 55555 4y agoWow the tech talent in Tokelau is insane!
- charcircuit 4y agoWhat is the benefit of using all of these different components over using an FPGA?
- ynoxinul 4y agoIt's a fun project. I feel like building stuff with logic gates.
- meltedcapacitor 4y agoIt is hardware poetry. (What is the benefit of rhymes, meter, etc over using prose?)
- PostOnce 4y agoIt's worth your while to buy another domain. You could keep the .tk running. Some sites shadowban .tk, Reddit probably still does. Search engines probably downrank it. That's because it's free and has been used for a lot of spammy stuff. This makes it harder for people to share and harder for people to find. That might just put a damper on your hobby, but it might also mean you won't get random emails about jobs you might want. (If you're interested in that.) I only mention it because I learned that the hard way many years ago.
- moffkalast 4y agoIs it worth it though? Renewing a domain is yet another bottomless pit you throw money into, along with server hosting. For a site without ads or other revenue it's just more expense.
- 1kurac 4y agoThe thing with TK is, it costs nothing upfront, but the internet is bursting with countless reports that if your site eventually becomes popular, TK domain admins might outright snatch it from you for their own ads, without the possibility of seeking retribution as it's all in their TOS ... https://getfreedomain.name/domain/tk/ https://getfreedomain.name/domain/tk/
- actionfromafar 4y agoStatic hosting can be found free on sites like gatsby.
- moffkalast 4y agoOk yeah now that I think about it there are ways to host for free, github pages also comes to mind. Not exactly elegant solutions though. Makes the domain expense even worse in that respect.
- layer8 4y agoStandard domains (com/net/org) are super cheap, around $1 per month.
- psychphysic 4y agoI love this stuff, well over my head but amazing read and so grateful for the scope captures!
- testermelon 4y agoThis is sick. I also read their post about the making a discrete computer and didn’t expect them to be also writing a compiler from scratch. Something I’ve only been dreaming about.
- mikewarot 4y agoSo all I need are link pulses to fake the other end of an Ethernet connection to keep it alive? This makes building a data diode much simpler than I thought it needed to be. Thanks!
- ynoxinul 4y agoYes, but this is only the case with 10BASE-T. Modern standards use more complicated Fast Link Pulses.
- kevin_thibedeau 4y agoAlso applies to 100Base-T which is still a usable solution for basic networking.
- birdyrooster 4y agoI love these people bc they do all the esoteric stuff so that I don’t have to.
- greenyoda 4y agoThis is a wonderful project! I'm old enough to remember the days when Ethernet adapters for commercial computers were made of individual logic gates. The Ethernet adapter in the VAX 11/750 I used in the early 80's was two large Unibus boards full of TTL logic: http://gunkies.org/wiki/Digital_Ethernet_UNIBUS_Network_Adapter http://gunkies.org/wiki/Digital_Ethernet_UNIBUS_Network_Adap...
- aswanson 4y agoThat is crazy, the amount of space a network adapter took up.
- db48x 4y agoAnd there were a few more boards for the disk controller, and another couple for the display controller…
- greenyoda 4y agoNot to mention all the boards that the CPUs and RAM took up. Here's a nice photo of the insides of a VAX 11/780 - if you enlarge it all the way you can see the annotations showing which boards do what: https://upload.wikimedia.org/wikipedia/commons/e/ec/SPEC-1_VAX_05.jpg https://upload.wikimedia.org/wikipedia/commons/e/ec/SPEC-1_V... Note that those 16 huge memory boards each held 256K (kilobytes!) for a total of 4M of RAM. Photo with people to show size of cabinets: https://photovault.com/363660 https://photovault.com/363660
- db48x 4y agoIt’s always surprising to look back at these things, because it hardly seems like it would be economical to build and deliver such a huge monstrosity.
- aswanson 4y agoWhen the alternative is nothing or paying a lot of money for something you need to make a lot of money, people will pay a lot of money. It still crazy though. The 80s don't seem that long ago.
- amelius 4y agoFrom Wikipedia: > Manchester code was used in early Ethernet physical layer standards So, not in later standards?
- detaro 4y agoLater standards use more efficient codes that map longer symbols to DC-free codes, and thus are more bandwidth-efficient. (8b/10b, 64b/66b codes, where manchester is basically a 1b/2b code)
- Aromasin 4y agoInteresting timing for this post - I'm studying this for a new job at the moment and building myself my own little Wikipedia in order to learn it. 10BASE uses Manchester Encoding, 100BASE uses Non-Return-to-Zero, Invert-on-one (NRZI) encoding and Multiple Level Transition (MLT-3) with 4B5B translation, 1000BASE uses 8b/10b Encoding (8 bits for data, 2 for ECC). More recent speeds all tend to use PAM4 encoding, meaning there's 4 voltage levels instead of 2! There's a great article on it here: https://blog.samtec.com/post/understanding-nrz-and-pam4-signaling/ https://blog.samtec.com/post/understanding-nrz-and-pam4-sign...
- rasz 4y agoWanna read something bonkers? DDR6 memory coming in ~2025 is supposed to use PAM4 :o
- alexnewman 4y agoclassic hackernews. We need more of these
- jtlienwis 4y agoLook on Hackaday for "Why do you need to use decoupling caps". I am not seeing any talk of decoupling caps in any of this persons writeups. Maybe they are there and I am just not seeing them. It used to be when designing with LS ttl you needed one per chip to make sure switching noise did not get onto your power supply rails. Otherwise, a great project for learning.
- ynoxinul 4y agoDo you think they are worth mentioning? My post isn't a tutorial.
- bogantech 4y agoThe decoupling caps are there in the schematics shown alongside the symbols for the IC power inputs which is a common way of doing things. IDK why something as fundamental as decoupling caps should be mentioned here at all though, anyone sufficiently knowledgeable to make use of this information would know that they're required already.
- 0xmarcin 4y agoWhat a mervell of retro-computing. I think the author should definitely contact Ben Eater, as this is an excellent material for the next video. Aside from this, Arduino shields for Ethernet are available for quite some time, but they often contain the more advanced chip than the atmega328p itself. Here OTOH the author builds from the ground up. Simply amazing! That being said, I think most of the ppl that are serious about their arduino networking will use CAN as their network of choice (https://en.wikipedia.org/wiki/CAN_bus https://en.wikipedia.org/wiki/CAN_bus).
- bjt2n3904 4y agoOh wow. I had thought this was, "I simulated it in a high level HDL and synthesized it to gates". No, this is... I built it with physical chips. Brilliant build and write-up! Edit: This is beautiful for a second reason... The lack of regard for doing things "correctly". The ugly clock circuit is horrifically unreliable... But just reliable enough for it to still work. It reminds me of Muntzing. https://en.wikipedia.org/wiki/Muntzing https://en.wikipedia.org/wiki/Muntzing