Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app-to-app communicator on Android #2131

Closed
4 tasks
synctext opened this issue Apr 25, 2016 · 16 comments
Closed
4 tasks

app-to-app communicator on Android #2131

synctext opened this issue Apr 25, 2016 · 16 comments

Comments

@synctext
Copy link
Member

synctext commented Apr 25, 2016

Create a first app for automagic NAT puncturing and traversal on Android.

The app will connect to others which installed this app and try to establish a connection with them. This is the only functionality of this app: getting an UDP NAT puncture to others. Part of this functionality is discovering others and coordinating a puncture attempt. On this first screen of the app the currently discovered other app installs are shown. For each other user the status of the puncture is show in real-time. Builds upon the ideas of this work.
image

Testing This app will be released on TUDelft Android account, source code on Github, and with Tweakers coverage we aim to obtain test users.

No-server-needed Only 1 app is needed, without any dedicated server software. TUDelft will provide two Nexus 6 test phones with two fixed wifi-based IPv4 numbers. These will run the dedicated app and serve as hard-coded servers running the client servers and facilitate peer discovery.

PEX PEX builds on the no-server-needed part to discover others. Simply use the Peer Exchange message to decentralise the peer discovery. Use a simple PEX implementation. Only implement the ut_pex message without the added and dropped extras.

many ports One idea to evaluate is to open 60000 UDP listen ports from your app. This extreme approach would capture all incoming packets.

puncturing Implement the puncture-request message to conduct the actual NAT traversal with the help of another user. Essential approach description, see section 4 for another description of this, plus IETF draft

Starting point: https://github.com/MaStanford/AndroidSimpleNetworkInfo

Possible sprints (2 weeks each):

  • Working app with 2 hard coded Android phones
  • Implement scalable peer discovery
  • Effective UDP puncture mechanism with green and red lights
  • Test with 20+ test users, polish, Tweakers promo, and release on Google Play
@whirm
Copy link
Contributor

whirm commented Apr 25, 2016

Why does this have to be a standalone app instead of one based on @brussee's work?

@synctext
Copy link
Member Author

@whirm Another student, first Java prototype.. :-)

@whirm
Copy link
Contributor

whirm commented Apr 25, 2016

yeah, but that will mean having to reimplement it from scratch in python, I think that will be a waste of effort.

Isn't it better to directly implement the prototype feature on the existing codebase?

@synctext
Copy link
Member Author

This project by design is isolated from the huge Tribler/Dispersy code base.

If it works this method cannot be easily be integrated into Dispersy. Sometimes you need 10 tries before it punctures on Android with 3G/4G carrier networks. Dispersy only tries stuff once and only once.

@synctext
Copy link
Member Author

First running code: https://github.com/Jaapp-/app-to-app-communicator

@synctext
Copy link
Member Author

synctext commented May 12, 2016

Next sprint Goals:
PEX operational with 1 PC emulated Phone, 2x android devices
Tell people what external IP you are seeing for them in a message.
Lookup local IPv4 and wifi/3G info plus include this as text field in PEX as info for overview screen of app.
Puncture-request message
ToastNotifier for each incoming UDP packet of a new phone.

@synctext
Copy link
Member Author

Detailed report on NAT puncturing: http://www.ds.ewi.tudelft.nl/reports/2010/PDS-2010-007.pdf

@synctext
Copy link
Member Author

Public connectable App Port (Still TCP-only..)
screenshot_20160523-113252

@synctext
Copy link
Member Author

Advanced feature: voting on external IPv4 https://github.com/Tribler/dispersy/blob/devel/dispersy.py#L738

@Jaapp-
Copy link

Jaapp- commented May 23, 2016

Tribler IP
130.161.211.254

Use Datagram Socket instead of Socket
UDP puncture
Generate random peer-specific hash, send with each message to be able differentiate between data from peers
Don't establish a connection with self
Include carrier, more information, with messages
Save instance state, don't lose list on redraw.
Implement proper OnPause / OnStop
Use service instead of activity?

@synctext
Copy link
Member Author

synctext commented May 31, 2016

Algorithm for peer list:

  • continuously actively crawl the app-to-app overlay (start on app open)
  • remove PEX, fully rely on the 5 second crawler.
  • You attempt to establish a connection (in progress status: yellow), resulting in either a green or red status
  • Puncture-request message is used for NAT traversal
  • identify carrier and wireless technology used (3G/4G/wifi)
  • Bonus: determine roughly the IP address pool by repeatedly turning of data connectivity (3G/4G/wifi) and using the app to determine your assigned public IP number.
  • Implement the 4 message types of Dispersy
  • Connection management:
    • outgoing message every 5 seconds, randomly select between the current known IP numbers
    • always directly reply to an incoming message; status green; also add this to known IP numbers
    • timeout and memory leak prevention: limit to 10 known IP numbers, drop oldest (green status).
    • dead peer prevention: limit to 20 unknown IP numbers (red status).
  • Think about a list of peers with unique hash-based identities and various flags:
    • incoming peers (incoming-message-peers)
    • just introduced to you and already punctured (already-punctured-peers)
    • outgoing peers (introduction-request) which have given a reply (outgoing-connection-peers)

@synctext
Copy link
Member Author

synctext commented Jun 8, 2016

The walker is getting operational. No more Hello World or keyboard entry popup. Tighter GUI design:
gui

@synctext
Copy link
Member Author

synctext commented Jun 16, 2016

Stability issues, GUI mistakes, but running!

@synctext
Copy link
Member Author

synctext commented Jun 16, 2016

Fixes and polish:

  • 2 lines on the screen per peer - including the green/red/orange status bullet
  • 5 Second real-time update
    • outgoing peers
    • WAN address (not WAN vote) + "local IP"
    • last ping to each peer
  • graceful handling of 4G to wifi switch.
  • permanent storage of the unique identifier.
  • Overwrite Peer-List duplicates upon arrival, only keep last incoming packet of same hash.
  • stability....
  • Incoming versus outgoing
    • in outgoing column when never got reply
    • move peer to incoming and turn green when received reply
    • Means you're connectable for that peer
  • Add global NAT traversal rate: percentage of outgoing packets to unique hashes from which you got a reply.

@synctext
Copy link
Member Author

synctext commented Nov 16, 2016

Live on app store: https://play.google.com/store/apps/details?id=org.tribler.app_to_appcommunicator

@YourDaddyIsHere our progress from earlier this year

@synctext
Copy link
Member Author

Good demo app, now project has finished

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants