Bad Network performance - udp

Discussion in 'Mac Programming' started by T1663R, Apr 4, 2014.

  1. T1663R, Apr 4, 2014
    Last edited: Apr 4, 2014

    T1663R macrumors newbie

    Joined:
    Apr 4, 2014
    #1
    Hey,

    im working on adding Network support to my game. on 127.0.0.1 it runs fine. If i try with a Friend over the internet we get really bad gaming Performance.

    this code is sending the moving Blocks in our world to the Clients :
    this is the sendObjecttoall clients method :

    But as mentioned we get really bad Performance. (with bad Performance i mean moving Boxes constanly warping for the Client, but only for few Pixels, increasing if the moving speed of the Boxes Increases)
    And it also lags for the client, increasing if he moves faster.
    Why is that ? And how can i fix that ?

    thanks in advance. Greetings

    EDIT
    i forgot to mention i use the AsyncNetwork.framework
     
  2. lee1210, Apr 4, 2014
    Last edited: Apr 5, 2014

    lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    There's a lot of information missing here. How much data are you sending over the wire? How big is an archived BlockPosition? What is the latency between you and your client? How much overhead is there for your UDP packets? How many BlockPositions are normally sent by this? Could you bundle all BlockPositions together to reduce chatter? What processing is done on the other side? How much time does it take to archive this thing? Are you maintaining the connection or is it being closed/reopened frequently? Have you ever worked with this networking library before? Have you worked with network programming in general?

    Start measuring and asking these questions. Find your bottleneck. Optimize it. Test again. Tweak. Keep going until it's acceptable. Don't assume anything is as it should be. Be willing to abandon all of your assumptions.

    Post more of your code and we may be able to help more specifically.

    -Lee

    Edit: The "are you maintaining a connection" is likely irrelevant here. I deal with TCP much more frequently.
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #3
    Exactly which version? Post its URL.

    There's this one:
    https://github.com/jdiehl/async-network

    It says there:
    In client-server networking, clients connect to servers to exchange messages. In AsyncNetwork, every client will automatically connect to every discovered server with the same service name. Servers are discovered using Bonjour.
    ...
    In peer-to-peer networking, every peer can exchange messages with every other peer on the network. To implement peer-to-peer networking on AsyncNetwork, you may either use the AsyncBroadcaster or have every peer instantiate an AsyncServer and a AsyncClient.

    With the AsyncBroadcaster messages can be send to all peers on the same subnet. The broadcaster can only send binary data (NSData) and it is not guaranteed that the data arrives in order.
    ...
    From the name of one of your properties (self.broadcaster.broadcastSocket), it looks like you're using broadcasting. Unfortunately, the above reference says "on the same subnet", which necessaril implies "not across the internet".

    Also, it's unclear what routers or gateways you're going through. Some of them might not handle multicast (Bonjour) or broadcast properly.

    Without knowing more details about exactly what's on the wire going over the internet, I don't see an easy way to diagnose the problem. The posted code is too abstracted from the low-level "over the netwrk" layer.

    There's no data about what's on the wire on the local subnet (LAN), so no one knows what to expect if those packets are sent over the internet. Get a tool like wireshark or tcpdump, and look at the actual packets, so you understand what data is going where. Then work up from there.
     

Share This Page