Sign in to follow this  

UDP - Peer 2 Peer

This topic is 3551 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've created a method for tcp where the server would give data to the client. But, on top of that, I wanted to create a secondary-method of sending unimportant data to clients from other clients. (really just things like x,y etc..) Anyway, I'm unsure where to start on such a project. Really, I'm kind of confused how udp works that differs it from tcp (besides the unreliability, and packet-loss)

Share this post


Link to post
Share on other sites
Quote:
Original post by KuJi
I've created a method for tcp where the server would give data to the client. But, on top of that, I wanted to create a secondary-method of sending unimportant data to clients from other clients. (really just things like x,y etc..)
I would advise against that as it makes the system very exploitable. Especially if players decide to not send information to other players. If a client decides not to send information to other clients then it could wreck the game. But I guess it depends on what kind of game.

You should have no problem with sending all the data to the server and having the server handle what everyone gets.

Are you sure you want to go on with this idea?

Quote:
Original post by KuJiReally, I'm kind of confused how udp works that differs it from tcp (besides the unreliability, and packet-loss)
Did you read the wikipedia article? The header size is different and unordered. Packets can reach the destination before packets before that packet. Basically as you mentioned packets aren't expected to get to their destination. This makes them awkward at sending things like login information or important commands that are expected to get their destination. However UDP can be used in such a way that it mimics TCP allowing for reliable packets and ordered/unordered and everything.

You need to decide what your game needs. While UDP is faster, it's not exactly that big of a difference that would make it a choice over TCP. (I've used UDP and TCP for small games, and just ended up using TCP for everything since the difference isn't really a problem).

Share this post


Link to post
Share on other sites
Quote:
Original post by Sirisian
I would advise against that as it makes the system very exploitable. Especially if players decide to not send information to other players. If a client decides not to send information to other clients then it could wreck the game. But I guess it depends on what kind of game.

You should have no problem with sending all the data to the server and having the server handle what everyone gets.

Are you sure you want to go on with this idea?


Well, it's more of an option. The clients will be able to choose udp or not, the only clients who will peer-2-peer are clients who both have UDP on. The others will get the TCP-data from the server.

Share this post


Link to post
Share on other sites
You should probably read the Forum FAQ entry on NAT punch-through. It explains how NAT punch-through for UDP works, which you will have to solve for your peer-to-peer implementation; in doing so, it may also help you understand UDP better.

However, I wonder why you're doing this. Will the game be significantly more fun for the players if you implement this feature? Will you get a lot more players by implementing this feature? If the games works already, and UDP support does not make the game significantly more fun/more playable/more known, then you should probably focus on gameplay instead of technology.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
You should probably read the Forum FAQ entry on NAT punch-through. It explains how NAT punch-through for UDP works, which you will have to solve for your peer-to-peer implementation; in doing so, it may also help you understand UDP better.

However, I wonder why you're doing this. Will the game be significantly more fun for the players if you implement this feature? Will you get a lot more players by implementing this feature? If the games works already, and UDP support does not make the game significantly more fun/more playable/more known, then you should probably focus on gameplay instead of technology.


Speed for player-movement is kind of a focus in this game.

Also will look through that stuff, ty :)

Share this post


Link to post
Share on other sites
Hello pac30000000!

You want to use UDP because it's faster right? Well you can use it through a client-server model instead of peer-to-peer and still get lower latency. Just send the UDP packets to the server instead of directly to the other player, than let the server process and forward it. When the server forwards it however, make it forward it through the TCP socket because the client will not be able to receive a UDP packet unless his firewall/router is setup correctly. The client can still send UDP packets without worrying about firewalls and routers. Make sure the nagle algorithm is turned off.

For the method you described to work every client would need the IP address of every other client in the same level as you (security). Then the player just iterates through each of the other players in the same level and send the X/Y directly to their IP.

Share this post


Link to post
Share on other sites
UDP is significantly better for twitch games. I've also found that writing a reliable UDP wrapper (out of order but guarenteed delivery) works really well (and is easy) given the generally tiny level of packet loss experienced on all but the internet's worst days. Of course forwarding information through your server increases that over the p2p scenarios I generally deal with.

If you really want to get twitch factor in perhaps you could also send packets directly to clients and just timestamp them so they can discard ones arriving slower from the server?

One of your client connection criterias should be time since last UDP packet was received to prevent them finding exploits by blocking just UDP on their connection.

Share this post


Link to post
Share on other sites

This topic is 3551 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this