Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Fri Dec 15, 2017 7:45 pm

All times are UTC




Post new topic  Reply to topic  [ 21 posts ]  Go to page 1 2 Next
Author Message
 Post subject: Network code bug
PostPosted: Mon Aug 09, 2004 12:31 am 
Offline
Engineer
Engineer

Joined: Mon Aug 09, 2004 12:08 am
Posts: 1
Hi,

if found the network code bug that results in random disconnects i think.

The Problem is, that the code thinks, that the data stream is continuous, but it isn't. The network connection is made via udp, which has the feature to not resend lost packages.

So, there are two possible ways to fix:

Use TCP instead of UDP. But this is not a good solution. The most games use udp, because the resend of the package would be outdated anyway.

Instead the code need more error checks. First of all, all packages have to be signed by a prefix magic and a suffix magic plus checksum.

A package starts with a magic, this could be a char with suffix checksum check or a string like "oTtdS". Without suffix checksum, a single char isn't enough. But i suggest:

byte magic
byte packet_len
byte type
byte packet[packet_len]
byte magic
byte chksum[4]

checksum algorithm could be something like crc32, not to strong because we don't need cryptographic security :)

the parse method looks for the next magic, then checksums from packet_len to packet[packet_len]. Looks for the magic and compares the checksums, if the are vaild, continue.
If the checksums doesn't match, search for the next magic and discard everything before the new magic.

Using UDP does also require to resend updates, the server can't assume the client state.


Top
   
 Post subject: Re: Network code bug
PostPosted: Mon Aug 09, 2004 8:30 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Sat Aug 16, 2003 12:55 pm
Posts: 768
Location: Bonn, Germany
poelzi wrote:
if found the network code bug that results in random disconnects i think.

The Problem is, that the code thinks, that the data stream is continuous, but it isn't. The network connection is made via udp, which has the feature to not resend lost packages.


UDP is only used to find the server on a network. The game runs through TCP. And TCP is perfect for this, because no data is lost and a little lag does not hurt, because OpenTTD is not a close combat type of game. I haven't looked into the desynch problem yet, but if you have a fix, it's of course greatly appreciated. :D

_________________
"There's a readme that comes with the source. I suggest you read it."
- Korenn


Top
   
 Post subject:
PostPosted: Tue Aug 10, 2004 2:36 pm 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Wed Feb 04, 2004 11:24 pm
Posts: 389
Desynching seems to happen very often as it switches from one month to the other. I first thought the monthly autosave (almost required in net play) was causing the problem... so we both turned it off but I was still getting disconnected... so my next guess is the difference in computing power (dual P3 733MHz vs. P4 2.5GHz) is the likely cause... would there be some way for the client that is "ahead" of everyone to wait a few frames... just to resynch the game?

_________________
Siggy not gonna work unless someone allows javascripting...


Top
   
 Post subject:
PostPosted: Tue Aug 10, 2004 7:39 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Jan 06, 2004 6:38 pm
Posts: 2451
Location: Kaunas, Lithuania
I already suggested that developers could make the lan game like in starcraft were the slowest performing pc dictates the speed that others folow so there would not be any desynch.
And you can get an example of that multiplayer in c coding here: http://www.relic.com/rdn/index.php register and download the homeworld source it should contain multiplayer.c or something like that the code is in c and the game's multiplay runs in a way that i said before :wink:


Top
   
 Post subject:
PostPosted: Tue Aug 10, 2004 8:11 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sun Apr 18, 2004 8:27 pm
Posts: 1228
I also think desyncs might have something to do with differences in computing power. For example if you have the server on a fast PC (e.g. 2ghz processor) the game will run at a speed that is good for that computer, but if a client is an old PC (e.g. 200mhz processor) with full detail options on it may not be able to keep up with the speed at which the server is running.

The way in which (I think) the game is kept in sync is by syncing the random seed number and the server sending out to the clients what frame it is on. This only happens every few frames though rather than every frame. I don't really know how the frame system affects gameplay but if the client is a few frames behind the server I don't think it would hurt to skip a few, or if it is ahead to wait a bit.

I will do some more experimenting to see if I can find anything out because this is one of the most annoying and on-going bugs in the game that still hasn't been solved....

_________________
No longer active here, but you can still reach me via email: luca[at]stackednotion[dot]com


Top
   
 Post subject:
PostPosted: Thu Aug 12, 2004 12:01 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sun May 23, 2004 1:19 pm
Posts: 27
Location: Germany
I can tell it is not a problem with fast and slow machines.
Just sync the settings and use axactly the same version and
everything is fine. Just played about 3 hours with a friend:
Duron 500MHz vs. Athlon XP 2500+ ;)


Top
   
 Post subject:
PostPosted: Tue Aug 17, 2004 2:32 pm 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Wed Feb 04, 2004 11:24 pm
Posts: 389
Hrm... did some thinking and I'm not sure if it's entirely cpu power related.... been running on fast mode occasionally with a friend of mine... even with 3 people... no desynch (large rail networks for each player)... yet it still randomly lets people desynch on normal speed.

_________________
Siggy not gonna work unless someone allows javascripting...


Top
   
 Post subject:
