TCPPacket Class — netty Architecture
Architecture documentation for the TCPPacket class in TCPPacket.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5005d382_85fb_be8b_2d1a_3492e61f9441["TCPPacket"] 01b05935_d4ca_200b_92ae_d5b9ab5e0e5f["TCPPacket.java"] 5005d382_85fb_be8b_2d1a_3492e61f9441 -->|defined in| 01b05935_d4ca_200b_92ae_d5b9ab5e0e5f 21007178_8988_5c1f_a125_d66e83d5161a["TCPPacket()"] 5005d382_85fb_be8b_2d1a_3492e61f9441 -->|method| 21007178_8988_5c1f_a125_d66e83d5161a 371e7f98_355a_0f11_7570_5d95a3f73fe9["writePacket()"] 5005d382_85fb_be8b_2d1a_3492e61f9441 -->|method| 371e7f98_355a_0f11_7570_5d95a3f73fe9
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/pcap/TCPPacket.java lines 20–82
final class TCPPacket {
/**
* Data Offset + Reserved Bits.
*/
private static final short OFFSET = 0x5000;
private TCPPacket() {
// Prevent outside initialization
}
/**
* Write TCP Packet
*
* @param byteBuf ByteBuf where Packet data will be set
* @param payload Payload of this Packet
* @param srcPort Source Port
* @param dstPort Destination Port
*/
static void writePacket(ByteBuf byteBuf, ByteBuf payload, long segmentNumber, long ackNumber, int srcPort,
int dstPort, TCPFlag... tcpFlags) {
byteBuf.writeShort(srcPort); // Source Port
byteBuf.writeShort(dstPort); // Destination Port
byteBuf.writeInt((int) segmentNumber); // Segment Number
byteBuf.writeInt((int) ackNumber); // Acknowledgment Number
byteBuf.writeShort(OFFSET | TCPFlag.getFlag(tcpFlags)); // Flags
byteBuf.writeShort(65535); // Window Size
byteBuf.writeShort(0x0001); // Checksum
byteBuf.writeShort(0); // Urgent Pointer
if (payload != null) {
byteBuf.writeBytes(payload); // Payload of Data
}
}
enum TCPFlag {
FIN(1),
SYN(1 << 1),
RST(1 << 2),
PSH(1 << 3),
ACK(1 << 4),
URG(1 << 5),
ECE(1 << 6),
CWR(1 << 7);
private final int value;
TCPFlag(int value) {
this.value = value;
}
static int getFlag(TCPFlag... tcpFlags) {
int flags = 0;
for (TCPFlag tcpFlag : tcpFlags) {
flags |= tcpFlag.value;
}
return flags;
}
}
}
Source
Frequently Asked Questions
What is the TCPPacket class?
TCPPacket is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/pcap/TCPPacket.java.
Where is TCPPacket defined?
TCPPacket is defined in handler/src/main/java/io/netty/handler/pcap/TCPPacket.java at line 20.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free