TCP hole punching on iPhone
I have done a bit of reading, and although I'm new to iPhone networking I was wondering if a TCP hole punch is possible for connecting two iPhones thro开发者_运维问答ugh NAT. I also read some helpful things about uPnP and hairpinning but I'm not to familiar with those at all, so if anyone has any ideas as to whether or not this is possible.
My goal is to be able to connect multiple iPhones over a large range (so it may be better to switch to some type of GPSR) but for now I'm only working with two iPhones and 3G NAT Traversal seems the simplest and most reliable in theory.
nat traversal is generic term used to connect two node directly with the help of rendevous server.Node can be any thing computer, smart phone or any other device.as far 3g is concerned it is one of the medium to transfer data nothing more .
Hair pin comes in to picture if your peer devices under same NAT uses public ip to connect each other because some router does not support hairpining like cisco router etc.This can be overcome if you use private IP instead of public IP.I can't say any thing about hair pinning in your case, since i don't the technical details about your network.
Update your question with technical details like kind of 3g you are using.then only I can say about hair pinning on 3g.
I have implemented udp/tcp hole punching using on 2g.I used three PC(one rendevous server and two node) to do this.
develop a rendevous server program which will run on one pc.the program should be capable to exchange public ip of two iphone device.
develop a client program install in iphone.Connect iphone to server this will expose public ip of iphone to server.repeat same process for second iphone. Now server will exchange public ip/port to both iphone. now each simultaneously start sending packet to each other at the same time this will punch hole in NAT.
detail about hole punching can be found on this http://www.brynosaurus.com/pub/net/p2pnat/
Better try with UDP hole punchcing which is easy to develop.TCP hole punching is bit tricky.Once you implement UDP Hole punching it is easy to to implement TCP hole punching.
Learn about STUN,ICE,NAT type,Nat Maping
https://www.rfc-editor.org/rfc/rfc5389
http://en.wikipedia.org/wiki/Network_address_translation
Cellular networks use Large Scale NAT. There are only three ways to get around it.
Don't use cellular networks or use a home/Wifi connected to a cellular network.
Get a TURN server.
Use multi-UDP hole punching (advanced technique). For Multi-UDP hole punching, try: https://drive.google.com/file/d/0B1IimJ20gG0SY2NvaE4wRVVMbG8/view?usp=sharing
精彩评论