Android VpnService to capture packets won't capture packets
Ok, it was not easy at all but I figured out how to capture packets. Since I am not extremely familiar with networking (but this new job is requesting that I am) I had difficulty with setting everything correctly. Basically after setting the right route in the VpnService.builder I got to receiving packets correctly.
So:
builder.addAddress("192.168.0.6", 24); // was wrong, you need to put an internal IP (10.0.2.0 for example)
and
builder.addRoute("0.0.0.0", 0); // needs to be this.
you don't need to set up a DnsServer through builder.addDnsServer() to make it work. Hope this helps anyone!
A firewall for Android with VpnService. Responses are delivered, but a SocketTimeoutException is thrown
The point was that I used a wrong IPv4 pseudo header to compute the checksum. It contained neither the packet UDP header nor the transmitted data. Since I included the UDP header and the data, I haven't seen the exception from the original question.
Related Topics
How to Retrieve the Logged in Google Account on Android Phones
How to Use the Same Keystore File to Sign Two Different Applications
Proguard: Can't Find Referenced Class Com.Google.Android.Gms.R
Android O - Old Start Foreground Service Still Working
Android Runonuithread Explanation
Launch Skype from an App Programmatically & Pass Number - Android
Android Studio Gradle Dsl Method Not Found: 'Android()' -- Error(17,0)
Set Selected Item in Android Bottomnavigationview
Notificationcompat with API 26
Error Message:This Android Sdk Requires Android Developer Toolkit Version 22.6.1 or Above
Run Code When Android App Is Closed/Sent to Background
Flutter Projects & Android X Migration Issues
Android: Retrieve Contact Name from Phone Number
What Are the Differences Between Linearlayout, Relativelayout, and Absolutelayout
Adding Opencv to Native C Code Through Cmake on Android Studio
Android: Remove All the Previous Activities from the Back Stack