nanog mailing list archives
Re: Speaking of DNS server software...
From: Tom Beecher via NANOG <nanog () lists nanog org>
Date: Sun, 10 Aug 2025 22:04:18 -0400
For Python to access a DNS packet, the programmer must pack and unpack an array of bytes using complex software of their own devising. You can't just tell Python, "This is the complex data structure these bytes contain, let me access the data without unpacking it."
Yes you can. https://docs.python.org/3/library/socket.html With these data structures you can:
header = (struct ipv4_header*) byte_buffer;
printf ("Don't fragment bit is: %s\n",
header->dont_fragment?"set":"unset");
Not only is that code simple, the amount of work the CPU has to do to
execute that code is trivial.
df_status = s.getsockopt(socket.IPPROTO_IP, socket.IP_DONTFRAG)
print(f"Don't Fragment flag status: {df_status}")
On Sun, Aug 10, 2025 at 9:31 PM William Herrin via NANOG <
nanog () lists nanog org> wrote:
On Sun, Aug 10, 2025 at 5:56 PM John Levine <johnl () iecc com> wrote:It appears that William Herrin via NANOG <nanog () lists nanog org> said:Python doesn't work this way. Its memory management is abstracted away from the programmer and the programmer does not control its precise structure. For Python to access a DNS packet, the programmer must pack and unpack an array of bytes using complex software of their own devising. You can't just tell Python, "This is the complex data structure these bytes contain, let me access the data without unpacking it."The python struct module is pretty fast, since it's written in C.Hi John, That's the difference. In Python you have a complex software library which can shuttle data back and forth between Python's internal data management process and an arbitrary byte-oriented data structure. In C, that arbitrary data structure is a first class citizen in the core language and no translation is needed. You could pull apart a DNS packet in a Bash shell script if you really wanted to. The code complexity would be out of sight and it would run orders of magnitude slower than Python or C, but it can be done. Just because a thing can be done doesn't mean the language is an optimal choice for the task. Regards, Bill Herrin -- William Herrin bill () herrin us https://bill.herrin.us/ _______________________________________________ NANOG mailing list https://lists.nanog.org/archives/list/nanog () lists nanog org/message/LVNUTOYAVDB5AEQSPNQI22YJCLYUBRFJ/
_______________________________________________ NANOG mailing list https://lists.nanog.org/archives/list/nanog () lists nanog org/message/AKI6PGZI5DRVDNQQ2TGFD74MEEX7BHNR/
Current thread:
- Re: Speaking of DNS server software..., (continued)
- Re: Speaking of DNS server software... Chris Woodfield via NANOG (Aug 10)
- Re: Speaking of DNS server software... Michael Crute via NANOG (Aug 10)
- Re: Speaking of DNS server software... Ryan Kozak via NANOG (Aug 10)
- Re: Speaking of DNS server software... Mike Crute via NANOG (Aug 10)
- Re: Speaking of DNS server software... Ryan Kozak via NANOG (Aug 11)
- Re: Speaking of DNS server software... Etienne-Victor Depasquale via NANOG (Aug 10)
- Re: Speaking of DNS server software... William Herrin via NANOG (Aug 10)
- Re: Speaking of DNS server software... John Levine via NANOG (Aug 10)
- Re: Speaking of DNS server software... Ryan Hamel via NANOG (Aug 10)
- Re: Speaking of DNS server software... William Herrin via NANOG (Aug 10)
- Re: Speaking of DNS server software... Tom Beecher via NANOG (Aug 10)
- Re: Speaking of DNS server software... William Herrin via NANOG (Aug 10)
- Re: Speaking of DNS server software... Michael Thomas via NANOG (Aug 10)
- Re: Speaking of DNS server software... Randy Bush via NANOG (Aug 10)
- Re: Speaking of DNS server software... Jared Mauch via NANOG (Aug 10)
- Re: Speaking of DNS server software... Rubens Kuhl via NANOG (Aug 10)
- Re: Speaking of DNS server software... Ryan Hamel via NANOG (Aug 10)