PostPosted: Tue Aug 17, 2004 5:14 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Thu Aug 05, 2004 8:54 pm
Posts: 307
Location: Oregon, USA
I tried fast forward with 1 other person and it desync'd me the next month.....although we were having desyncs A LOT on normal speed too...but fast forward seemed to trigger it. Is fast forward even officially "supported" for multiplay?


Top
   
 Post subject:
PostPosted: Tue Aug 17, 2004 5:54 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Mar 26, 2004 1:27 am
Posts: 1628
Location: Netherlands, Enschede
the speed of the different computers in a network game is totally insignificant. The server synchronises the game state before allowing things to continue so it will automatically go at the speed of the slowest computer/connection combination.

I played in an 8 player game on the internet for hours where most players were in brittain and using a modem dial-up. there was maybe 1 desync, but that player reconnected and all was fine again.

_________________
Creator of the Openttd Challenge Spinoff, Town Demand patch
The path to riches, a report on playing on a daylength server on ultra hard mode.


Top
   
 Post subject:
PostPosted: Tue Aug 17, 2004 11:06 pm 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Wed Feb 04, 2004 11:24 pm
Posts: 389
You sure about that Korenn? I played it even on a 100Mbit LAN connection (computers side by side) with both comps running past the 1.5GHz... yet still I got randomly desynched every 20-30 minutes or so.

_________________
Siggy not gonna work unless someone allows javascripting...


Top
   
 Post subject:
PostPosted: Tue Aug 17, 2004 11:42 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Mar 26, 2004 1:27 am
Posts: 1628
Location: Netherlands, Enschede
very sure. although that was the official release, not the nightly build, and the nightly build is not garantueed bug free.

_________________
Creator of the Openttd Challenge Spinoff, Town Demand patch
The path to riches, a report on playing on a daylength server on ultra hard mode.


Top
   
 Post subject:
PostPosted: Wed Aug 18, 2004 6:43 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Sat Aug 16, 2003 12:55 pm
Posts: 768
Location: Bonn, Germany
Fast forward is not supported in multiplayer games.

_________________
"There's a readme that comes with the source. I suggest you read it."
- Korenn


Top
   
 Post subject:
PostPosted: Wed Aug 18, 2004 2:18 pm 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Wed Feb 04, 2004 11:24 pm
Posts: 389
Not supported true... but working for sure... but hell, the entire networking feature is not supported (reason why the 2 player button don't work)

_________________
Siggy not gonna work unless someone allows javascripting...


Top
   
 Post subject:
PostPosted: Wed Aug 18, 2004 8:34 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Thu Aug 05, 2004 8:54 pm
Posts: 307
Location: Oregon, USA
}T{Reme [Q_G] wrote:
Not supported true... but working for sure... but hell, the entire networking feature is not supported (reason why the 2 player button don't work)


Yeah took me alittle bit to figure out the command line way to get it running :)


Top
   
 Post subject:
PostPosted: Thu Oct 28, 2004 4:03 pm 
Offline
Engineer
Engineer

Joined: Mon Oct 25, 2004 3:14 pm
Posts: 8
Location: Bratislava Slovakia
i tryed openttd over internet but i was immedietly disconnected and i dont know why??
I have Duron 1800 and 2 MBit connect and my friend has got Athlon 2000+ and 1 MBit.
We have the latest version 0.4.0.
What about that?


Top
   
 Post subject:
PostPosted: Thu Oct 28, 2004 4:16 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Feb 24, 2003 6:45 pm
Posts: 3053
Location: Hong Kong
Wow, 0.4.0 :D Can you send it to us? Then we can just do an immediate update from 0.3.4 to 0.4.0 and not go through this process is lots of work to do :P
Anyways, 0.3.4. network is really buggy unfortunately. You can try the SVN version; but pretty soon a new network is out that will be a lot and lot better!

_________________
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."


Top
   
 Post subject:
PostPosted: Thu Oct 28, 2004 5:42 pm 
Offline
Engineer
Engineer

Joined: Mon Oct 25, 2004 3:14 pm
Posts: 8
Location: Bratislava Slovakia
ooooops ;)
sorry i have mistaken :)
ill try svn but i dont know how to get it ... are that only source codes? or is there a compiled version?


Top
   
 Post subject:
PostPosted: Thu Oct 28, 2004 7:25 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Feb 24, 2003 6:45 pm
Posts: 3053
Location: Hong Kong
2 magic words: nightly build

(look in General OpenTTD)

_________________
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."


Top
   
 Post subject:
PostPosted: Fri Nov 12, 2004 2:29 pm 
Offline
Engineer
Engineer

Joined: Mon Oct 25, 2004 3:14 pm
Posts: 8
Location: Bratislava Slovakia
hmm doesnt work :(
What about new version? ;)


Top
   
 Post subject:
PostPosted: Fri Nov 12, 2004 4:05 pm 
Offline
Director
Director
User avatar

Joined: Fri Jul 02, 2004 10:56 am
Posts: 574
We are just preparing a completely new network code, and we have high hopes there will be a release with it this month.

Celestar


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 21 posts ]  Go to page 1 2 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.