Live data from Hacker News

Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

saminiir.com

41–50 of 50 posts

Re: Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

#41
post #34

Earlier quoted context omitted.

A range one might introduce boxing depending on the types being iterated.

Or use a language with reified generics :)

Go maps are reified generics, and very efficient ones at that.

Re: Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

#42
post #17

Earlier quoted context omitted.

I don't see any reason in modern C to use int/short/long over explicit int32_t/int8_t/int64_t other than they're shorter to type.

Where can I read tips like that about modern C, would you have a book to recommend or a blog to follow? Thank you

I wish I did. I write C for my day job, and pick up most of this from my teammates.

Re: Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

#43
post #17

Earlier quoted context omitted.

I don't see any reason in modern C to use int/short/long over explicit int32_t/int8_t/int64_t other than they're shorter to type.

Where can I read tips like that about modern C, would you have a book to recommend or a blog to follow? Thank you

I can't speak to the utility of either, but a couple of resources I've found recently:

http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf

http://shop.oreilly.com/product/0636920033677.do

Re: Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

#44

Operating System Design: Internet Working With Xinu by Douglas Comer (1987) is a nice explanation with lots of C code of how to add a networking stack to an operating system, in this case his educational unix-inspired XINU.

I actually can't find the book you are referencing. I do see:

"Operating System Design: The Xinu Approach" and also the books "Internetworking with TCP /IPvolumes1-3." Might you have a link to the title you are referencing here? I have read the Internetworking series which is excellent.

Re: Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

#45

Earlier quoted context omitted.

Or use a language with reified generics :)

Go maps are reified generics, and very efficient ones at that.

What you mean is it's a set of C macros, except built-in to the compiler. Great if it's exactly what you need. And you're prepared for severe WTF moments (e.g. equality on map values is ... not the same as equality on variables of the same type containing the same thing). Also, expect the whole thing to be useless if you need slight complexity (e.g. you can use strings as keys, but not bytes (either Bytes, or []byte, but you can use [5]byte for example).

Oh ... you actually need it to be a red-black tree, or a custom hash function ? Tough.

Re: Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

#46
post #21

For those that rather learn how to implement it in a safer language, Fuchsia's TPC/IP stack is written in Go. https://fuchsia.googlesource.com/third_party/netstack/

Isn’t garbage collection going to introduce jitter?

Not in general, though of course lots of production language runtimes do involve a certain amount of GC-related jitter. But even where such jitter is introduced, it might not be a very big deal for something like TCP/IP.

Re: Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

#47

Operating System Design: Internet Working With Xinu by Douglas Comer (1987) is a nice explanation with lots of C code of how to add a networking stack to an operating system, in this case his educational unix-inspired XINU.

I actually can't find the book you are referencing. I do see: "Operating System Design: The Xinu Approach" and also the books "Internetworking with TCP /IPvolumes1-3." Might you have a link to the title you are referencing here? I have read the Internetworking series which is excellent.

This seems to be the book - https://www.amazon.com/Operating-System-Design-Vol-Internetw...

It looks the the second volume that goes with "Operating System Design".

I can't be 100% certain, as I didn't find a table of content for either of the 1st edition books, but the 2nd edition of "Operating System Design" includes a section in implementing ethernet, so perhaps the two volumes got combined into one for the second edition.

Re: Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

#48
post #47

Earlier quoted context omitted.

I actually can't find the book you are referencing. I do see: "Operating System Design: The Xinu Approach" and also the books "Internetworking with TCP /IPvolumes1-3." Might you have a link to the title you are referencing here? I have read the Internetworking series which is excellent.

This seems to be the book - https://www.amazon.com/Operating-System-Design-Vol-Internetw... It looks the the second volume that goes with "Operating System Design". I can't be 100% certain, as I didn't find a table of content for either of the 1st edition books, but the 2nd edition of "Operating System Design" includes a section in implementing ethernet, so perhaps the two volumes got combined into one for the second…

I see that now. Great, this looks interesting. Thanks for checking.

Re: Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

#49
post #33

Earlier quoted context omitted.

GC will always introduce jitter. You can choose not to use it and allocate statically etc, but that does not mean that use of a GC does not introduce jitter. Also don't confuse high performance with latency-sensitive. Highly performance-optimised code will still have issues with GC jitter if you or someone else is causing it. There is a reason why the GC-enabled OSs aren't used for anything in reality. BTW: There sho…

> GC will always introduce jitter. > You can choose not to use it and allocate statically etc, but that does not mean that use of a GC does not introduce jitter. It only introduces jitter if it runs at all. If one really wants to be drastic in performance critical code, in most GC runtimes it is possible to just turn it off. On Go's case a runtime.SetGCPercent(-1) will take care of that. > There is a reason why the G…

Care to say which GC-enabled OS you have on your phone?

I'm not talking about GC-enabled runtimes such as a JVM or ObjC/Swift runtime, they're application-level.

Both Mach(IOS) and Linux(Android) are non-GC-enabled OSs.

Re: Let's code a TCP/IP stack, 1: Ethernet & ARP (2016)

#50
post #47

Earlier quoted context omitted.

I actually can't find the book you are referencing. I do see: "Operating System Design: The Xinu Approach" and also the books "Internetworking with TCP /IPvolumes1-3." Might you have a link to the title you are referencing here? I have read the Internetworking series which is excellent.

This seems to be the book - https://www.amazon.com/Operating-System-Design-Vol-Internetw... It looks the the second volume that goes with "Operating System Design". I can't be 100% certain, as I didn't find a table of content for either of the 1st edition books, but the 2nd edition of "Operating System Design" includes a section in implementing ethernet, so perhaps the two volumes got combined into one for the second…

That's indeed the book I was referring to. Thank you for clarifying.
Post reply on HN