简体   繁体   English

在Android VpnService中读取和转发数据

[英]Reading and forwarding data in Android VpnService

In ToyVpnService they read IP packets and then forward them to a remote VPN server. ToyVpnService中,他们读取IP数据包,然后将其转发到远程VPN服务器。

  1. Why do they use DatagramChannel ? 他们为什么使用DatagramChannel Isn't DatagramChannel used with UDP only? DatagramChannel是否仅与UDP一起使用?
  2. Why do they forward packages with their IP and TCP headers? 他们为什么转发带有IP和TCP标头的软件包? There are a lot of examples of writing arbitrary data to sockets (for example, here ) without headers. 有很多示例将没有头的任意数据写入套接字(例如here )。

From what I can tell the ToyVpnService is either an experiment or in a very early stage of development. 据我所知,ToyVpnService要么是实验,要么处于开发的早期阶段。

  1. Yes, it's only used for UDP. 是的,它仅用于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. 在您提供的Messenger示例中,应用程序交换字符串。 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. 与VPN通信时,必须发送标头,以便VPN可以转发其接收的任何数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM