code: def tcp_traceflow(packet, *, count=NotImplemented):
      
      if 'TCP' in packet:
          ip = packet['IP'] if 'IP' in packet else packet['IPv6']
          tcp = packet['TCP']
          data = dict(
              protocol=LINKTYPE.get(packet.name.upper()),     # data link type from global header
              index=count,                                    # frame number
              frame=packet2dict(packet),                      # extracted packet
              syn=bool(tcp.flags.S),                          # TCP synchronise (SYN) flag
              fin=bool(tcp.flags.F),                          # TCP finish (FIN) flag
              src=ipaddress.ip_address(ip.src),               # source IP
              dst=ipaddress.ip_address(ip.dst),               # destination IP
              srcport=tcp.sport,                              # TCP source port
              dstport=tcp.dport,                              # TCP destination port
              timestamp=time.time(),                          # timestamp
          )
          return True, data
      return False, None
docs: Trace packet flow for TCP.