I am implementing a vpn client in android using toyvpn sample. I want check details of packets send and receive by tunnel. I am using jpcap library to read packets but I'm not really know packets are in what protocol. my question is how to find type of packets.
// 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());
}
Ok I found answer. any packet received in vpn tunnel is internet layer packet. in this case we receive ip packets and then we can extract tcp or udp packet from that.