6

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 through 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.

Skyler
  • 63
  • 1
  • 5

2 Answers2

10

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.

  1. develop a rendevous server program which will run on one pc.the program should be capable to exchange public ip of two iphone device.

  2. 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

Community
  • 1
  • 1
Vikram Ranabhatt
  • 7,268
  • 15
  • 70
  • 133
  • I was actually wondering whether it is possible with only iPhones. My guess is no, since you would have to somehow be able to control each iPhone's local network, but I'm not sure. – Skyler Jul 18 '11 at 03:04
  • Each iPhone's Local area network is the network of the Provider Say from example British Telecom,Vodafone.That Local area will provides IP address to each iPhone and that Ip is local to their network.But when it comes to communication between two iPhone between Different Network like between VOdafone and British Telecom they will use some public IP.This is my thinking not sure about it.If you can clarify "somehow be able to control each iPhone's local network" than it will easy to understand your problem – Vikram Ranabhatt Jul 18 '11 at 09:42
  • Yes. I think the problem is each phone can only get the public ip of another phone. I don't think it's possible to get the ip local ip address over 3G without knowing something about the network each phone is in, and since Vodafone, Telecom, AT&T, or Singtel for example control that network, I don't think it is possible. I'm wondering if it's possible either without the local ip of the phone, or to access that network to find the ip address. – Skyler Jul 19 '11 at 10:29
  • I never Tried over 3G But I tried using Data Card(2G) of Vodafone/Air Tel It will Give Only Public Ip.That Public is sufficient to communicate with each Other within Same Network like or Outside.2g network and 3g network are same .Private IP comes in to the picture When Your Device is connected with Network using Router like PC in any organisation.So in an Organisation to accommodate large user they install NAT/Router.Here In case of mobile communication that case never comes, Since your iPhone is not connected with Router and Provider assign IP address Dynamically to each phone. – Vikram Ranabhatt Jul 19 '11 at 15:52
  • So, if I am understanding correctly, as long as the two phones are in different networks they will be assigned different ips by the provider and you won't be able to communicate directly (without the use of a server or something). They would have to be in the same network, which in my case I cannot guarantee. – Skyler Jul 20 '11 at 01:48
  • Whether phones are on same network or different network public Ip will assigned to both the phone and using hole punching you can connect it.Obviously server is required but that is only for initial connection.once the connection between the phone is done you can disconnect with the server and start communication between two phone. I would like know what procedure you are following to make this communication done.Do update me about it. – Vikram Ranabhatt Jul 20 '11 at 06:40
0

Cellular networks use Large Scale NAT. There are only three ways to get around it.

  1. Don't use cellular networks or use a home/Wifi connected to a cellular network.

  2. Get a TURN server.

  3. Use multi-UDP hole punching (advanced technique). For Multi-UDP hole punching, try: https://drive.google.com/file/d/0B1IimJ20gG0SY2NvaE4wRVVMbG8/view?usp=sharing