Question

In ToyVpnService they read IP packets and then forward them to a remote VPN server.

  1. Why do they use DatagramChannel? Isn't DatagramChannel used with UDP only?
  2. Why do they forward packages with their IP and TCP headers? There are a lot of examples of writing arbitrary data to sockets (for example, here) without headers.
Was it helpful?

Solution

From what I can tell the ToyVpnService is either an experiment or in a very early stage of development.

  1. Yes, it's only used for UDP. They either don't care about lost packets at this stage or they plan to implement a control mechanism later.

  2. In the messenger example that you provide, the apps exchange strings. They don't need to send any other info because they only want to display them. When you communicate with a VPN you have to send the headers so the VPN can forward any data it receives.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top