def tcp_traceflow(frame, *, data_link):
    """Trace packet flow for TCP."""
    if 'TCP' in frame:
        ip = (frame['IPv4'] if 'IPv4' in frame else frame['IPv6']).info
        tcp = frame['TCP'].info
        data = dict(
            protocol=data_link,                     # data link type from global header
            index=frame.info.number,                # frame number
            frame=frame.info,                       # extracted frame info
            syn=tcp.flags.syn,                      # TCP synchronise (SYN) flag
            fin=tcp.flags.fin,                      # TCP finish (FIN) flag
            src=ip.src,                             # source IP
            dst=ip.dst,                             # destination IP
            srcport=tcp.srcport,                    # TCP source port
            dstport=tcp.dstport,                    # TCP destination port
            timestamp=frame.info.time_epoch,        # frame timestamp
        )
        return True, data
    return False, None
Trace packet flow for TCP.