def tcp_timestamp_test(): p = Packet(tlspkt) (bef_tsval, _, _) = p.parse_timestamp() p.offset_timestamp(4, True) (after_tsval, _, _) = p.parse_timestamp() assert (bef_tsval + 4 == after_tsval) # Verify the TCP checksum before = p.get_tcp_cksum() p.update_cksum() after = p.get_tcp_cksum() assert (abs(after - before) == 4)
def tcp_attrib_test(): p = Packet(tlspkt) assert (p.get_sport() == 443) assert (p.get_dport() == 59320) assert (p.get_tcp_cksum() == 0xb8b0) assert (p.thl == 32) assert (p.get_opts() == '\x01\x01\x08\x0a\x44\x4e\x98\x3d\x0b\x63\x5a\xdb') assert (p.get_payload_len() == 95) assert (p.get_seq() == 0xbdb8019a) assert (p.get_ack() == 0xa72449c8) assert (p.get_flags() == 0x18) old_seq = p.get_seq() p.set_seq(old_seq + 1) assert (p.get_seq() == old_seq + 1) assert (p.get_ack() == 0xa72449c8) old_ack = p.get_ack() p.set_ack(old_ack + 1) assert (p.get_ack() == old_ack + 1)
def tcp_cksum_test(): p = Packet(tlspkt) before = p.get_tcp_cksum() p.update_cksum() after = p.get_tcp_cksum() assert (before == after)