'bout upd protocol
Blitz3D Forums/Blitz3D Programming/'bout upd protocol
| ||
Exuse i wrote this to use with a flash program but it seems pretty slow... Can you say me if't's correct, please? |
| ||
As far as I see you send each Character seperately. Someone correct me if I'm wrong, but shouldn't you send packets instead? I mean, sending UDP does require a handshake, and isn't it a waste of performance if you do that logical handshake for every single byte? I guess you can write the entire string to the stream, then send the UDP Message. Well, as I said, maybe I'm wrong here, it's some time ago since I did UDP stuff the last time. |
| ||
UDP doesn't require a handshake does it? AFAIK, that's TCP, not UDP. |
| ||
It does have some packet overhead though, so you should send packets of 50-500 bytes or so. |
| ||
There is no handshake for UDP. As a rule don't let your packet size go over 1500 bytes. I would design around 64, 128, 256, or 512 size packets. While you can send characters one at a time and cause many small packets there would be less overhead to send a whole line at a time. So buffer the characters till you get a carrage return. Hope this helps. |
| ||
so can i use Wruteline and readline instead? I tried to send charcter but it failed :p.... |
| ||
@Wayne I assume thats 1500 bytes per port? |
| ||
Per packet. You can only send a packet on one port at once. So for every SendUPDMsg() call, you should have written no more than 1500 bytes to the stream beforehand. |
| ||
As I understand it, every packet requires some kind of handshake, probably only a "hi, got packet" and "that's it". That's why I said "locical handshake", cause in UDP you'll have to detect transmission errors by your own and reorder defect packets. Isn't that a handshake? But maybe I interpret the term handshake too liberal. However, I meant the overhead when he's sending a single Byte as a message. |
| ||
@Frank 1500 Byte is the MTU of an Ethernetframe excluding Ethernet-header and not per Port. So, normally that's the maximum of a "frame". UDP it self is called a "connectionless protocol", so you have to care if the data arrives at the other node. For your Opensource FPS i suggest to send small packets. |
| ||
Chi3f Stadi, With the current network setup, I create a separate UDP port for each client (max 16). I'm using 8 bytes per game object (player, projectiles, moving platforms, etc) to update client-side mimics of the server game world. I capped the number of objects updated to 64. Thats a 512 byte update per client. Thats 512x16=8192 total bytes per update sync. So if I understand you correctly I would have to reduce the total bytes per update sync 1500 for optimum performance? |
| ||
No, that will work fine. EDIT: But you have to make sure you don't update stuff over the network too often. I use 4x per second for an MMO game. For an FPS you probably want about 10x per second. Think about it like this: If you have a 512k (broadband) connection, that's (512/8)*1024 = 65536 bytes per second. If you update 10x per second, you can send 6554 bytes per update, if you want your game to work on 512k or above. |
| ||
Thanks Guys for your thoughts. |
| ||
I would keep packet sizes under 1500 the least amount of packet overhead and greatest equipment compatability. It's probobly not necessary to have a bunch of ports open just to talk to other peers, because you get the remote IP address each time you receive a packet. I suppose if you want to use your router to monitor or control ports it might be handy to have ports open for each peer. My preference would be to send important position updates 10 times a second, and others less. Some game designers like to assign priorities to packets, and adjust the prioriries based on such things as TARGETED, RANGE, INVIEW.. Sending those packets first. The whole network game protocol thing can be complex and even the pro's don't get it right all the time. Take your time and enjoy. |
| ||
The whole network game protocol thing can be complex and even the pro's don't get it right all the time. Take your time and enjoy. wayne,I totally agree. Network programming is a totally new bag of worms. Concepts in rendering optimizations: bsp, portals, etc, are pretty solid. But, a new idea on how to deal with network lag pops up pratically every day. I taking my time and using techniques others have employed. |