EthernetPacket Class — netty Architecture
Architecture documentation for the EthernetPacket class in EthernetPacket.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD bf875d14_0a63_8e25_f2ce_56b911b429cf["EthernetPacket"] 237a1357_92dc_1818_8ff5_6d79fa07643b["EthernetPacket.java"] bf875d14_0a63_8e25_f2ce_56b911b429cf -->|defined in| 237a1357_92dc_1818_8ff5_6d79fa07643b 76385209_4bd1_01d5_6305_331446b8a9aa["EthernetPacket()"] bf875d14_0a63_8e25_f2ce_56b911b429cf -->|method| 76385209_4bd1_01d5_6305_331446b8a9aa bc79b740_6cc3_0503_3ae7_9679b768b6cf["writeIPv4()"] bf875d14_0a63_8e25_f2ce_56b911b429cf -->|method| bc79b740_6cc3_0503_3ae7_9679b768b6cf d63141ad_1211_2caf_3210_4c637a3d4cfa["writeIPv6()"] bf875d14_0a63_8e25_f2ce_56b911b429cf -->|method| d63141ad_1211_2caf_3210_4c637a3d4cfa 2eb1d768_10ef_cca4_b206_4d6e817e525f["writePacket()"] bf875d14_0a63_8e25_f2ce_56b911b429cf -->|method| 2eb1d768_10ef_cca4_b206_4d6e817e525f
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/pcap/EthernetPacket.java lines 20–81
final class EthernetPacket {
/**
* MAC Address: 00:00:5E:00:53:00
*/
private static final byte[] DUMMY_SOURCE_MAC_ADDRESS = new byte[]{0, 0, 94, 0, 83, 0};
/**
* MAC Address: 00:00:5E:00:53:FF
*/
private static final byte[] DUMMY_DESTINATION_MAC_ADDRESS = new byte[]{0, 0, 94, 0, 83, -1};
/**
* IPv4
*/
private static final int V4 = 0x0800;
/**
* IPv6
*/
private static final int V6 = 0x86dd;
private EthernetPacket() {
// Prevent outside initialization
}
/**
* Write IPv4 Ethernet Packet. It uses a dummy MAC address for both source and destination.
*
* @param byteBuf ByteBuf where Ethernet Packet data will be set
* @param payload Payload of IPv4
*/
static void writeIPv4(ByteBuf byteBuf, ByteBuf payload) {
writePacket(byteBuf, payload, DUMMY_SOURCE_MAC_ADDRESS, DUMMY_DESTINATION_MAC_ADDRESS, V4);
}
/**
* Write IPv6 Ethernet Packet. It uses a dummy MAC address for both source and destination.
*
* @param byteBuf ByteBuf where Ethernet Packet data will be set
* @param payload Payload of IPv6
*/
static void writeIPv6(ByteBuf byteBuf, ByteBuf payload) {
writePacket(byteBuf, payload, DUMMY_SOURCE_MAC_ADDRESS, DUMMY_DESTINATION_MAC_ADDRESS, V6);
}
/**
* Write IPv6 Ethernet Packet
*
* @param byteBuf ByteBuf where Ethernet Packet data will be set
* @param payload Payload of IPv6
* @param srcAddress Source MAC Address
* @param dstAddress Destination MAC Address
* @param type Type of Frame
*/
private static void writePacket(ByteBuf byteBuf, ByteBuf payload, byte[] srcAddress, byte[] dstAddress, int type) {
byteBuf.writeBytes(dstAddress); // Destination MAC Address
byteBuf.writeBytes(srcAddress); // Source MAC Address
byteBuf.writeShort(type); // Frame Type (IPv4 or IPv6)
byteBuf.writeBytes(payload); // Payload of L3
}
}
Source
Frequently Asked Questions
What is the EthernetPacket class?
EthernetPacket is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/pcap/EthernetPacket.java.
Where is EthernetPacket defined?
EthernetPacket is defined in handler/src/main/java/io/netty/handler/pcap/EthernetPacket.java at line 20.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free