December 3, 2022

BSD TCP/IP for Kyu - Progress report 12-3-2022

This all started around October 21, so I have been working on this for over a month. I did get distracted for about a week on another project (involving the EMUP prom programmer and the EBAZ fpga board).

At this point I have bind working, so I can register a server on the host I am working with. I also have listen and accept working so I can respond to connections to such a server. And I have write working, so I can send something when I accept a connection.

Working on "read" will be next. Right now I am working on "connect".

While working on connect I have gotten embroiled in getting a full understanding of TCP (and IP) checksums. Another issue that came up is how to handle things that pertain to the local interface, namely putting the correct source IP address into an outgoing packet.

On a BSD system, interfaces are set up by various "ioctl" calls that are initiated by system scripts running the ifconfig program. I have nothing like this, so I need to set up the datastructures by hand that such calls would have done.

Along the way, I decided to implement a loopback interface on 127.0.0.1. The motivation here was to allow me to debug connect and leverage my ability to add as much debug information as I wanted to the server side of a connection. I ran into a situation where the ACK packet that I was sending to my linux machine was simply never showing up. As it turns out it was silently being dropped due to a bad checksum, but I didn't find that out until I could get information by using the loopback arrangement.

Adding loopback means that I now have two interfaces and two structures to handle them. My idea is that TCP code should not need to have any information about routing (that should all by done by the IP code). The need to select a different interface structure for loopback packets sort of conflicts with that philosophy.

I have spent a lot of time working on some debug tools. At first I was just sprinkling printf statements in the code, and to a large extent that is still what I am doing. As the debug trace has gotten more voluminous and confusing, I have needed to add some order to it to be able to use it effectively. I have also added a test menu and intend to add some statistics display to it. I would like to show how many objects of different sort are in use, on the free list for said object, and what the "high water mark" has been.

My current focus is undestanding why I cannot properly verify the TCP checksum for an outgoing packet with tools I have written. Once I satisfy myself about that, I will work on cleaning up the handling of data in the interface structures.


Have any comments? Questions? Drop me a line!

Kyu / [email protected]