Any thoughts on the best way to go about testing networking under varying conditions (packet loss, latency, etc.)?
I'm not finding any good external programs to help out.
Simulating Network Lag
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- josefnpat
- Inner party member
- Posts: 955
- Joined: Wed Oct 05, 2011 1:36 am
- Location: your basement
- Contact:
Re: Simulating Network Lag
The easiest way to simulate lag is to put a sleep in the server before responding. I suppose you could also do something along these lines:
Code: Select all
require "socket"
function sleep(sec)
socket.select(nil, nil, sec)
end
function handle_data(data)
sleep(0.120) -- 120 ms
if math.random(1,10)>1 then
-- properly handle the data
else
-- haha, packet loss!
end
Missing Sentinel Software | Twitter
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
Re: Simulating Network Lag
I'm trying to figure out what else I might be missing by simulating it only within Love.
I guess I'd miss potential problems with testing packets of different sizes, as I've seen large ones get dropped before....maybe. So far this is the most difficult part of networking, as I never have problems with LAN's, but there have been plenty of bugs reported in the wild.
I guess I'd miss potential problems with testing packets of different sizes, as I've seen large ones get dropped before....maybe. So far this is the most difficult part of networking, as I never have problems with LAN's, but there have been plenty of bugs reported in the wild.
Re: Simulating Network Lag
There are all kind of fun things you have to look out for. As an example, here's a quote from the luasocket reference about udpsocket:receive.
Linux has some tools to simulate stuff like that, but I forgot the name.If size is omitted, the maximum datagram size is used (which is currently limited by the implementation to 8192 bytes).
Shallow indentations.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Simulating Network Lag
And the worst part isn't fitting stuff in 8192 bytes, it's that what's sent with multiple send() calls can be received with one receive() call.
Re: Simulating Network Lag
If you've got OSX Lion and have installed Xcode then you already have a nice utility app called network link conditioner, I've been using it to test my RTS game.
It let's you change your bandwith, packet loss and latency.
http://joemiller.me/2011/07/25/network- ... -4-1-lion/
It let's you change your bandwith, packet loss and latency.
http://joemiller.me/2011/07/25/network- ... -4-1-lion/
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 84 guests