Decoding Ethernet headers
If we recall how the headers are layered from this chapter's introduction, the first layer we will need to peel off is the Ethernet (Link layer) header. It looks like this:
The hardware will filter out the preamble, so we will not have access to it, but we need to retrieve the following elements:
- Destination Address: This is the MAC address of the computer that this packet is being sent to
- Source Address: This is the MAC address of the computer that this packet came from
- Type: This is used to indicate the type of protocol that is encapsulated. Some of the common protocols are as follows:
- 0x0800—IPv4
- 0x0806—ARP
- 0x8035—RARP
- 0x86DD—IPv6 ...
Get iOS and OS X Network Programming Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.