ETHER(4)

NAME
ether - ethernet

SYNOPSIS
#include <netinet/if_ether.h>

    struct ether_addr {
            uint8_t ether_addr_octet[ETHER_ADDR_LEN /* 6 */];
    };
    struct ether_header {
            uint8_t ether_dhost[ETHER_ADDR_LEN /* 6 */];
            uint8_t ether_shost[ETHER_ADDR_LEN /* 6 */];
            uint16_t ether_type;
    };
    struct ether_footer {
            uint32_t ether_crc;
    };

DESCRIPTION
The Ethernet is a physical and link layer protocol for datagram exchange on a local area network. An Ethernet packet contains an Ethernet frame that contains a datagram of a higher level protocol. Ethernet 2.0 framing is implemented. IEEE Std 802.3 Ethernet framing is intentionally not implemented.

Ethernet hosts are addressed with a globally unique six byte address assigned to the network interface controller. An Ethernet address can be stored in the struct ether_addr type. Ethernet addresses are notated in hexadecimal form interspaced with colons, e.g. 00:00:5e:00:53:ff. The Ethernet addresses in the range from 00:00:5e:00:53:00 (inclusive) to 00:00:5e:00:53:ff (inclusive) are reserved for documentation. The address with all bits set (ff:ff:ff:ff:ff:ff) is the broadcast address and can be conveniently accessed using the etheraddr_broadcast(3) which is initialized to ETHERADDR_BROADCAST_INIT.

Ethernet packets are transmitted starting with an eight-byte start-of-frame preamble, followed by the Ethernet frame itself, ending with a twelve-byte interpacket gap. Ethernet 2.0 frames consist of a header, a datagram payload, and a frame check sequence. Frames are at least 64 bytes and are at most 1518 bytes. With 18 bytes of Ethernet frame overhead, the minimum transmission unit of the payload datagram is 46 bytes and the maximum transmission unit is 1500 bytes. The size of the frame is implicitly determined by the interpacket gap. The header has the format of struct ether_header, starting with the destination host address (ether_dhost), followed by the source host address (ether_shost), ending with a big-endian 16-bit EtherType value denoting the protocol associated with the payload datagram (ether_type). The frame check sequence has the format of struct ether_footer, being a 32-bit cyclic redundancy checksum of the frame except the checksum itself (ether_crc).

Frames are discarded on receipt if the destination address is neither the local address nor the broadcast address, if the source address is the broadcast address, or if the checksum is invalid.

Network layer addresses can be resolved to Ethernet addresses using the Address Resolution Protocol arp(4).

The ether_type field denotes the payload datagram protocol and the following values are supported:

ETHERTYPE_IP (0x0800)
    The Internet Protocol version 4 ip(4).

ETHERTYPE_ARP (0x0806)
    The Address Resolution Protocol arp(4).

The following constants are defined in <netinet/if_ether.h>:

ETHER_ADDR_LEN 6
    The size of an Ethernet address in bytes.

ETHER_TYPE_LEN 2
    The size of the type field in the Ethernet header in bytes.

ETHER_HDR_LEN 14
    The size of the Ethernet header in bytes.

ETHER_CRC_LEN 4
    The size of the Ethernet frame check sequence in bytes.

ETHER_LEN 18
    The total size of the Ethernet header and the frame check sequence in bytes.

ETHER_MIN_LEN 64
    The minimum size of Ethernet frames.

ETHER_MAX_LEN 1518
    The maximum size of Ethernet frames.

ETHERMTU 1500
    The maximum transmission unit for Ethernet payloads.

ETHERMIN 46
    The minimum transmission unit for Ethernet payloads.

ETHERADDR_BROADCAST_INIT {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}
    An initializer list for struct ether_addr that initializes it to the broadcast address ff:ff:ff:ff:ff:ff.

ERRORS
Socket operations can fail due to these error conditions, in addition to the error conditions of the invoked function.

[EMSGSIZE]
    The datagram was too large to be sent because it exceeded the maximum transmission unit (MTU) (1500 bytes) of the Ethernet protocol.

[ENOBUFS]
    There was not enough memory available for network packets.

SEE ALSO
etheraddr_broadcast(3), arp(4), if(4), inet(4), ip(4), kernel(7)

STANDARDS
Digital Equipment Corporation, Intel Corporation, Xerox Corporation, November 1982, Version 2.0, The Ethernet - A Local Area Network.

C. Hornig, April 1984, STD 41, RFC 894, A Standard for the Transmission of IP Datagrams over Ethernet Networks, Symbolics Cambridge Research Center.

Internet Engineering Task Force, R. Braden (ed.), October 1989, STD 3, RFC 1122, Requirements for Internet Hosts -- Communication Layers, USC/Information Sciences Institute. Internet Engineering Task Force, D. Eastlake 3rd, J. Abley, October 2013, RFC 7042, IANA Considerations and IETF Protocol and Documentation Usage for IEEE 802 Parameters, Huawei, Dyn, Inc..