【问题标题】:How to find packet type如何查找数据包类型
【发布时间】: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


    【解决方案1】:

    好的,我找到了答案。在 vpn 隧道中收到的任何数据包都是互联网层数据包。在这种情况下,我们会收到 ip 数据包,然后我们可以从中提取 tcp 或 udp 数据包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-15
      • 1970-01-01
      • 1970-01-01
      • 2021-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多