Pure-Go SoC & L2 switch emulator for Realtek RTL8372 / RTL8372N / RTL8373 2.5GbE/10GbE switches.
Boot unmodified vendor DW8051 firmware (HRUI, Horaco, Sodola, Hasivo, Sirivision) on your laptop in ~2 seconds — serial console, Web UI, L2 switching fabric, UDP port tunnels, and Wireshark pcapng capture included. Zero root, zero TAP devices, zero hardware.
firmware.bin (SPI NOR dump or web-upgrade .bin)
│
▼
┌──────────────────────────────────────────────────────────────────┐
│ DW8051 CPU (32-bank Keil C51) ◄────► SPI NOR Flash + OTP │
│ │ │ │
│ UART Switchcore ASIC + L2 Forwarding Engine │
│ │ (VLAN, STP, LACP, IGMP, RLDP, I2C PoE) │
└────────┼──────────────────────┬───────────────────┬──────────────┘
▼ ▼ ▼
stdin / stdout gVisor netstack UDP port tunnels
(serial CLI) http://127.0.0.1:8080 & per-port pcapng
Grab a prebuilt binary from Releases, install via Go, or build from source:
git clone https://github.com/brennoo/rtl51.git && cd rtl51
go build ./cmd/rtl51
./rtl51 boot ./firmwares/SWTG118AS-v2.0.binOr install just the CLI:
go install github.com/brennoo/rtl51/cmd/rtl51@latestOnce booted:
- Serial console is attached to
stdin/stdout(Ctrl+Cto exit; password shown byrtl51 inspect). - Web UI is forwarded to
http://127.0.0.1:8080(default credentials:admin/admin). - Read-only by default: input images are never modified; pass
-write-flash out.binto persist NVRAM/config changes on exit.
# Inspect image layout, chip ID, checksums, OTP algo, default IP/MAC, and serial password
./rtl51 inspect ./firmwares/SWTG118AS-v2.0.bin
# Verify or recalculate 0x12345678 runtime header & payload checksums
./rtl51 checksum ./firmwares/HRRF_V200.2.5_ZX310S-4T2XH_0422.bin
./rtl51 checksum -o patched.bin modified.bin
# Generate SPI Flash Security Register (0x48) payload for a flash chip UID
./rtl51 otp -a v1 10093f3010093f30
./rtl51 otp -a 1 e6632c25a344b330 # v2-algo1 (-a 2 for v2-algo2, -a sirivision)Attach front-panel ports to UDP datagram tunnels (GNS3/QEMU NIO_UDP wire format — 1 datagram = 1 raw Ethernet frame, works with Scapy or another rtl51 instance) and dump every port + the 0x8899-tagged CPU interface (cpu9) to pcapng:
# Cable port 2 on Switch A directly to port 2 on Switch B and capture Switch A's fabric
./rtl51 boot -http 127.0.0.1:8081 -pcap switch-a.pcapng \
-port 2=127.0.0.1:10001,peer=127.0.0.1:10002 ./firmwares/SWTG118AS-v2.0.bin
./rtl51 boot -http 127.0.0.1:8082 \
-port 2=127.0.0.1:10002,peer=127.0.0.1:10001 ./firmwares/SWTG018AS-A-v2.0.1.binCustom board layouts and management port selection are supported via -portmap 4,5,6,7,8,3 and -mgmt-port <N>.
pkg/mcs51— Machine-cycle-accurate DW8051 core, 32-bank Keil C51 code banking (PSBANK/0xBBhardware LIFO),MOV Direct, Directoperand ordering, Timers 0/1/2, and 2-levelIPinterrupt preemption.pkg/rtl837x— Copy-on-write SPI NOR flash with automatic0x48Security Register calibration (v1,v2-algo1,v2-algo2,sirivision); 4096-entry VLAN & L2 tables with learning/aging; L2 forwarding engine (802.1Q, STP/RSTP, LACP/LAG, IGMP/MLD snooping, RLDP loop detection, port isolation); Clause 45 MDIO/SerDes; 4-port I2C PoE PSE telemetry; CPU NIC DMA (0x8899tags); per-portpcapngwriter.pkg/netbridge— In-process gVisornetstackauto-learning the switch IP (across static & DHCP changes), HTTP proxy for the Web UI, and UDP port tunnels.pkg/firmware— Content-based image inspector, checksum patcher, and standalone web-upgrade.binunpacker (synthesizes a 2 MB flash image + interrupt vector stubs in memory so update files boot without a SPI dump).
Seven unmodified vendor images (512 KB unmanaged, 2 MB/4 MB full SPI dumps, and standalone web-upgrade .bin files are included in ./firmwares for quick boot and end-to-end testing — see firmwares/README.md for the full list and provenance notice.
go test -race ./...The test suite boots the reference firmware images end-to-end and verifies Web UI endpoints, NVRAM/IP changes, VLANs, STP, LACP, IGMP, RLDP, UDP port tunnels, and pcapng output.
rtl51source code is released under the MIT License.- Firmware binaries in
./firmwaresare unmodified third-party vendor dumps and web-upgrade images downloaded from the internet. They are not my work and are not covered by the MIT license — all rights belong to their respective copyright holders, and they are kept solely for emulation testing and research. - Credits: Builds on foundational RTL837x firmware, flash layout, and OTP (
encuid/encuid2) reverse-engineering work from up-n-atom/SWTG118AS and the ServeTheHome community, as well as board port profiles fromlogicog/RTLPlayground(MIT).