问题
I need to send a tcp SYN packet with timestamp value in tcp option. Since tcp opts should be prepacked in 32-bit representation, can anyone brief me how to set the value in 32 bit packet representaion with a example.
Thanks in advance
回答1:
You should be able to do that pretty easily with Scapy. When defining your TCP layer, just use
TCP(flags='S', options=[('Timestamp', (TSval, 0))])
where TSval is your timestamp value. If you want to convert the resultant packet to its binary representation, call str() on it.
In future packets, you can replace the 0 with the appropriate TS echo reply per RFC 1323.
来源:https://stackoverflow.com/questions/5082516/how-to-set-the-tcp-option-timestamp-while-building-a-tcp-syn-packet-using-python