Author Topic: Testing IPv6 on iOS  (Read 11160 times)

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Testing IPv6 on iOS
« on: July 26, 2016, 12:09:18 AM »
Starting with the example scene basics of TNet3 I am able to connect to an external server with the TNServer.exe by typing in the address plus port number on an iOS build. It connects and works fine on my router with my IP address.

When connecting on a IPv6 NAT64 network using the exact same method. No dice.



I followed the Apple guide in setting up IPv6 NAT64 network.

https://developer.apple.com/library/mac/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW1

What steps did I miss in regards to getting a connection from an IPv6 network?  How are you connecting from an IPv6 network?

Apologies, but I am not quite getting how this works.  Does TNet3 not automatically do this for you or am I not using it properly?
« Last Edit: July 26, 2016, 12:35:17 AM by voncarp »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Testing IPv6 on iOS
« Reply #1 on: July 26, 2016, 11:03:26 PM »
TNServer is compiled using IPv4, not IPv6. You need to explicitly recompile it for IPv6. Look at how it's done in ExampleMenu.cs:
  1. TcpProtocol.defaultListenerInterface = useIPv6 ? System.Net.IPAddress.IPv6Any : System.Net.IPAddress.Any;
Attached is the ServerMain file that supports an -ipv6 flag along with a pre-compiled TNServer.exe for you.

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Testing IPv6 on iOS
« Reply #2 on: July 27, 2016, 01:43:54 PM »
Thanks for compiling the server for me.  And the previous one.

But I am still struggling making a connection.

I run a few different TNServer.exe to test on this external test server.  Port 7000 is set up for IPv6.



Connecting to port 7001 ipv4  works brilliantly easy.





But any attempt to connect to port 7000 never works. I set IPv6 to true in the example scene.



Here are the two TNserver.exe on the server:



Perhaps I am missing something very fundamental, but are you able to tell me what steps I am missing or what I did wrong?

This test has the latest TNet on the Asset Store and uses the TNServer.exe that you provided. I just used a Mac for testing.




cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Testing IPv6 on iOS
« Reply #3 on: July 27, 2016, 03:01:37 PM »
161.202.144.242 is not an IPv6 address.

Make sure the client socket is IPv6.

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Testing IPv6 on iOS
« Reply #4 on: July 27, 2016, 03:27:11 PM »
Thanks cmifwdll.

You have been a big help to me before.

Make sure the client socket is IPv6.

I have to admit I don't what that means or what I need to do. Would you be able to push me in the right direction?

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Testing IPv6 on iOS
« Reply #5 on: July 27, 2016, 03:38:00 PM »
Well, first step would be replacing that ipv4 address with an ipv6 one :P

