Introduction

Installation Please refer to the Compiler Setup page, as all your questions should be answered there. If you have additional problems please refer to the FAQ, http://www.rakkarsoft.com, or contact us. Advanced users can jump to the code tutorial. Beginners or those wishing to learn more about RakNet should keep reading. API Description RakNet is an advanced networking API that provides services for and over Berkeley Sockets, or on Windows systems "Winsock." It allows any application to communicate with other applications that also uses it, whether that be on the same computer, over a LAN, or over the internet. Although RakNet can be used for any networked application, it was developed with a focus on online gaming and provides extra functionality to facilitate the programming of online games as well as being programmed to address the most common needs of online games. Networking 101 Network connections fall under two general categories: peer to peer and client/server. Each of these are implemented in a variety of ways and with a variety of protocols. RakNet supports any topology, including peer to peer and client/server. Generally speaking, the fastest computer with the best connection should act as the server, with other computers acting as the clients. While there are many types of ways to encode packets, they are all transmitted as either UDP or TCP packets. TCP packets are good for sending files, but not so good for games. They are often delayed (resulting in games with a lot of lag) and arrive as streams rather than packets (so you have to implement your own scheme to separate data). No games worth mentioning use TCP, so we won't discuss it further. UDP packets are good because they are sent right away and are sent in packets so you can easily distinguish data. However, the added flexibility comes with a variety of problems: UDP packets are not guaranteed to arrive. You may get all the packets you sent, none of them, or some fraction of them. UDP packets are not guaranteed to arrive in any order. This can be a huge problem when programming games. For example you may get the message that a tank was destroyed before you ever got the message that that tank had been created! UDP packets are guaranteed to arrive with correct data, but have no protection from hackers intercepting and changing the data once it has arrived. UDP packets do not require a connection to be accepted. This sounds like a good thing until you realize that games without protection from this would be very easy to hack. For example, if you had a message that said "Give such and such invulnerability" a hacker could copy that message and send it to the server everytime they wanted invulnerability. The UDP transport does not provide flow control or aggregation so it is possible to overrun the recipient and to send data inefficiently. How does RakNet help me with these issues? At the lowest level, RakNet provides a layer over UDP packets that handle these problems transparently, allowing the programmer to focus on the game rather than worrying about the engine. RakNet can automatically resend packets that did not arrive. RakNet can automatically order or sequence packets that arrived out of order, and does so efficiently. RakNet protects data that is transmitted, and will inform the programmer if that data was externally changed. RakNet provides a fast, simple, connection layer that blocks unauthorized transmission. RakNet trnasparently handles network issues such as flow control and aggreggation. Of course, RakNet would be not much use if it handled these issues inefficiently such as by sending a lot of data, locking up, or making it hard to take advantage of these features. Fortunately, that is not the case. Unlike the majority of networking APIs: RakNet adds very few bytes to your data. RakNet allows you to turn off bandwidth consuming features that you don't need. RakNet has nearly instantaneous connections and disconnections. RakNet does not assume the internet is reliable. RakNet will gracefully handle connection problems rather than block, lock-up, or crash. RakNet technology has been successfully used by both commercial and freeware games. It's been proven to work. RakNet is easy to use. What else can RakNet do for me? Working at the level of packets is bandwidth efficient and gives you a great deal of control but is time consuming. RakNet provides two higher level layers to make networking easier: Distributed Objects and a set of synchronization functions. Most games share a common set of functionality, such as setting player limits, password production, and statistics. RakNet has large set of networking functions that are immediately usable and handled internally so they require no additional programming on your part. Lastly, RakNet includes a small set of programs that work in conjunction with your game, such as the master server or real time voice Here is a partial list of things you can do "out of the box." Synchronize class instances with two lines of code, allowing you to network game objects with a fair degree of control without writing a single packet. Implement low-bandwidth / high quality voice communications. Run a master server for players to find games on the internet. Utilize remote procedure calls, allowing you to call functions on other computers with variable parameters. Get statistics such as ping, packetloss, bytes sent, bytes received, packets sent, packets received, and more. Get a high precision synchronized random number seed so your random numbers can be in synch. Automatically transmission of per-system data on connection, allowing for easy handshaking. Optional per-packet timestamping so you know with a fair degree of accuracy how long ago an action was performed on another system despite ping fluctuations. Next page: System Overview

See Also

Index System Overview Detailed Implementation Tutorial Compiler Setup