Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
179 views
in Technique[技术] by (71.8m points)

network programming - Router gets unresponsive when using UDP

I'm working on a multiplayer game. The principle is simple, each of the two players sends each other periodically 512 bytes every 50 milliseconds.

The problem is that about every 20-30 seconds players stop receiving data for sometimes one but sometimes even up to 20 seconds (though, sending had not been interrupted).

At first I thought that this is caused by a slow network connection on either my side or on the side of my remote PC which I use for debugging.

But then I noticed that all network traffic on my side slows down at the same times when the game stops receiving data.

So I started ping <my-local-router> and this is what it shows me:

When the game isn't running:
...
64 bytes from 192.168.1.1: icmp_req=4520 ttl=64 time=4.89 ms
64 bytes from 192.168.1.1: icmp_req=4521 ttl=64 time=7.96 ms
64 bytes from 192.168.1.1: icmp_req=4522 ttl=64 time=10.5 ms
64 bytes from 192.168.1.1: icmp_req=4523 ttl=64 time=7.21 ms
64 bytes from 192.168.1.1: icmp_req=4524 ttl=64 time=8.10 ms
64 bytes from 192.168.1.1: icmp_req=4525 ttl=64 time=3.37 ms
64 bytes from 192.168.1.1: icmp_req=4526 ttl=64 time=5.12 ms
64 bytes from 192.168.1.1: icmp_req=4527 ttl=64 time=3.29 ms
...
When the game is running:
...
64 bytes from 192.168.1.1: icmp_req=47 ttl=64 time=6.99 ms
64 bytes from 192.168.1.1: icmp_req=48 ttl=64 time=1.69 ms
64 bytes from 192.168.1.1: icmp_req=49 ttl=64 time=2.60 ms
64 bytes from 192.168.1.1: icmp_req=50 ttl=64 time=2.88 ms
64 bytes from 192.168.1.1: icmp_req=52 ttl=64 time=9210 ms
64 bytes from 192.168.1.1: icmp_req=53 ttl=64 time=17144 ms
64 bytes from 192.168.1.1: icmp_req=54 ttl=64 time=16214 ms
64 bytes from 192.168.1.1: icmp_req=55 ttl=64 time=15372 ms
64 bytes from 192.168.1.1: icmp_req=56 ttl=64 time=14482 ms
64 bytes from 192.168.1.1: icmp_req=57 ttl=64 time=13486 ms
64 bytes from 192.168.1.1: icmp_req=58 ttl=64 time=12511 ms
64 bytes from 192.168.1.1: icmp_req=59 ttl=64 time=11546 ms
64 bytes from 192.168.1.1: icmp_req=60 ttl=64 time=10591 ms
64 bytes from 192.168.1.1: icmp_req=61 ttl=64 time=9626 ms
64 bytes from 192.168.1.1: icmp_req=62 ttl=64 time=1.34 ms
64 bytes from 192.168.1.1: icmp_req=63 ttl=64 time=3.33 ms
...

It seems that the game is causing the router to become unresponsive.

I don't have any P2P running on my local PC, but that doesn't even sound relevant since I don't experience the slowback when the game isn't running.

I'm new to UDP programming and I'm getting clueless with this, especially since the 512 bytes every 50ms seems like quite a small bandwidth to me (when I do run P2P, it easily runs 1.5MB/s).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This might have been my router dying and needing a replacement or something fishy in my wireless drivers, as I've noticed more network freezes lately even at times when the application wasn't running.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...