Network Programing - What Options are out there?

BlitzMax Forums/BlitzMax Programming/Network Programing - What Options are out there?

beanage(Posted 2010) [#1]
Hey,

preffering ease of use over multitude of features, and stability over performance, what are my options networking-wise?

Has anybody experience with the dozens of networking libs and code snippets that are out there for Bmx? What about the standard BlitzMax Networking Module (Gnet)?

Thank you very much,


Czar Flavius(Posted 2010) [#2]
There was another post like this recently. My input was that I prefer Raknet. Unfortunately it goes for multitutde of features over ease of use, but it has both stability and performance.


beanage(Posted 2010) [#3]
Is RakNet cross-platform?


beanage(Posted 2010) [#4]
I haz it now. It seems somewhat like what I've been looking for. Thanks for the hint.


Czar Flavius(Posted 2010) [#5]
It can be a bit awkward to get going, look at Brucey's examples. But it is VERY reliable and fast.


Tibit(Posted 2010) [#6]
Take a look TNet, I'm not 100% sure but it might just be the EASIEST TO USE use network library in the world :P

Supports TCP & UDP at the same time. Works on all bmx plattforms. A very long time since I update this, however I know it works since there are people except me using it atm.

TCP CLIENT TEST


TCP SERVER TEST


You need to download these 5 source-files and put them in the same folder as the examples.
TNetBASIC_Source1.20v2.zip
Manual here:
List of Commands

Whatever the site says - it is now 100% FREE to use for whatever you want :)

An total rewamp are coming in a few weeks time. I'm going to use the new version in my actionbased-multiplayer game myself so there will be "support" so to say if you need help. Moreover if you start with the "old" TNet it should be pretty easy to upgrade to the new version when it ships.

Last edited 2010


wmaass(Posted 2010) [#7]
Thanks for the heads up on that Tibit, looks like it will be very useful for some stuff I have in mind.


wmaass(Posted 2010) [#8]
Wow...I was cruising along with this, it was really going to help a lot and then BAM! Mister router ruins the party. sigh.


Tibit(Posted 2010) [#9]
Maybe there is a solution. I'm not sure about how big your experience with routers is, but...

The most common issue is that people want to host a game when they are behind a router and allow people outside connect to you.

This can be fixed in two ways.

1. go to the Admin Panel on you router (usually http://192.168.0.1/ or similar) and forward a port (external) to a (internal) port on your specific machine, meaning you must MAP the external port to your computer's internal IP & port.

Let people outside your network/LAN connect to your External IP (see http://www.whatismyip.com/ )
Let people inside your network connect to your internal IP (the one you get from TNet)
Both using the forwarded port.

2. Use hole-punching to get a connection going. It is quite easy to do, I can explain more if you need help with it, the major issue here is to realize that you must deal with the LAN in separate.

Routers can cause a lot of other problems as well. Corporate and Academic network sometimes block incoming UDP, meaning you must use TCP in that case.


wmaass(Posted 2010) [#10]
Thanks Tibit. Unfortunalety my customers likely would not know how to deal with their routers, or would be unwilling to do so.

I have another way to allow my applications to exhange data over the Internet though. I'm just going to use MySql to pass data between applications. I don't need anything super fast so this should work well.

I have other stuff that would be used more often on a LAN. In these cases using TNet is no problem.

I love to hear more about about hole punching.


Last edited 2010

Last edited 2010


Tibit(Posted 2010) [#11]
Are you using a web-server that your user's can pass data to and then other users can grab data from the same web-server?

In case this is your own server, then you can simply connect to it directly, and transfer (route) the data that way. I mean SQL is using TCP.

Hole punching do require that you have a server that can relay information, such as a webserver.


dmaz(Posted 2010) [#12]
@Tibit, TNet... is the "total rewamp" TNetX that's talked about on the forum or something new?


Tibit(Posted 2010) [#13]
It is something new, built from scratch and right now it has a realiable UDP implementation that you can adjust the aggressiveness of (latency vs bandwith) depending on the tempo (action/strategy/puzzel/chat/).

I'm not sure what to call the library for though :)

A few weeks, I'm finishing my physics library first and it is looking awesome atm, and after that I'm doing some gameplay programming, then I'm doing the TNet stuff, so in 3-5 weeks something.


wmaass(Posted 2010) [#14]
Tibit,

I'm not up too speed on this stuff so sorry if this sounds noobish.

Yes I would be using my own server to pass data via MySql. Are you saying that my server can facilitate TCP communication between 2 computers without MySql? I suppose this is how multiplayer games work these days. I guess there would be some application on the server that handles the data between the computers, like a Halflife server, etc.


Tibit(Posted 2010) [#15]
No worries, you can't know everything for starters. What is it that you are trying to do?

On a side note, do you have the ability to install "anything" on that server or are you using a 3rd party for the hosting so that you only get a limited feature set?

It sounds to me that you are doing a similar thing that I will do later on, which is to setup a "portal" that users can connect to and then chat and find games.


wmaass(Posted 2010) [#16]
First I must say that the server does not yet exist, but I have the means to get it, either at my office or co-located.

Here are the basics of what I have in mind:

I have a small app that runs on a golf simulator PC and collects data from it. It simply parses external files that the simulator creates for data such as ball speed, ball spin etc for golf shots that are hit in the sim.

Then I have a collection of "apps" that users can download to run on their laptops or other PCs that use the data collected by the app running on the sim. The apps re-purpose the data in various ways. For example there is an app that suggests the best golf ball to buy, one that provides golf lesson content.

The way I do it currently is I simply share a folder on the sim PC and my apps read data via text files from that shared folder. I have an app running at the Golf Channel studio that does this to display shot data on tv.

The ideal setup is to get the data from the Internet. This way I can create apps that run on many platforms if desired and it makes it easier for end users to use the apps - they don't have to know how to setup shared folders, etc.

Make sense?

Last edited 2010


Galaxy613(Posted 2010) [#17]
How well will that TNet code do for a 2D space trading/combat multiplayer with asteroids-like physics? I suppose I'll have to do a lot of dead reckoning to try to make the movements smooth, but is the code robust enough for something of that complexity? Because there will be many systems with people flying, shooting, and landed on planets at the same time...


Tibit(Posted 2010) [#18]
@wmaass

I would setup a server that the collection-app (client) can connect to, this server must use an "static" ip (or dns), that is built into the application. On this static-p server I would have my little "collection" app (server) running so that my users can *login* to using their collection-app (client), auto-upload those files, print when done. That would be quite straight forward to do. On the other end, your other apps would then connect to this same server, login and then check for when the "latest" files where uploaded and check that against the files present on the hard drive, if new files exists on the server, do a backup of the old data then download the new data through the app. I would use TCP for this, and simply chunk the file into 500byte chunks and when the file transfer is 100% I would save the file to the hard drive.

It does depend on how "stream lined" your requirements are. However this is the way I would do it since I think it would be the simplest solution:
In my collection app, the one running on the simulator I would have a button called "upload files to server". Clicking this would open a website that I would have coded using php, and it would contain a "browse" button and a few lines of instructions, and a login if you need to identify users. Coding this in php (tweak, copy & paste a sample from google) should not take more than a couple of hours - it's like a 3line php-program. My desktop apps would have a button "get data online" and clicking it would open a webpage where they can login and see all their uploaded files, each having a "save as.." button. I'll instruct them to save the file in a specific folder in the application directory. This would remove the need for a static ip, and it would work on any plattform, even smart-phones, downside is that it is not as user-friendly and way less smooth.


Tibit(Posted 2010) [#19]
@ Galaxy631

TNet is built for 2D action-games, asteroid style. That's what I'm doing myself atm. There are even samples in old TNet that shows how you can do solid dead-reckoning for an Asteroid game, I even use a triangle-shaped ship, no kidding ;)

What is the limit of TNet?

In Blitzmax, I only managed to send and receive 25 000 packets/second LAN and 6300 pack/sec on wireless. I have no idea where this limit comes from though. In C# I get ~45 000packets/sec (LAN) using non-blocking sockets and no threads (same as I do in blitzmax), and ~70000 packets/sec using the new asynchronous IO support in .Net 3.5, and in C++ using boost's overlapping IO I have seen up to 100 000 packets/sec.

This limit is important if you are making an wow-sized MMO, since it would limit how many players you can have versus the responsiveness of the gameplay, but only for the Server, the client should be fine. However the CPU drain was low and should not be a problem even during high-loads. You game's logic will (should) be the limit here.

What determines lag-free-ness is like you said, how you deal with latency-spikes. Do you "teleport" the player or smoothly move them towards that location over time, allowing the players to be out-of-sync. Dead-reconing, interpolation, let shots and ships accelerate, add a cast-bar, charge-time or other short delay for your attacks and abilities.


Galaxy613(Posted 2010) [#20]
Thanks for the very fast response!

Is the 25,000 packets/second limit just for a single running application? Or could I possibly cut the server up into different applications running on different ports and switch between them? A even better question would be could I possibly make the server in C++ and still have it interface with the BlitzMax client?

Either way, I don't envision more than 32 players at a time right now.

The reasons for these questions is what I tried to use GameNet to do a test but it failed pretty bad once I had more than 4 people on the server. I need to go find that the old TNet example you talked about because I think I remember something like it. I think the issue was that GameNet likes to constantly be updating objects across all connected applications, ignore the cilent/server hierarchy.


wmaass(Posted 2010) [#21]
Good info Tibit, thanks so much.

FYI, things are coming together with my little venture, might need to tap into some of the talent around these forums. I've a feeling I'll have more work than I can handle, I'd love to contract help.


Tibit(Posted 2010) [#22]
wmaass, I do some minor contract work on the side, mail me at patrik@... and we can discuss further.

Galaxy613, yeah the limit is only for a single app. However TNet aside, consider the hardware limits you face whatever network lib you use:
Assume your player limit is 32 players and you send data 10 times/sec, that is an passive update every 10th sec. 32 players means 10*32 packets per sec IN to the server, that is 320 packets/sec in total. Assuming a packet size of 50 bytes then you have a bandwidth cap of 16 000 bytes/sec = 15 kb/sec down. The server then must send this data (in case you do no interest management) to all clients, which means 15kb*32 OUT, which is 500kb/s up.

For comparison:
Cable (256+ Kbps)
DSL (256+ Kbps)
Satellite (50 - 1500 Kbps)
ISDN (64 - 128 Kbps)
Dial Up (28.8 - 56 Kbps)

Upload is usually much lower than the max download. So you might not want to have the server on a crappy DSL connection, but a player should have no problems connecting to the server over one.

To reach the TNet limit you must have a very good line since 25k packs/sec @ 50 bytes each is 1200kb/s, which is 9 Mbit/s. However this limit is only a factor for the server, and it is not obvious that blitzmax is the best choice for writing a large server solution in anyway.

Of course there are hundreds of things you can optimize that will reduce packet size, packets/sec and latency. Often the simplest and best of such optimizations is to make it a part of the game's design :)