Packets are data-turduckens: [ Ethernet frame [ IP packet [ TCP packet [misc data] ] ] ]
Octets Structure: ------------------------ 7 Preamble (0x55 * 7) 1 Start of frame delimiter (0xD5) 6 MAC destination 6 MAC source (4) 802.1Q tag (optional) used for tagging Ethernet frames for Virtual LANs 2 Ethertype - Indicates what protocol is encapsulated in the Ethernet frame(Ethernet II) or length (IEEE 802.3) 46(42)-1500* Payload 4 Frame check sequence (32-bit CRC) 12 Inter-packet gap
Internet Protocol (IP) (man 7 ip)
man 7 ip
IPv4 packet header:
Offsets |0 1 2 3 Octet Bit |0 1 2 3 4 5 6 7 8 9 10111213141516171819202122232425262728293031 0 0 |Version |IHL |DSCP |ECN| Total Length 4 32 | Identification |Flags| Fragment Offset 8 64 |Time To Live |Protocol | Header Checksum 12 96 |Source IP Address 16 128 |Destination IP Address 20+ 160 |Options (if IHL > 5)
Version (4 bits)
Total Length (16 bits)
[Source port (2 octets)][Destination port (2 octets)] [Length (2 octets)][Checksum (2 octets)] [ Data (length-8 octets) .... ]
https://en.wikipedia.org/wiki/Transmission_Control_Protocol
Provides reliable, ordered delivery of a data stream. If a packet fails to arrive at its destination it will eventually be resent.
Header contains among other information:
[ Source Port (2 octets) ][ Destination Port (2 octets) ] [ Sequence number (4 octets) ] [ Acknowledgment number (4 octets) ] [ Data Offset (4bits)][Reserved(3bits)][Flags(9bits)][Window Size (2octets)] [ Checksum (2 octets) ][ Urgent pointer(if URG set)(2) ] [ Options (if data offset > 5). Zero padded if necessary ] [ Data ... ]
Flags = { NS | CWR | ECE | URG | ACK | PSH | RST | SYN | FIN } (1 bit each)
Src/Dst ports - same as UDP.
Sequence #
Acknowledgment #
Reserved (3 bits)
Flags (9 bits): NS ECN (Explicit Congestion Notification)-nonce concealment protection. CWR Congestion Window Reduced. ENE ECN - Echo URG Indicates that the Urgent Pointer field is to be used. ACK Indicates the Acknowledgment field is to be used. PSH Push Function RST Reset connection SYN Synchronize sequence numbers (set when initializing connection) FIN No more data from sender
Window Size (16 bits)
Urgent Pointer
If URG is set, indicates the offset from the sequence # of the last urgent data byte.
Options