When Raw Network Sockets Aren’t Raw: Raw Sockets In MacOS And Linux

Raw network sockets are a curious beasts, as unless you have a strong urge to implement your own low-level network protocol, it’s a topic that is probably best left to the (well-paid) experts. That said, you can totally use raw sockets in virtually every operating system, but one should be aware of a few things, the lack of portability being one of them. This is what tripped [Swagnik] up while trying to write a low-level network ping (ICMP) utility, by reading the Linux socket documentation while testing on MacOS. It’s all BSD-style sockets, after all, right?

As it turns out, the network stacks in Linux and MacOS have some subtle differences, which become apparent when you read the friendly manuals. For Linux, the raw(7) man entry for IPv4 sockets make it clear that the IP_HDRINCL socket option is default by default for IPPROTO_RAW sockets. This is different from MacOS, which is effectively FreeBSD with glossy makeup. Like FreeBSD, the MacOS man page makes it clear that the IP_HDRINCL option is not set by default.

So that’s easy, right? Just fire off a setsockopt() call on the raw socket and that’s done. Not quite. The Linux man page notes that it cannot receive all IP protocols, while the FreeBSD/MacOS version makes no such exceptions. There is also the issue of endianness, which is where [Swagnik]’s blog post seems to err. The claim is that on MacOS the received IPv4 raw socket header is in host (little endian) order, while the documentation clearly notes that these are in network (big endian) order, which the blog post also shows.

Where things get really fun is when moving from IPv4 raw sockets to IPv6 raw sockets, as [Michael F. Schönitzer] covered for Linux back in 2018 already. IPv6 raw sockets drop IP_HDRINCL and requires a whole different approach. The endianness also changes, as IPv6 raw sockets under Linux must send and will receive data in network byte order, putting it in line with FreeBSD raw sockets.

A Really Low Level Guide To Doing Ethernet On An FPGA

With so much of our day-to-day networking done wirelessly these days, it can be easy to forget about Ethernet. But it’s a useful standard and can be a great way to add a reliable high-throughput network link to your projects. To that end, [Robert Feranec] and [Stacy Rieck] whipped up a tutorial on how to work with Ethernet on FPGAs. 

As [Robert] explains, “many people would like to transfer data from FPGA boards to somewhere else.” That basically sums up why you might be interested in doing this. The duo spend over an hour stepping through doing Ethernet at a very low level, without using pre-existing IP blocks to make it easier. The video explains the basic architecture right down to the physical pins on the device and what they do, all the way up to the logic blocks inside the device that do all the protocol work.

If you just want to get data off an embedded project, you can always pull in some existing libraries to do the job. But if you want to really understand Ethernet, this is a great place to start. There’s no better way to learn than doing it yourself. Files are on GitHub for the curious. Continue reading “A Really Low Level Guide To Doing Ethernet On An FPGA”

So What’s All This HaLow Long-Range WiFi About Then?

We’re all used to wireless networking, but if there’s one thing the ubiquitous WiFi on 2.4 or 5 GHz lacks, it’s range. Inside buildings, it will be stopped in its tracks by anything more than a mediocre wall, and outside, it can be difficult to connect at any useful rate more than a few tens of metres away without resorting to directional antennas and hope. Technologies such as LoRa provide a much longer range at the expense of minuscule bandwidth, but beyond that, there has been little joy. As [Andreas Spiess] points out in a recent video though, this is about to change, as devices using the so-called HaLow or IEEE 802.11ah protocol are starting to edge into the realm of affordability.

Perhaps surprisingly, he finds the 5 GHz variant to be best over a 1km test with a far higher bandwidth. However, we’d say that his use of directional antennas is something of a cheat. Where it does come into its own in his tests, though, is through masonry, with far better penetration across floors of a building. We think that this will translate to better outdoor performance when the line of sight is obstructed.

There’s one more thing he brings to our attention, which seasoned users of LoRA may already be aware of. These lower frequency allocations are different between the USA and Europe, so should you order one for yourself, it would make sense to ensure you have the appropriate model for your continent. Otherwise, we look forward to more HaLow devices appearing and the price falling even further because we think this will lead to some good work in future projects.

Continue reading “So What’s All This HaLow Long-Range WiFi About Then?”

How DEC’s LANBridge 100 Gave Ethernet A Fighting Chance

Alan Kirby (left) and Mark Kempf with the LANBridge 100, serial number 0001. (Credit: Alan Kirby)
Alan Kirby (left) and Mark Kempf with the LANBridge 100, serial number 0001. (Credit: Alan Kirby)

