udpV4() — netty Function Reference
Architecture documentation for the udpV4() function in PcapWriteHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 09664c21_072d_80b4_a75e_e5bf4f97af22["udpV4()"] e9f4993c_4935_9405_4fab_0bbc9030a673["PcapWriteHandlerTest"] 09664c21_072d_80b4_a75e_e5bf4f97af22 -->|defined in| e9f4993c_4935_9405_4fab_0bbc9030a673 04cb4359_ee0e_2eba_fe0f_fdd5884262e0["udpV4SharedOutputStreamTest()"] 04cb4359_ee0e_2eba_fe0f_fdd5884262e0 -->|calls| 09664c21_072d_80b4_a75e_e5bf4f97af22 1ceaa157_983b_01fb_7e76_423befb794eb["udpV4NonOutputStream()"] 1ceaa157_983b_01fb_7e76_423befb794eb -->|calls| 09664c21_072d_80b4_a75e_e5bf4f97af22 7294656e_de76_eb6d_2716_ab3c6280f6c4["udpV4NoGlobalHeaderOutputStream()"] 7294656e_de76_eb6d_2716_ab3c6280f6c4 -->|calls| 09664c21_072d_80b4_a75e_e5bf4f97af22 201e7e9e_c23c_b328_ecb1_117026fc1c03["InetSocketAddress()"] 09664c21_072d_80b4_a75e_e5bf4f97af22 -->|calls| 201e7e9e_c23c_b328_ecb1_117026fc1c03 eb1ea467_0963_a158_64e4_4642e02fe449["verifyUdpCapture()"] 09664c21_072d_80b4_a75e_e5bf4f97af22 -->|calls| eb1ea467_0963_a158_64e4_4642e02fe449 style 09664c21_072d_80b4_a75e_e5bf4f97af22 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java lines 89–149
private static void udpV4(boolean sharedOutputStream, boolean writeGlobalHeaders)
throws InterruptedException {
ByteBuf byteBuf = Unpooled.buffer();
ByteBuf payload = Unpooled.wrappedBuffer("Meow".getBytes());
try {
InetSocketAddress serverAddr = new InetSocketAddress("127.0.0.1", 0);
InetSocketAddress clientAddr = new InetSocketAddress("127.0.0.1", 0);
EventLoopGroup eventLoopGroup = new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory());
// We'll bootstrap a UDP Server to avoid "Network Unreachable errors" when sending UDP Packet.
Bootstrap server = new Bootstrap()
.group(eventLoopGroup)
.channel(NioDatagramChannel.class)
.handler(new SimpleChannelInboundHandler<DatagramPacket>() {
@Override
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) {
// Discard
}
});
ChannelFuture channelFutureServer = server.bind(serverAddr).sync();
assertTrue(channelFutureServer.isSuccess());
CloseDetectingByteBufOutputStream outputStream = new CloseDetectingByteBufOutputStream(byteBuf);
// We'll bootstrap a UDP Client for sending UDP Packets to UDP Server.
Bootstrap client = new Bootstrap()
.group(eventLoopGroup)
.channel(NioDatagramChannel.class)
.handler(PcapWriteHandler.builder()
.sharedOutputStream(sharedOutputStream)
.writePcapGlobalHeader(writeGlobalHeaders)
.build(outputStream));
ChannelFuture channelFutureClient =
client.bind(clientAddr).sync();
assertTrue(channelFutureClient.isSuccess());
Channel clientChannel = channelFutureClient.channel();
DatagramPacket datagram = new DatagramPacket(payload.copy(),
(InetSocketAddress) channelFutureServer.channel().localAddress());
assertTrue(clientChannel.writeAndFlush(datagram).sync().isSuccess());
assertTrue(eventLoopGroup.shutdownGracefully().sync().isSuccess());
// if sharedOutputStream is true or writeGlobalHeaders is false, we don't verify the global headers.
verifyUdpCapture(!sharedOutputStream && writeGlobalHeaders,
byteBuf, payload,
(InetSocketAddress) channelFutureServer.channel().localAddress(),
(InetSocketAddress) clientChannel.localAddress()
);
// If sharedOutputStream is true, we don't close the outputStream.
// If sharedOutputStream is false, we close the outputStream.
assertEquals(!sharedOutputStream, outputStream.closeCalled());
} finally {
byteBuf.release();
payload.release();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does udpV4() do?
udpV4() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java.
Where is udpV4() defined?
udpV4() is defined in handler/src/test/java/io/netty/handler/pcap/PcapWriteHandlerTest.java at line 89.
What does udpV4() call?
udpV4() calls 2 function(s): InetSocketAddress, verifyUdpCapture.
What calls udpV4()?
udpV4() is called by 3 function(s): udpV4NoGlobalHeaderOutputStream, udpV4NonOutputStream, udpV4SharedOutputStreamTest.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free