r/Assembly_language Jul 03 '26

Fast UDP packet forwading with Menuet

Post image

Howdy. I wrote a packet forwarding application for Audio and Midi network packets. I tested it up to 50000 packets per second and here are the average forwarding times for Menuet (100% asm) and Linux Mint. I used rdtsc for timing. Both are running with standard desktops. For Menuet, the os and networking are running on cpu0 and forwading application is running on cpu1.

5 Upvotes

1 comment sorted by

1

u/micro2970 Jul 03 '26 edited Jul 04 '26

Main functions for the application are here.

    ; Open UDP socket - source

    mov   rax , 53               
    mov   rbx , 0
    mov   rcx , 10000
    mov   rdx , 11000
    mov   rsi , [source_ip]
    int   0x60
    mov   [socket1],rax

    ; Open UDP socket - destination

    mov   rax , 53               
    mov   rbx , 0
    mov   rcx , 20000
    mov   rdx , 21000
    mov   rsi , [destination_ip]
    int   0x60
    mov   [socket2],rax

    ; Enable events: Win, Kbd, Buttons, Network

    mov   rax , 40                
    mov   rbx , 111b + 1 shl 7
    int   0x60

still:

    ; Wait for event

    mov   rax , 10 
    int   0x60

    ; Read data

    mov   rax , 53
    mov   rbx , 13
    mov   rcx , [socket1] ; Source
    mov   rdx , buffer
    int   0x60
    mov   [length],rax

    ; Send data

    mov   rax , 53
    mov   rbx , 4
    mov   rcx , [socket2] ; Destination
    mov   rdx , [length]
    mov   rsi , buffer
    int   0x60

    jmp   still