I need to change window size in TCP header, but when I changing it and recalculate the checksum the final window is multiplying by window scale option. Where and in which structure I can find it and change?
You can't change the window scale after it has been negotiated during connection establishment. You need to set a large receive buffer on the socket prior to connecting it. In the case of a server, you need to set the receive buffer size on the listening socket, from whence it will be inherited by the accepted socket.
Yes, I can't change the window scale after it has been negotiated during connection establishment. I want to post a piece of code which I wrote to get tcp options(mss and window scale):
typedef struct {
unsigned char kind;
unsigned char size;
} tcp_option_t;
unsigned char* tmp = tcp_header;
if (tcp_header->doff > 5) {
unsigned char* opt = tmp + sizeof(struct tcphdr);
while( *opt != 0 ) {
tcp_option_t* _opt = (tcp_option_t*)opt;
if( _opt->kind == 1 ) { //NOP
++opt; // NOP is one byte;
continue;
}
if( _opt->kind == 2 ) { //MSS
unsigned int* mss_opt = (unsigned int*)(opt + sizeof(tcp_option_t));
unsigned int mss = htons(*mss_opt);
f->mss = mss;
}
if( _opt->kind == 3 ) { //wnd_scale
integer24* wnd_opt = (integer24*)(opt + sizeof(tcp_option_t));
integer24 wnd_scale = *wnd_opt;
f->wnd_scale = wnd_scale.data;
}
opt += _opt->size;
if (_opt->size == 0) {
//pr_info("Very strange situation: zero size\n");
break;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.