1

I am trying to implement a receiving side of the TCP protocol via scapy.

I have node A who sends some random json file over TCP to node B, and I am trying to write the receiving side of TCP using scapy for node B. I am sniffing packets in scapy and trying to ACK incoming packets from node B.

I have figured out how to set correct ACK and SEQ numbers for the ACK packets I construct, but I'm struggling with creating correct Timestamp TCP options. I have read in RFC-1323 that Timestamp contains TSval and TSecr. I set TSecr by copying the TSval from the incoming packet, but from what I understand, I need to set TSval to be the current time of the system. I'm not sure how to get the time correctly. I tried doing the following in python

import time
TSval = int(time.time())

But it doesn't give me the correct value because the value of TSecr is something like 3130283869 whereas the above snippet gives me something like 1539307653 (almost 2x smaller). It's not clear to me what kind of time is represented by Tsecr and TSval. Is it epoch time? Is it something else?

Anny G
  • 159
  • 2
  • 2
  • 11
  • Are you sure that a simple TCP serversocket / socket implementation is not enough ? Scapy is more focused on low-level networking. – Cukic0d Oct 13 '18 at 01:27
  • While it is no doubt that the specific scenario I described could use existing TCP socket implementation, in reality I have actually simplified my real scenario in order to ask a question on StackOverflow. So yes, I know that Scapy is focused on low level networking and it is exactly why I am using it and simple TCP serversocket/socket implementation is not enough for me. – Anny G Oct 13 '18 at 21:58
  • My bad I didn’t get the question. What you are asking seems very similar to https://stackoverflow.com/q/27812542/5459467 – Cukic0d Oct 14 '18 at 18:33
  • I saw it but it didn't answer my question because it does not say how to calculate the values :( The answer provided only explains what TSval and TSecr mean and links to their official definition but it's still not helpful for actually creating those values via python. – Anny G Oct 15 '18 at 05:59

0 Answers0