Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Best networking library?

This thread is locked; no one can reply to it. rss feed Print
Best networking library?
Kibiz0r
Member #6,203
September 2005
avatar

What's the best library for networking if I want to be able to both send data back and forth quickly as well as download complete files to the client?

A J
Member #3,025
December 2002
avatar

All of them. 8)

___________________________
The more you talk, the more AJ is right. - ML

Kibiz0r
Member #6,203
September 2005
avatar

Owned by ambiguity.

Thanks anyways. :P I decided to use Zoidcom btw.

GullRaDriel
Member #3,861
September 2003
avatar

Socket or Winsock library.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Milan Mimica
Member #3,877
September 2003
avatar

ziglite is my favorite. Altought it says it's a game engine, you don't have to use all of it's features.

BAF
Member #2,981
December 2002
avatar

adamk kromm
Member #5,432
January 2005

HawkNL is a good pretty low level multi platform library.
www.hawksoft.com

----------
-Adam Kromm

My Website

James Stanley
Member #7,275
May 2006
avatar

I'm using DyConnect in my currently-in-development game.

GullRaDriel
Member #3,861
September 2003
avatar

You all use socket/winsock based library. Why not use the first original library ? It will help you understanding the behaviors of networking.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

BAF
Member #2,981
December 2002
avatar

Higher libraries such as Raknet implement UDP for you which gives you more efficiency, debugged code, etc. For TCP, there's not much efficiency with that, so I'd just use socks for that.

Myrdos
Member #1,772
December 2001

Quote:

For TCP, there's not much efficiency with that, so I'd just use socks for that.

Huh? TCP/IP is quite efficient, in terms of network resources used. Or did you mean that it can have increased latency? In TCP/IP, the only 'inefficiency' is that packets that were dropped due to congestion or interference are re-sent. If you aren't interested in reliability, this is a waste.

For example, in a game you may only want to know the most recent x,y coordinates of the other player. Re-sending stale coordinates makes no sense. If you're going to send coordinates, you'd might as well send the current ones. In this case you'd be better off using UDP.

So TCP/IP isn't inefficient exactly, but you have to be willing to wait for dropped packets to be re-sent. Though I notice commercial games seem to use TCP/IP anyways.

Quote:

I'm using DyConnect in my currently-in-development game.

Hey, no kidding! :) I just released a new version of DyConnect a few days ago, though I'm sad to report that I ended up breaking backwards compatibility. :-/ It's mainly a matter of using NetworkEngine objects instead of DyConnect ones, and specifiying your own buffer size in UDPSock. This should be the last time backwards compatibility is broken, from now on I'll concentrate on adding support for more OSs, maintenance, bug fixes, clarifying the documentation, etc.

__________________________________________________

CursedTyrant
Member #7,080
April 2006
avatar

I have to agree with BAF that RakNet is a rather good, simple (yet efficient) and well documented library/engine/whatever.

---------
Signature.
----
[My Website] | [My YouTube Channel]

Seppl
Member #4,656
May 2004
avatar

Quote:

I decided to use Zoidcom btw

I can recommend this library. Many features, easy to use, but unfortunately my favorite feature (automated bool replication) does not work yet (v0.6.3) :'(

__________________________________
All you need is lunch - The Rutles

Billybob
Member #3,136
January 2003

Quote:

Huh? TCP/IP is quite efficient, in terms of network resources used. Or did you mean that it can have increased latency? In TCP/IP, the only 'inefficiency' is that packets that were dropped due to congestion or interference are re-sent. If you aren't interested in reliability, this is a waste.

TCP/IP is inefficent in that it is designed inefficently. The protocol was designed years ago. Networking libraries like Raknet recreate TCP over UDP, but in a more efficent way. Smaller headers, and such.

GullRaDriel
Member #3,861
September 2003
avatar

In My Humble Opinion:

William said:

...Networking libraries like Raknet[reinvent the wheel] recreate TCP over UDP, but in a more efficent way[In a way you use because you do not know how to correctly use socket]. Smaller headers[not even smaller than a simple RAW packet], and such.[what such ?]

You make me smile when you talk about TCP header and all those stuff.
Where do you see a game with a packet/pixel-moved update ?
All games usually only use between 3-10 updates / second. Are you really gonna send more than 1000 octets/update ? No, of course.

Even a 56k modem is enough for a playing a networked game. The only thing who is going to bore you is the evil 56k latency. UDP will not really help, because latency is not only a question of used protocol, and it doesn't not matter

In those days, I think there are more ADSL-like users than ole-56k ones.

UDP is not reliable trough the internet. Many router/FAI just drop UDP packets. Many Enterprise do not allow UDP. And some also do not allow TCP.

Raknet, Libnet, whatever-you-want-to-use-as-a-networking-library, is just a matter of personal network-coding taste.

There is nothing quick than the socket themselves. If you really need speed, do your own wrapper.

And notice that WOW is not using UDP but TCP. Can you say you notice something different before knowing that ?

A nicely-coded TCP application can be more efficient than the same using UDP.
A nicely-coded UDP application can be more efficient than the same using TCP.

I always remember a sentence I read somewhere in the forum, and it makes me feel this one: A good algorithm && simple socket is from far better than a bad one using any network wrapper.

