Search Unity

Network over 3g?

Discussion in 'Multiplayer' started by iceshaft07, Dec 2, 2010.

  1. iceshaft07

    iceshaft07

    Joined:
    Jul 23, 2010
    Posts:
    293
    I am currently converting a turn based-esq game into a networked turn based game. There is only one thing that really moves, so I think TCP should be fine.

    I was reading up on the problems with networking over 3G here:
    http://forum.unity3d.com/threads/59612-Networking-with-iPhone?highlight=network+iphone

    And it seems that this is not really possible.

    Before I dive too deep into this, has anyone figured out if this is possible (the whole NAT punchtrough?) Maybe could I program around it somehow?

    I was planning on having a SQL DB with information about who is a server, and have users look that stuff up (but maybe I should look into Unity Master Server before I do)

    While working on the android, I noticed that it returned 127.0.0.1. for the device IP address; it seems as if I am about to program my users into being required to be on WIFI rather than being able to play over 3G (the over lords won't be happy with this).

    That said, it seems like we will likely have to use that GameKitPlugin, and some #if UNITY_IPHONE's-- but what about the android? Is there a plugin for that hanging out somewhere as well (not a whole lot of info exists for the androids-- only a week ago did an answer come out for ads on androids).

    Any words of advice?

    Thanks

    -Rob
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    nat punchthrough is not possible on most phone providers.
    They completely block any port on UDP normally which kills out any option to host games.

    GameKit does not change that btw, gamekit allows adhoc multiplier in direct device - device range but for online you still need a dedicated server as with unity networking or the common solutions (photon, smartfox, electro server). GameCenter multiplayer or OpenFeint multiplayer should work but they do so cause they are actually handled by dedicated servers in the background.

    also don't forget: latency on 3G is 100ms to 5s commonly and it can jump in that range in the blink of an eye. so doing anything but turnbased is not really an option for "enjoyable gameplay".
     
  3. iceshaft07

    iceshaft07

    Joined:
    Jul 23, 2010
    Posts:
    293
    Woops, sorry didn't write clearly enough.

    I'm really trying to do a mix of getting people in the same room hooked up together over 3G, while also getting them from around the world hooked up together.

    Since Unity does not support BlueTooth connections, I only have 2 options-- over the network, or use GameKit. Game Kit only works with iPhone, so I was hoping to maximize portability and minimize coding by only using the network. If networking over 3G is not possible, then I will need to find a bluetooth solution for Android, and in addition implement GameKit for iPhone.




    My plan was to do an ad-hoc style, where one device becomes a client/server, and the other a client. Once a person presses 'create server' on their phone.Ii was planning to have a SQL database online with an IP column in it so people can find servers in a nice list, and hten just click them to connect.

    My question about the android was if there was something that does allow AdHoc for a plugin-- is there a GameKit-esq solution for android that allows communication over BlueTooth?

    Thats really a bummer through, I wish Unity would just start supporting BlueTooth already.

    I suppose I'll have to use iPhoneNetworkReachability.ReachableViaWiFiNetwork to determine if they can connect over the wifi, and disable the button if they can't.

    Well, thanks anyways :).
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    For AdHoc you have no alternative to GameKit as its not available in any other form (Unity 3 originally was meant to have GK integrated but thats among the list of iOS additions that got postphoned till somewhen).

    And nope, no GameKit alike thing on Android as android has not locked down access to everything. You should be able to access it there rather directly through java, potentially even on the NDK level

    unity supporting bluetooth wouldn't change much, especially cause bluetooth is not an exactly fast protocol, especially in those versions that oyu will find on all iphones and most android phones
     
  5. iceshaft07

    iceshaft07

    Joined:
    Jul 23, 2010
    Posts:
    293
    Does GameKit use bluetooth or does it use something else?

    I assumed it did.
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    GameKit since 3.1 can use bluetooth but also Wifi adhoc (not possible in any other way - without gamekit wifi always requires an access point you are connected through)
     
  7. iceshaft07

    iceshaft07

    Joined:
    Jul 23, 2010
    Posts:
    293
    Good To Know, Thanks :)
     
  8. iceshaft07

    iceshaft07

    Joined:
    Jul 23, 2010
    Posts:
    293
    Dreamora, there is a new game out called 'Eliminate'; there is a review stating that this game /can/ be played over 3G, and I have confirmed myself that it does. Briefly, it is an FPS game that you can buy stuff for at an online store-- Any idea on how they might have gotten around the UDP filters?

    I know I saw another one of your posts (I believe under SmartFox somewhere) where you said you were excited to see if they might have been able to fix the 3G issue-- but unless people are sending packets over port 80 (against IEEE, but I've seen people do it), I'm not sure how you can do it.

    Also, I read that the speed of 3G (one certain towers) reached on the upwards of ~14.5 Mb/sec down, and ~6 Mb/sec down-- that sounds about as fast as a basic cable modem, so sounds like 3G should be fast enough for a FPS style game.
    http://www.qttel.com/htc-evo-4g/

    The above information was difficult to find, and I probably wouldn't consider it general case.

    Everywhere else says that speed of 1.5Mb/sec down and .5 Mb/sec up are roughly what most people get.

    From: http://www.pocketgamer.co.uk/r/iPhone/Eliminate/news.asp?c=15497
    Code (csharp):
    1.  
    2. Phenomenal stability ensures the game runs smoothly over 3G (even better with a solid wi-fi connection) and much-needed changes to the interface guarantee easier control.
    3.  
    Thanks for the info!

    -Rob
     
  9. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    3G is not even remotely in that range. Its at max 7.2mbit /s (not mbyte)
    You need 4G / LTE to get higher which is in most places of earth rather unlikely to be seen.

    Also the traffic is totally unimportant, the problem is the latency on 3G which is in the 100ms to 2000ms range, where anything above 500 means you are dead in a shooter.


    As for Eliminate: right you can play it on 3G. But you forget the important fact: Players don't host games, the games are hosted on their central server actually.
    Also, nothing on a shooter on 3G really requires UDP, you can jsut as well use async TCP, cause the packet drop rate on 3G is that high, that you will end with more overhead on UDP than you would see on TCP.
     
  10. Kaiserludi

    Kaiserludi

    Joined:
    Jan 21, 2009
    Posts:
    94
  11. Kaiserludi

    Kaiserludi

    Joined:
    Jan 21, 2009
    Posts:
    94
    Actually Ego-Shooter are one of the easiest and most suited genres, if it comes to 3G and it's bad latencies and (much more important) bad jitter (meaning, latency is not stable at some bad level, but highly fluctuating): If you are shot in an ego-shooter, as on the server you have been hit, but on your client due to latency the shot has only been close but no cigar, you as the player often can't tell for sure, if it has been a hit or not, as most of the body of your own character is not visible to yourself, so you will just accept it. If you have a 2d game in bird eye view, you can see such situations and so here the algorithms to make latency less visible are much more mportant. For Ping Tanks I even had to reinvent the wheel as all the existing well known algorithms out there used by games like for example Quake or CS, etc. were visually absolutely inacceptable for a realtime birds eye action game with direct user input (would be no problem with indirect user input like for RTS) and quick units on the latencies and jitter of average 3G-connections.

    Actually, the advantages of udp and tcp depend on the type of data to send:
    movement-positon updates - udp is preferable, as this data has to be sent up to multiple times a second per player and if a packet is lost, it does require more time on tcp to resent it as the most uptodate update, which would make the previous one outdated, would need to come through
    kills/hits and this kind of data - has to be reliable, so udp is not usable out of the box for this kind of data, tcp is
    for Ping Tanks only udp is used, but for all data aside from the movements updates, the special Photon-feature of reliable udp is used here, to combine the reliability of tcp with the less overhead of udp.
    Indeed 3G has quite a lot of packet-loss, so sending information like kills via unreliable udp would make the game unplayable, but for the same reason it woul have a lot more latency effects and would be way less fun to play, if movement-data would be sent reliable.
     
  12. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    You would really go for unrealiable on 3G?

    I would personally definitely never go there.
    But I would also never offer action oriented shooter with low latency requirements on 3G, just cause it won't work out. Dino XXX (the MP dino battle game, one of the first MP over internet the iOS had) stutters like stupid and thats sending very little position data ...

    The "most action oriented MP" concept I would consider going to 3G is an MMO or a secret of mana style game, where the position sync is less important than the target actions etc which go through RPC mechanisms (Ops in Photon etc) anyway
     
  13. Kaiserludi

    Kaiserludi

    Joined:
    Jan 21, 2009
    Posts:
    94
    I not only would go this way, I already went it. Ping Pilots, the team behing Ping Tanks, which I mentioned above, rent me out form Exit Games as lead game engineer, responsible for most of the iPhone code including all of the client side network logic.
    Although this kind of game is way more latency-sensitive than Ego-Shooters, which already to latency play in a completely different dimension thant mmorpgs, it worked out on 3g.
     
  14. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    ok, sounds cool :)
     
  15. iceshaft07

    iceshaft07

    Joined:
    Jul 23, 2010
    Posts:
    293
    I didn't write that it was MegaByte, I wrote that it was Megabit. MB = MegaByte, Mb = Megabit (unless you've heard something else :) ).

    My game isn't huge is only has 2 players. Sending positions via UDP is exaclty what I'm going to do, but I'm glad you mentioned sending hits over TCP, 'cause I wouldn't have thought to do that.

    That's fine; what I was really bringing up was not the speed so much as I thought the ports were blocked for that? Maybe I can get creative to reduce the amount of data sent-- given my game, this would be the perfect game to test on since such little data would be transmitted that I think I should be able to get away with it.

    That said, when I programmed network things in the past, it was usually pretty easy-- just tell the program to use a UDP socket or a TCP socket and I was done.

    But, I can't quite figure it out on Unity. I see state syncronization, but that isn't what I want. I am just dispatching RPC's and I want to dispatch some as TCP and some as UDP.

    Any suggestions?
     
  16. iceshaft07

    iceshaft07

    Joined:
    Jul 23, 2010
    Posts:
    293
    Has anyone figured out how to do this yet?

    I have attempted, but even trying to cheat the AT&T servers by using port 80 for the server / client connection failed.
     
  17. iceshaft07

    iceshaft07

    Joined:
    Jul 23, 2010
    Posts:
    293
    We did some preliminary tests with SmartFoxServer 2, and it appears that networking over 3G is possible if you use this.

    The free version that they are offering, though in its beta stages, allows 100 connections free. Just thought I'd throw that out there. I will not however, that it does not appear to do much work for you. It seems (at my understanding right now), that if you want to program it properly, you need to duplicate a lot of the code that Unity handles for you (such as Raycasting) as Java Code on the server.

    Dreamora, why would SFS2 work over 3G but not Unity Networking? I figured that because the ports were simply closed on the AT&T side, that there would have been no way to do this other than through port 80-- but I seem to be able to communicate fine through 27015 on our tests (I should not that I did not perform the test, and I can not verify the integrity of the test-- I would have tried a few more times than "once" and say "OK, this workls").
     
  18. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    With SFS or any centralized networking solution its no problem because you don't host anything.
    You only send out data and the sending back then normally is allowed.

    But only after you really sent out data to that physical place not just fake (NAT punchthrough) it.

    But in case of SFS it might actually even be due to a fallback to TCP - HTTP protocol which both will definitely fine when you do calling out.


    With Unity Networking, you don't host a central server, one of the players has to host it and to do so. And thats where the problem comes in: That user can never be reached as he can not receive UDP messages from places he has not talked to and he can not talk to any place thats on 3G commonly.
    With one of them being on WiFi it could reasonably become possible (but even then only if they are not in a public places Wifi).

    for that reason its normally far less of a pain


    As for the ports itself: The general rule is and always has been (I think its even defined in the related documents on networking portranges itself), that all ports in the sub 10k range are tabu. There are "globally standardized" ports in that range and its pretty common for hardware firewalls and other mechanisms to block all communications outside these ports and if the data don't fullfill the expected protocol.
    With Port 10000 and higher, the "free and open" ports, its reasonably possible to get much further.

    There is only 1 exception to this and that is UDP Port 6112. This is often working too, because this is the port Blizzard has been using since WarCraft 2 / diablo days.