【发布时间】:2015-08-14 16:43:42
【问题描述】:
我正在使用 toyvpn 示例在 android 中实现一个 vpn 客户端。 我想检查通过隧道发送和接收的数据包的详细信息。我正在使用 jpcap 库来读取数据包,但我真的不知道数据包在什么协议中。我的问题是如何找到数据包的类型。
// Packets to be sent are queued in this input stream.
FileInputStream in = new FileInputStream(mInterface.getFileDescriptor());
// Packets received need to be written to this output stream.
FileOutputStream out = new FileOutputStream(mInterface.getFileDescriptor());
// Allocate the buffer for a single packet.
ByteBuffer packet = ByteBuffer.allocate(32767);
// Read the outgoing packet from the input stream.
int length = in.read(packet.array());
if (length > 0) {
// Write the outgoing packet to the tunnel.
packet.limit(length);
tunnel.write(packet);
// i use ip packet of jpcap but i think it is wrong
IPPacket ipPacket = new IPPacket(length,packet.array());
}
【问题讨论】:
标签: android network-protocols packet-sniffers