code: def tcp_reassembly(packet, *, count=NotImplemented):
      
      if 'TCP' in packet:
          ip = packet['IP'] if 'IP' in packet else packet['IPv6']
          tcp = packet['TCP']
          data = dict(
              bufid=(
                  ipaddress.ip_address(ip.src),       # source IP address
                  ipaddress.ip_address(ip.dst),       # destination IP address
                  tcp.sport,                          # source port
                  tcp.dport,                          # destination port
              ),
              num=count,                              # original packet range number
              ack=tcp.ack,                            # acknowledgement
              dsn=tcp.seq,                            # data sequence number
              syn=bool(tcp.flags.S),                  # synchronise flag
              fin=bool(tcp.flags.F),                  # finish flag
              rst=bool(tcp.flags.R),                  # reset connection flag
              payload=bytearray(bytes(tcp.payload)),  # raw bytearray type payload
          )
          raw_len = len(tcp.payload)                  # payload length, header excludes
          data['first'] = tcp.seq                     # this sequence number
          data['last'] = tcp.seq + raw_len            # next (wanted) sequence number
          data['len'] = raw_len                       # payload length, header excludes
          return True, data
      return False, None
docs: Store data for TCP reassembly.