I have a snippet below which is a part of a code to create and send raw packet, which works by the way.
However, the code sets the tcph-> window to htonl(65535). My issue is, the window is only 16 bits and actually gets assigned 0x0000 so I don’t get why not just set 0 directly.
Also, what is the significance of setting the Window to 0 ?
void setup_tcp_header(struct tcphdr *tcph)
{
tcph->source = htons(src_port); // SOURCE PORT
tcph->dest = htons(dst_port); // TARGET PORT
tcph->seq = random();
tcph->ack_seq = 0;
tcph->res2 = 0;
tcph->doff = 5;
tcph->syn = 1;
tcph->window = htonl(65535); // 0x FFFF 0000 but window is uint16_t so only gets the 00 00
// LSBs
tcph->check = 0;
tcph->urg_ptr = 0;
}
Verified with WS and indeed Window is set to 0: