The OSI model, which is the industry standard, defines the fundamental layers of network communication implementation by computer operating systems.
A host with one network interface card (NIC) is identifiable on the Internet by one unique IP address. A host's IP address is determined by the network to which it is connected. The same host could be connected to the network at a local coffee shop and then, later, be connected to a home network. Between the two locations, that host was identified by two different IP addresses. Think of an IP address like a home address. It is based on location.
An address not based on location is a physical address, or MAC address. A host's MAC address is permanently assigned to its NIC during manufacture. Unlike an IP address, MAC addresses do not change when a host moves to a different network. Think of a MAC address like a SSN. It is permanently assigned to a person at birth and never changes.
Ethernet and WiFi dominate the way hosts connect to networks now, so new computers typically have both an Ethernet adapter and a WiFi adapter. Each interface has its own unique MAC addresses and it is possible for each interface to have its own unique IP address as well. Each interface can connect to a different network and, therefore, possess different IP addresses.
|
At the link layer of the OSI stack, IEEE standard 802.3 specifies communication over Ethernet links. Each device on the network has a unique Media Access Control (MAC) address, which is used to direct Ethernet packets. An Ethernet packet consists of a 1 byte preamble followed by the Ethernet header, encapsulated data, and checksum. The last three items are collectively referred to as an Ethernet frame. |
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |[ Destination MAC Address (6 bytes) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ]|[ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Source MAC Address (6 bytes) ]| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type/Length of Data |[ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Client Data + padding (46-1500 bytes) | | .... ]| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CRC Checksum (4 bytes) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
tar -xvf udp.pcap.tarYou will see a file
udp.pcap
|
A PCAP file has the following format:
The global header is 24 bytes. We won't really care much about what's in the global header. If you're curious, check out the documentation. |
$ hexdump -C udp.pcap 00000000 d4 c3 b2 a1 02 00 04 00 00 00 00 00 00 00 00 00 |................| 00000010 00 00 04 00 01 00 00 00 ac 25 30 61 25 b9 03 00 |.........%0a%...| 00000020 33 00 00 00 33 00 00 00 08 00 27 f3 5c ca 08 00 |3...3.....'.\...| 00000030 27 b3 0c 54 08 00 45 00 00 25 47 c0 40 00 40 11 |'..T..E..%G.@.@.| 00000040 19 ac c0 a8 ac 04 c0 a8 ac 06 8d f8 1e c6 00 11 |................| 00000050 d9 7e 75 64 70 20 74 65 73 74 0a af 25 30 61 ec |.~udp test..%0a.| 00000060 02 09 00 3c 00 00 00 3c 00 00 00 08 00 27 b3 0c |...<...<.....'..| 00000070 54 08 00 27 f3 5c ca 08 00 45 00 00 22 55 bf 40 |T..'.\...E.."U.@| 00000080 00 40 11 0b b0 c0 a8 ac 06 c0 a8 ac 04 1e c6 8d |.@..............| 00000090 f8 00 0e 1c d2 77 6f 72 6b 73 0a 00 00 00 00 00 |.....works......| 000000a0 00 00 00 00 00 00 00 |.......| |
ac 25 30 61 25 b9 03 00 |.........%0a%...|
00000020 33 00 00 00 33 00 00 00 08 00 27 f3 5c ca 08 00 |3...3.....'.\...|
00000030 27 b3 0c 54 08 00 45 00 00 25 47 c0 40 00 40 11 |'..T..E..%G.@.@.|
00000040 19 ac c0 a8 ac 04 c0 a8 ac 06 8d f8 1e c6 00 11 |................|
00000050 d9 7e 75 64 70 20 74 65 73 74 0a af 25 30 61 ec |.~udp test..%0a.|
00000060 02 09 00 3c 00 00 00 3c 00 00 00 08 00 27 b3 0c |...<...<.....'..|
00000070 54 08 00 27 f3 5c ca 08 00 45 00 00 22 55 bf 40 |T..'.\...E.."U.@|
00000080 00 40 11 0b b0 c0 a8 ac 06 c0 a8 ac 04 1e c6 8d |.@..............|
00000090 f8 00 0e 1c d2 77 6f 72 6b 73 0a 00 00 00 00 00 |.....works......|
000000a0 00 00 00 00 00 00 00
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 | Timestamp (Seconds) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4 | Timestamp (Microseconds or nanoseconds) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
8 | Captured Packet Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
12 | Original Packet Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
08 00 27 f3 5c ca 08 00 27 b3 0c 54 08 00 45 00 00 25 47 c0 40 00 40 11 19 ac c0 a8 ac 04 c0 a8 ac 06 8d f8 1e c6 00 11 d9 7e 75 64 70 20 74 65 73 74 0a
Ethernet frame format is shown below:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |[ Destination MAC Address (6 bytes) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ]|[ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Source MAC Address (6 bytes) ]| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type/Length of Data |[ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Client Data + padding (46-1500 bytes) | | .... ]| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CRC Checksum (4 bytes) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
The packet data is re-arranged according to the Ethernet frame format:
08 00 27 f3 5c ca Destination MAC
08 00 27 b3 0c 54 Source MAC
08 00 Type
45 00 00 25 47 c0 40 00 Client Data
40 11 19 ac c0 a8 ac 04
c0 a8 ac 06 8d f8 1e c6
00 11 d9 7e 75 64 70 20
74 65 73 74 0a
|