You probably just forgot, but you typed the server's ipv4 address here: https://dl.dropboxusercontent.com/u/78828827/Screen%20Shot%202016-07-27%20at%207.40.15%20AM.png and that's likely why you're unable to connect ;)
I don't know exactly how Aren implemented it, but here's how I instantiate the client socket:
File TNTcpProtocol.cs, function ConnectToTcpEndPoint():
mSocket = new Socket(tcpEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

In this case, tcpEndPoint is the parsed IPEndPoint from the box you type in. So its address family would be ipv4, and the socket would be ipv4.

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Testing IPv6 on iOS
« Reply #6 on: July 27, 2016, 04:11:28 PM »
Thanks again cmifwdll,

My low skill level in networking and connections is very evident in my questions and issues.

Well, first step would be replacing that ipv4 address with an ipv6 one :P

You probably just forgot, but you typed the server's ipv4 address here: https://dl.dropboxusercontent.com/u/78828827/Screen%20Shot%202016-07-27%20at%207.40.15%20AM.png and that's likely why you're unable to connect ;)
I don't know exactly how Aren implemented it, but here's how I instantiate the client socket:
File TNTcpProtocol.cs, function ConnectToTcpEndPoint():
mSocket = new Socket(tcpEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

In this case, tcpEndPoint is the parsed IPEndPoint from the box you type in. So its address family would be ipv4, and the socket would be ipv4.

I didn't forget, sadly; I just never knew and bothered to research further since TNet made it so easy. Thanks for taking it easy on me  ;)

But, once I can connect; I can bounce RFC's around to create some wonderful things in my projects. And because of that, I have had some very good success on iOS and Steam, so your assistance is very much appreciated.

So what I need to do is type in an ipv6 address to connect to the server as such: 2002:a1ca:90f2:a1ca:90f2:7000 in lieu of 161.202.144.242:7000? Because I typed that in the example menu to no avail.



Just to add on to this conversation, on a IPv6 NAT64 network created from Apple's guidance:

https://developer.apple.com/library/mac/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW1

Half of the apps on my phone no longer connect.  Clash of Clans and Pokemon Go connect on this network non surprisingly, however agar.io

https://www.quora.com/How-much-did-the-Agar-io-creator-earn-for-his-game

the top selling free app on the US Appstore apparently is not compatible. So, like me he will be unable to update his project until he remedies that.








cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Testing IPv6 on iOS
« Reply #7 on: July 27, 2016, 04:53:18 PM »
Yes, because Unity is running an earlier version of mono, TNet can't make use of dual mode sockets. Because of this, ipv4 servers can only accept ipv4 clients, and ipv6 servers can only accept ipv6 clients. Likewise for clients connecting to servers, but that's based more on the IP you enter rather than the public IP you've been assigned (as most ISPs are dual-stack now).

Back on topic: if you want to connect to an ipv6 server, you must address it using its ipv6 address. Looking at the server console output, it doesn't look like your server has been assigned a public ipv6 address? That's very strange. I don't know enough about ipv6 to recognize if those local IPs are accessible over the WAN. I know the fe80:: addresses are link-only, but the 2002: one looks strange as well.

Regardless, the line that outputs the external IP should return ipv6 if you have a public ipv6. I suppose it's possible the WebClient is using the wrong interface? Still, then, one of the outputted ipv6 local addresses should be publicly accessible.

TL;DR I don't think your host gave you an ipv6 address. Double check that. If you do have a public ipv6 address and still can't connect to it, there's a bug in TNet.

edit: On your server, try going to http://ipv6.icanhazip.com and see what it returns (it's not a fancy webpage, only a single string should pop up).

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Testing IPv6 on iOS
« Reply #8 on: July 27, 2016, 10:07:59 PM »
Again cmifwdll,

Thanks for the continued support!



« Last Edit: July 27, 2016, 10:52:24 PM by voncarp »

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Testing IPv6 on iOS
« Reply #9 on: July 28, 2016, 05:22:02 AM »
Looks like a parsing error now.

Can you open up TNTcpProtocol.cs and navigate to the ConnectToTcpEndPoint() function. In that function, there should be a line similar to:
IAsyncResult result = mSocket.BeginConnect(tcpEndPoint, OnConnectResult, mSocket);
Can you add a
UnityEngine.Debug.LogWarning("Connecting to: " + tcpEndPoint + " with socket address family (" + mSocket.AddressFamily + ")");
directly above that?



voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Testing IPv6 on iOS
« Reply #10 on: July 28, 2016, 12:28:13 PM »
I added it above. Its not hitting that Debug.LogWarning  :'(

Tnet3 is structured a bit differently than the original.  For the most part, everything seems to work the same.

Edit:

Placed

Debug.Log (tcpEndPoint);

right after if (tcpEndPoint != null)
 
Results in
0.0.7.210:0
« Last Edit: July 28, 2016, 01:05:02 PM by voncarp »

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: Testing IPv6 on iOS
« Reply #11 on: July 28, 2016, 08:04:42 PM »
Yeah, definitely a parsing error. Probably because of the double colons out of nowhere. IPv6 still doesn't make sense to me :(

I don't know where TNet3 does its parsing, so I can't help further. Hopefully Aren will see this and help you out more. In the meantime, if you want, you can try finding the parsing error. I'd start with the TNManager.Connect function and its overloads. You'll want to extract the port, then pass the leftover string to IPAddress.TryParse. From there, it might make sense to verify the IPAddress is valid. It seems the Uri.CheckHostName function can do that for you.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Testing IPv6 on iOS
« Reply #12 on: July 29, 2016, 10:24:55 AM »
Why did you add port 7000 to the end of your address? Remove that, and use the default port 5127. That input field was written with IPv4 in mind in regards to specifying a port with a colon at the end, but you are using IPv6. Omitting the port makes it use the default (5127).

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Testing IPv6 on iOS
« Reply #13 on: July 29, 2016, 11:54:27 AM »
I start up a new TNServer.exe with default port -tcp 5127



I have the port open



Find my IPv6 with on the server with http://ipv6.icanhazip.com



And then type in the IPv6 address without the port number



And still nothing  :(

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Testing IPv6 on iOS
« Reply #14 on: July 29, 2016, 09:08:13 PM »