i've upgraded the Ethernet controller applet for #GlasgowInterfaceExplorer
this is the main loop of the applet working in bridge mode (acting as a network card for your PC). no weird optimizations, no hacks, just a loop that forwards packets in normal boring Python
on a 100BASE-T link, i get ~95.5 Mbps [saturated link] of upload bandwidth and ~70 Mbps of download bandwidth before packet loss starts
how cool is this?
![async def run(self, args):
if args.operation == "bridge":
os_iface = OSNetworkInterface(args.interface)
async def forward_rx():
async for packet in self.eth_iface.iter_recv():
if len(packet) >= 14: # must be at least ETH_HLEN, or we'll get EINVAL on Linux
await os_iface.send([packet])
async def forward_tx():
while True:
for packet in await os_iface.recv():
if not await self.eth_iface.send(packet):
break
async with asyncio.TaskGroup() as group:
group.create_task(forward_rx())
group.create_task(forward_tx())](https://files.mastodon.social/media_attachments/files/114/640/314/746/449/561/original/8f1057c4cd6ca8f6.png)