When Ethernet was originally envisioned, it would use a common, shared medium (the ‘Ether’ part), with transmitting and collision resolution handled by the carrier sense multiple access with collision detection (CSMA/CD) method. While effective and cheap, this limited Ethernet to a 1.5 km cable run and 10 Mb/s transfer rate. As [Alan Kirby] worked at Digital Equipment Corp. (DEC) in the 1980s and 1990s, he saw how competing network technologies including Fiber Distributed Data Interface (FDDI) – that DEC also worked on – threatened to extinguish Ethernet despite these alternatives being more expensive. The solution here would be store-and-forward switching, [Alan] figured.

After teaming up with Mark Kempf, both engineers managed to convince DEC management to give them a chance to develop such a switch for Ethernet, which turned into the LANBridge 100. As a so-called ‘learning bridge’, it operated on Layer 2 of the network stack, learning the MAC addresses of the connected systems and forwarding only those packets that were relevant for the other network. This instantly prevented collisions between thus connected networks, allowed for long (fiber) runs between bridges and would be the beginning of the transformation of Ethernet as a shared medium (like WiFi today) into a star topology network, with each connected system getting its very own Ethernet cable to a dedicated switch port.

Replacement PCB Replicates Early 80s Modem

It’s certainly been a few decades, but plenty of us remember a time before widespread access to broadband internet, when connections were generally made over phone lines using acoustic modems. In the 90s these could connect you to AOL and Napster well enough, but in the early 80s the speeds were barely enough to read text as it loaded. A company called Hayes set out to change this with some of the first useful, widely-available modems for the PCs at the time. While they couldn’t keep up with the changing times there’s still a retro community that has these antiques, and to modernize it a bit this drop-in replacement for the PCBs replicates these old modems almost exactly.

The new PCB is equipped with everything needed to get a retro computer online again, including all the ports to connect a computer without any further modifications. It houses a few modern upgrades beyond its on-board processors, though. Rather than needing an actual acoustic coupled phone, this one has an ESP32 which gives it wireless capability. But the replacement PCB maintains the look and feel of the original hardware by replicating the red status LEDs at the front, fitting into the original Hayes cases with no modifications needed at all, and even includes a small speaker through which it can replicate the various tones, handshakes, and other audio cues that those of us nostalgic for this new online era remember quite well.

For those looking for a retro feel without the hassle of getting antique networking equipment functional again, this type of upgrade that preserves the essence of the original hardware is an excellent way of keeping retro computers functional on modern networking equipment. But if you absolutely must get the networking equipment exactly right down to the last patch cable, you might end up having to build your own ISP from scratch.

Continue reading “Replacement PCB Replicates Early 80s Modem”

Australia’s Second Largest Telco Went Dark, And Chaos Reigned

Engineers tend to worry about uptime, whether it’s at a corporate server farm or just our own little hobby servers at home. Every now and then, something will go wrong and take a box offline, which requires a little human intervention to fix. Ideally, you’ll still have a command link that stays up so you can fix the problem. Lose that, though, and you’re in a whole lick of trouble.

That’s precisely what happened to Australia’s second largest telecommunications provider earlier this month. Systems went down, millions lost connectivity, and company techs were left scrambling to put the pieces back together. Let’s dive in and explore what happened on Optus’s most embarrassing day in recent memory.

Continue reading “Australia’s Second Largest Telco Went Dark, And Chaos Reigned”

The WebStick Is A Small, Cheap NAS

The ESP8266 was one of the first chips that provided wireless functionality at a cost low enough to be widely popular for small microcontroller projects. This project uses one to provide rapid, small, and inexpensive network-attached storage (NAS) capabilities wherever you happen to go.

With an ESP12F board at the heart to provide network connectivity, the small device also hosts a micro SD card slot and a USB-A port to provide power and programming capabilities for the device. It’s Arduino-compatible, and creator [tobychui] has provided the firmware source code necessary to bring it up on your network and start serving up files. Originally intended for people to host web services without experience setting up all of the tools needed for it, there’s services for storing and streaming music and video over the network as well.

While it includes a lot more functionality than is typically included on a NAS, [tobychui] notes that with a library, something like WebDAV could be added to provide more traditional NAS capabilities. As it stands, though, having networked storage with web hosting capabilities on a PCB with a total cost of around $5 is not something to shy away from. If you’re looking for something a little more powerful for your home network, take a look at this ARM-based NAS instead.