I do not flame anyone, and I do not say use this or that. I say do not post some so light advisement as use this one because it is quicker than this protocol.

You can drive a Ferrari at 1 mph, and a fiat uno at 100 mph. The only difference is how you are going to use each one :-)

Hmm. I must be fool today ;D

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Myrdos
Member #1,772
December 2001

William said:

Smaller headers, and such.

Well... as I recall, the UDP header is 8 bytes long, where a normal TCP/IP header is 20 bytes long. So you're talking about a potential saving of 12 bytes/packet, minus whatever you're using to implement reliability over UDP. For the sake of argument, let's say you're able to do this with no overhead.

To get the most efficiency, you'd want to use the maximum ethernet payload size of 1500 bytes, minus the size of your TCP or UDP header. This will let you send the most amount of data with the least amount of headers. Here is a useful site where this is calculated for you:

1TCP over Ethernet:
2 Assuming no header compression (e.g. not PPP)
3 Add 20 IPv4 header or 40 IPv6 header (no options)
4 Add 20 TCP header
5 Add 12 bytes optional TCP timestamps
6 Max TCP Payload data rates over ethernet are thus:
7 (1500-40)/(38+1500) = 94.9285 % IPv4, minimal headers
8 (1500-52)/(38+1500) = 94.1482 % IPv4, TCP timestamps
9 (1500-52)/(42+1500) = 93.9040 % 802.1q, IPv4, TCP timestamps
10 (1500-60)/(38+1500) = 93.6281 % IPv6, minimal headers
11 (1500-72)/(38+1500) = 92.8479 % IPv6, TCP timestamps
12 (1500-72)/(42+1500) = 92.6070 % 802.1q, IPv6, ICP timestamps
13 
14UDP over Ethernet:
15 Add 20 IPv4 header or 40 IPv6 header (no options)
16 Add 8 UDP header
17 Max UDP Payload data rates over ethernet are thus:
18 (1500-28)/(38+1500) = 95.7087 % IPv4
19 (1500-28)/(42+1500) = 95.4604 % 802.1q, IPv4
20 (1500-48)/(38+1500) = 94.4083 % IPv6
21 (1500-48)/(42+1500) = 94.1634 % 802.1q, IPv6

So we're talking about 95.7087% for UDP over IPv4 minus 94.9285% for TCP/IP which equals a difference in efficiency of 0.7802%. Not big potatoes, here. And of course, the actual difference will be less because there will be some overhead for reliable UDP.

William said:

The protocol was designed years ago.

Wikipedia said:

TCP is both a complex and evolving protocol. However, while significant enhancements have been made and proposed over the years, its most basic operation has not changed significantly since RFC 793, published in 1981. RFC 1122, Host Requirements for Internet Hosts, clarified a number of TCP protocol implementation requirements. RFC 2581, TCP Congestion Control, one of the most important TCP related RFCs in recent years, describes updated algorithms to be used in order to avoid undue congestion. In 2001, RFC 3168 was written to describe explicit congestion notification (ECN), a congestion avoidance signalling mechanism. In the early 21st century, TCP is typically used in approximately 95% of all Internet packets. Common applications that use TCP include HTTP/HTTPS (World Wide Web), SMTP/POP3/IMAP (e-mail) and FTP (file transfer). Its widespread use is testimony to the original designers that their creation was exceptionally well done.

I tend to agree with the opinions expressed in this summary. :)

__________________________________________________

Matthew Leverton
Supreme Loser
January 1999
avatar

The more you talk, the more AJ is right.

Billybob
Member #3,136
January 2003

Quote:

The only thing who is going to bore you is the evil 56k latency. UDP will not really help, because latency is not only a question of used protocol, and it doesn't not matter

With UDP you send the packet one way. TCP, the has to be an acknowledgment of the packet back from the client. So latency is cut in half. Yes, you lose packets, but you could care less for updates packets.

And what about MMORPGs? That'll eat the tiny 5KB/s of dialup several times over. Counter-Strike: Source is using up to 15KB/s in, 5KB/s out. Dial-up can't even come close to handling that. Sure, you can drop the update rate, but then good luck shooting people.

Myrdos
Member #1,772
December 2001

Quote:

So latency is cut in half.

Again, this is false. TCP/IP will continue to send packets before the ACK for the current packet has been received. You would only get a significant increase in latency if a packet is actually dropped, and needs to be re-sent.

http://en.wikipedia.org/wiki/Fast_retransmit

Quote:

The more you talk, the more AJ is right.

I'm cool with that. 8-)

__________________________________________________

BAF
Member #2,981
December 2002
avatar

Quote:

UDP is not reliable trough the internet. Many router/FAI just drop UDP packets. Many Enterprise do not allow UDP. And some also do not allow TCP.

I do know some routers drop UDP, but most aren't that evil. And as far as Enterprises not allowing UDP.. it is probably against the policy to play games on theri computers anyway, so that shouldn't matter much. 8-)

GullRaDriel
Member #3,861
September 2003
avatar

BAF said:

it is probably against the policy to play games on theri computers

That's why I have a nice http-tunnel at my work ;-) ( not so nice for gaming, but for chatting it is nice)

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Dustin Dettmer
Member #3,935
October 2003
avatar

I reccommend the BSD socket library, it seems to work pretty well and is fairly well supported.

Last I checked

Go to: