使用libnet_build_tcp_options設定options資料

來源:互聯網
上載者:User

標籤:libnet_build_tcp_options mss 時間戳記

在使用libnet發送TCP SYN資料時,一般預設不設定options資訊,即沒有mss和時間戳記。

在某些IDC機房,這些資料會被攔截掉。出現的現象是使用telnet訪問沒有問題,但是libnet發送SYN資料包沒有回應。需要在發包的時候設定options資訊。libnet提供了libnet_builf_tcp_options來進行設定。

uint8_t payload[20] = {0x00};static int set_options_payload(uint8_t *payload,uint32_t timeval,uint16_t mss){    int len = 0;        //set mss value    payload[len++] = 0x02;    payload[len++] = 0x04;    payload[len++] = (uint8_t)((mss >> 8) & 0xFF);    payload[len++] = (uint8_t)(mss & 0xFF);        //set SACK    payload[len++] = 0x04;    payload[len++] = 0x02;        //set timeval    payload[len++] = 0x08;    payload[len++] = 0x0a;    payload[len++] = (uint8_t)((timeval >> 24) & 0xFF);    payload[len++] = (uint8_t)((timeval >> 16) & 0xFF);    payload[len++] = (uint8_t)((timeval >> 8) & 0xFF);    payload[len++] = (uint8_t)(timeval & 0xFF);    len+=4;        //set NOP    payload[len++] = 0x01;        //set Window scale    payload[len++] = 0x03;    payload[len++] = 0x03;    payload[len] = 0x07;        return 0;}r = libnet_build_tcp_options(            payload,            20,            l,            0);


使用libnet_build_tcp_options設定options資料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.