Modifying outgoing TCP header fields

Hi everyone,
I'm new to FreeBSD and I faced a problem compiling FreeBSD kernel. Here is more details:

For an academic research project, I want to modify the header fields of TCP packets leaving the host.
My modification is quite simple, and I decided to to modify the kernel source code in this file /usr/src/sys/netinet/tcp_subr.c (I'd be happy if you can suggest me a better way)

Now, I'm not sure how to compile and install my changes. I have tried to add some intentional syntax error to the code, but following commands are telling me the kernel is successfully compiled.
Code:
sudo make -j4 buildworld KERNCONF=GENERIC
sudo make installworld KERNCONF=GENERIC

Do I miss something here? How can I make sure my new changes are being compiled?
 
I want to modify the header fields of TCP packets leaving the host.
Would you mind sharing what you want to modify? I'm not much of a developer but knowing what you want to do will provide a better indication of where things would need to be modified in the code.

As for the build instructions, you probably don't need to build world, you only need to rebuild the kernel (unless your changes would make its ABI incompatible). The build process is more or less split up into "world" (i.e. everything userland, libraries, executables, etc) and the kernel. The commands you've shown only built and installed the userland part, not the kernel. See build(7).

make buildkernel KERNCONF=MYKERNEL
make installkernel KERNCONF=MYKERNEL
 
Thanks for the quick reply.

I'm working with some programmable (P4-enabled) network devices. I'd like to use some information about the available buffer in the switches, to adjust TCP window size in the end-hosts.
In nutshell, I want to write/read into/from TCP URG field of outgoing TCP packets and to adjust CWND (congestion window size) dynamically in TCP stack.

I tried the new commands and now I see the intentional compile errors. Thanks a lot.
However, i'd be happy if you can recommend me a better approach for my project.
 
However, i'd be happy if you can recommend me a better approach for my project.
As I said, I'm not much of a developer so I simply don't know. But I'm sure there are others who can provide better answers for this.
 
Have you read the daemon book? It has a very good chapter at the end about how the network stack works. That should give you general guidance about what piece of code builds the headers, and how the stuff hangs together (the packet layer, the IP layer, the TCP layer), how IPSec and the packet filter interfaces modify things).

Marshall Kirk McKusick et al: Design and Implementation of the FreeBSD Operating System, 2nd edition. It's mostly black on the cover, with a red daemon on the left.

I have no idea whether sending packets with modified header fields is a good or bad idea. Nor what kind of trouble it will cause with other things on the network. I'm not an IP expert. But modifying the kernel source for experimental systems has long tradition in research, even if it leaves the system disfunctional for normal use. I've done this kind of stuff on the storage side, for example modifying the disk mid-layer driver to put time stamps into the IO buffers. So if you read or wrote a file, every 512-byte sector had the first few bytes replaced by a short string that described some performance-related fact. The fun thing was that even when writing a file, your memory buffer that you just wrote would change!
 
Back
Top