DRAFT: Life of a packet series: Packet Creation

The command used to generate the packet:

echo "Hello World!" | sudo strace -f nc -u 10.1.0.1 5000

The strace command is used to look inside the Linux kernel to examine how the kernel generates the packet and puts it on the wire.

execve("/bin/nc", ["nc", "-u", "10.1.0.1", "5000"], [/* 14 vars */]) = 0
...
socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP) = 3
fcntl(3, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
connect(3, {sa_family=AF_INET, sin_port=htons(5000), sin_addr=inet_addr("10.1.0.1")}, 16) = 0
fcntl(3, F_SETFL, O_RDWR)               = 0
poll([{fd=3, events=POLLIN}, {fd=0, events=POLLIN}], 2, -1) = 1 ([{fd=0, revents=POLLIN|POLLHUP}])
read(0, "Hello World!\n", 2048)         = 13
write(3, "Hello World!\n", 13)          = 13
poll([{fd=3, events=POLLIN}, {fd=0, events=POLLIN}], 2, -1) = 1 ([{fd=0, revents=POLLHUP}])
shutdown(3, SHUT_WR)                    = 0
close(0)                                = 0

…a lot of details and explanations go here…