The kernel, which is the part of the OS where the TCP/IP stack is implemented, is written in C.
For programs which you would install with the debian package management system, you can do this to get the source code for any package (execute this command in a terminal):
apt-get source <packagename>
The kernel source code is a special case - install the source code by installing the linux-source package like this (as root or with sudo):
apt-get install linux-source
The source code gets put in /usr/src/linux. An alternative to this is to browse it online. There's a nice site here