IPPacket Class — netty Architecture
Architecture documentation for the IPPacket class in IPPacket.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 2a529d61_5ad1_18d2_de54_9754b754e309["IPPacket"] e2fff88f_28bb_2e9d_7b17_eabe0fc944c9["IPPacket.java"] 2a529d61_5ad1_18d2_de54_9754b754e309 -->|defined in| e2fff88f_28bb_2e9d_7b17_eabe0fc944c9 5071529d_b24b_4ec9_39f8_8781c503650e["IPPacket()"] 2a529d61_5ad1_18d2_de54_9754b754e309 -->|method| 5071529d_b24b_4ec9_39f8_8781c503650e e1e0bffe_9a8c_499b_3405_ba1e9670ca8a["writeUDPv4()"] 2a529d61_5ad1_18d2_de54_9754b754e309 -->|method| e1e0bffe_9a8c_499b_3405_ba1e9670ca8a 845e3d9f_122c_e18b_da8b_67e81f55ef78["writeUDPv6()"] 2a529d61_5ad1_18d2_de54_9754b754e309 -->|method| 845e3d9f_122c_e18b_da8b_67e81f55ef78 ce6f4047_b49f_b89c_7554_affa2eb4cfca["writeTCPv4()"] 2a529d61_5ad1_18d2_de54_9754b754e309 -->|method| ce6f4047_b49f_b89c_7554_affa2eb4cfca dd6c96c2_5c3e_4436_c80d_76f1d1c91957["writeTCPv6()"] 2a529d61_5ad1_18d2_de54_9754b754e309 -->|method| dd6c96c2_5c3e_4436_c80d_76f1d1c91957 156ab60f_e4aa_05ff_1736_9a0ba1b68545["writePacketv4()"] 2a529d61_5ad1_18d2_de54_9754b754e309 -->|method| 156ab60f_e4aa_05ff_1736_9a0ba1b68545 e59ab5e0_bda8_f4ba_ecd6_a3e290cf997e["writePacketv6()"] 2a529d61_5ad1_18d2_de54_9754b754e309 -->|method| e59ab5e0_bda8_f4ba_ecd6_a3e290cf997e
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/pcap/IPPacket.java lines 20–111
final class IPPacket {
private static final byte MAX_TTL = (byte) 255;
private static final short V4_HEADER_SIZE = 20;
private static final byte TCP = 6 & 0xff;
private static final byte UDP = 17 & 0xff;
/**
* Version + Traffic class + Flow label
*/
private static final int IPV6_VERSION_TRAFFIC_FLOW = 60000000;
private IPPacket() {
// Prevent outside initialization
}
/**
* Write IPv4 Packet for UDP Packet
*
* @param byteBuf ByteBuf where IP Packet data will be set
* @param payload Payload of UDP
* @param srcAddress Source IPv4 Address
* @param dstAddress Destination IPv4 Address
*/
static void writeUDPv4(ByteBuf byteBuf, ByteBuf payload, int srcAddress, int dstAddress) {
writePacketv4(byteBuf, payload, UDP, srcAddress, dstAddress);
}
/**
* Write IPv6 Packet for UDP Packet
*
* @param byteBuf ByteBuf where IP Packet data will be set
* @param payload Payload of UDP
* @param srcAddress Source IPv6 Address
* @param dstAddress Destination IPv6 Address
*/
static void writeUDPv6(ByteBuf byteBuf, ByteBuf payload, byte[] srcAddress, byte[] dstAddress) {
writePacketv6(byteBuf, payload, UDP, srcAddress, dstAddress);
}
/**
* Write IPv4 Packet for TCP Packet
*
* @param byteBuf ByteBuf where IP Packet data will be set
* @param payload Payload of TCP
* @param srcAddress Source IPv4 Address
* @param dstAddress Destination IPv4 Address
*/
static void writeTCPv4(ByteBuf byteBuf, ByteBuf payload, int srcAddress, int dstAddress) {
writePacketv4(byteBuf, payload, TCP, srcAddress, dstAddress);
}
/**
* Write IPv6 Packet for TCP Packet
*
* @param byteBuf ByteBuf where IP Packet data will be set
* @param payload Payload of TCP
* @param srcAddress Source IPv6 Address
* @param dstAddress Destination IPv6 Address
*/
static void writeTCPv6(ByteBuf byteBuf, ByteBuf payload, byte[] srcAddress, byte[] dstAddress) {
writePacketv6(byteBuf, payload, TCP, srcAddress, dstAddress);
}
private static void writePacketv4(ByteBuf byteBuf, ByteBuf payload, int protocol, int srcAddress,
int dstAddress) {
byteBuf.writeByte(0x45); // Version + IHL
byteBuf.writeByte(0x00); // DSCP
byteBuf.writeShort(V4_HEADER_SIZE + payload.readableBytes()); // Length
byteBuf.writeShort(0x0000); // Identification
byteBuf.writeShort(0x0000); // Fragment
byteBuf.writeByte(MAX_TTL); // TTL
byteBuf.writeByte(protocol); // Protocol
byteBuf.writeShort(0); // Checksum
byteBuf.writeInt(srcAddress); // Source IPv4 Address
byteBuf.writeInt(dstAddress); // Destination IPv4 Address
byteBuf.writeBytes(payload); // Payload of L4
}
private static void writePacketv6(ByteBuf byteBuf, ByteBuf payload, int protocol, byte[] srcAddress,
Source
Frequently Asked Questions
What is the IPPacket class?
IPPacket is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/pcap/IPPacket.java.
Where is IPPacket defined?
IPPacket is defined in handler/src/main/java/io/netty/handler/pcap/IPPacket.java at line 20.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free