How to set the tcp option timestamp while building a tcp SYN packet using python?
I need to send a tcp SYN packet with timestamp value in tcp option. Since tcp opts should be prepacked in 32-bit representation,开发者_JAVA技巧 can anyone brief me how to set the value in 32 bit packet representaion with a example.
Thanks in advance
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.
精彩评论