I'm working with the android VpnService in Kotlin and after
val vpnInputStream = FileInputStream(vpnInterface!!.fileDescriptor).channel
val vpnOutputStream = FileOutputStream(vpnInterface!!.fileDescriptor).channel
GlobalScope.launch {
loop@ while(alive){
val buffer = ByteBuffer.allocate(1024) //Packet length
val readBytes = vpnInputStream.read(buffer)
When it comes to reading the data, I want to implement my own IpV4 packet parser so my question is what is the right ByteBuffer size, what happens if I make it bigger or smaller and do packets get automatically fragmented if the packet length is bigger?