SilabGarza - RS Private Server  
Home Forum Play Register Store Market Highscores Mark Forums Read
Go Back   SilabGarza - RS Private Server > SilGar Media > Computers > Programming
Reload this Page An explanation of how Winterlove (BlakeScape) works


An explanation of how Winterlove (BlakeScape) works
Old
  (#1 (permalink))
[[Whadafuxx]] is Offline
image
 
[[Whadafuxx]]'s Avatar
 
Posts: 1,811
Cookies Given: 0
Cookies Received: 0
Time Online: 17 d 21 h 16 m
Clan: Di
   
Default An explanation of how Winterlove (BlakeScape) works - 05-18-2010, 07:58 PM

I've decided that I'd help educate you guys with server development by teaching you exactly how the Winterlove server works internally (from the 10,000 foot view, of course). With the knowledge of how it operates, hopefully you should be able to write better code for it.
Let's get started!

The Listener - server
The listener is a thread that isn't paid much attention to in Winterlove, but infact if it weren't there, Winterlove simply wouldn't work. The Listener is something that listens for incoming connections to the server, and accepts them when one comes in. Once accepted, the listener instructs the PlayerHandler to make, store, and run a new client object. The listener is part of the "server" class, and operates as a standalone thread.

Code:
 loop:
    1. wait for an incoming connection
        A. accept when one comes in
        B. notify the PlayerHandler to create a new client
    2. loop back to the beginning
The Engine - PlayerHandler
The engine of the entire system is called the PlayerHandler. It is run in the server classes main processing loop, and runs at a rate of approximately 500 milliseconds. Packet processing has been thrown in with the engine and this creates problems when people spam the server with packets. The engine is structured like so:
Code:
loop:
    1. loop through every player
        A. process packets for each player (this is where game logic is handled - process() and parseIncomingPackets())
            a. loop and process each packet indefinitely until we have no more packets to process for this player, then move to the next player
        B. set necessary appearance/player-updating flags
    2. loop through every player (a second time)
        A. prepare update packet for this player
        B. loop through every player (inside this players loop)
            a. prepare update packet for this player for each player
    3. loop through every player (again)
        A. reset all updating flags that were set in loop 1
    4. wait 500ms minus the time it took to process (so timing stays accurate)
loop back to the beginning and start all over again
That entire process happens twice per second in Winterlove, however Winterlove servers have their timing tuned to operate slightly faster than the protocol was designed for - 500ms instead of 600ms. When the cycle time exceeds 600ms, players will experience server lag. Take a look at loop 1, step A->a, you will notice that it processes every packet that each player has at a time - this means that, if the player has 1,000 packets coming in (because somebody is spamming), it will process 1,000 times before it even moves onto the next player and eventually to the rest of the cycle. This is why spamming a Winterlove server can cause immense lag for every player, because you disrupt the timing system of the engine.

I/O Processors - client
When a connection is accepted by the listener, it starts a dedicated "client" thread for that player, which handles the login of the player and then processes all reading/writing with the socket stream. This means that every player has a dedicated thread for communicating with the game client end of the connection. A thread can be seen as a platform on which code can run independent of other code in the same computer process. This is an inefficient approach seeing as the threads use a lot of memory and they are sitting idle most of the time while the rest of the server is processing.

Miscellaneous Explanations
I will now take some time to explain some common things about how the Winterlove server operates and some of its problems.

Source of Crashes
If you are familiar with Winterlove servers, you know that they are incredibly unstable and unreliable because they suffer from server-wide crashes and therefore they need a restarter to restart the server every 30/60 minutes just incase it crashes. The common source of this problem is as follows:

When data is transmitted over the internet, it is sent in the form of "packets", or chunks of data that, in the RuneScape protocol, contain the following information:
opcode, size, data
Sometimes, however, random things will happen when the packet goes across the internet where it becomes "malformed", or messed-up. The server was not programmed with the capability to handle malformed packets in mind, so the server will attempt to treat the malformed packet as a regular packet, and chances are that the server will run into an error when it parses data that it doesn't expect. This would normally be okay, except for the fact that the engine has no handling of errors, also known as "exception handling" programmed into it - when the engine encounters an error, because it is not handled (which can be easily done), the engine thread will exit entirely and the server will crash.

Scalability
The Winterlove engine itself is relatively scalable, though it's implementation of processes are not very efficient (i.e. runs on a single thread while updating is read-only and therefore can be dispatched to a threadpool, update packet blocks are not cached when they easily could be, packet processing could be put into the IO threads to prevent the engine from being exploited with spamming packets, etc.) it is fast because it uses low-level resources to store players (an array instead of an arraylist) and is very procedural in nature. The design of having one dedicated thread for every player causes the server to use a lot of unnecessary memory and processing power, something known as "overhead", to manage all of the threads and this IO design counteracts the reasonably fast engine. In modern implementations of Winterlove servers (i.e. devo, etc) all of the game logic is piled on top of the packet processing, which exponentially increases the drawbacks of having packet processing handled inside the engine instead of making use of the dedicated IO threads (which should be used for packet processing anyways, seeing as they are networking threads). I would rate the original Winterlove source with a scalability of 6/10, but I would rate current implementations scalability as 2/10.

Extendibility
The server itself is not very easy to add onto, because it is not a very object-oriented design. The base itself is messy and very procedural, while it is written in a highly object-oriented language. This makes it difficult to work and develop with because the design is not very flexible. It only has one implementation of inheritance, and that is between the "Player" and "client" classes. On the plus side, the base itself has quite a lot of comments about how it works and about the protocol that one can learn from, although some of the comments on the protocol are incorrect.

Potential to Learn
Because the Winterlove base is very procedural (straight-forward) in design, it is easy to use as a tool to learn from, because instead of focusing on how objects work together and relate with each other, you can focus on the protocol and server design implementations and therefore I can say that the Winterlove base is a very good source to learn from through studying and tinkering-with.

Significance
The Winterlove base is very significant to the RuneScape Private Server community as a whole. It was the first multiplayer server ever released, and also included quite a bit of information about the (at the time of release) quite unknown RuneScape protocol. The Winterlove server is also the most common server base in use today, seeing as it is the core of 95% of running server projects. I believe the server was more of a proof of concept and research application instead of a commercial grade server. You can compare the Winterlove base and it's extensions (i.e. whitescape, cheezscape, etc etc etc) to the Linux kernel and it's distributions (i.e. Ubuntu, Fedora, etc etc etc) except for the fact that Winterlove was a proof of concept and was not made to run in a commercial scale environment while Linux is indeed the opposite. I believe it is being misused by being used as the base of almost every server that has ever existed, but it is not completely useless seeing as you can learn quite a bit from it

Credits to Blakeman8192 for creating this guide!
  
Old
  (#2 (permalink))
Asert One is Offline
Senior Member
image
 
Asert One's Avatar
 
Posts: 498
Cookies Given: 0
Cookies Received: 0
Time Online: 5 d 23 h 6 m
   
Default 05-19-2010, 03:08 AM

Winterlove is fantastic. Why are you posting these leeched things, make something yourself.
  
Old
  (#3 (permalink))
[[Whadafuxx]] is Offline
image
 
[[Whadafuxx]]'s Avatar
 
Posts: 1,811
Cookies Given: 0
Cookies Received: 0
Time Online: 17 d 21 h 16 m
Clan: Di
   
Default 05-19-2010, 03:12 AM

Quote:
Originally Posted by [[Whadafuxx]] View Post
Credits to Blakeman8192 for creating this guide!
  
Old
  (#4 (permalink))
lodece 1 is Offline
Senior Member
image
 
lodece 1's Avatar
 
Posts: 4,258
Cookies Given: 0
Cookies Received: 0
Time Online: 8 d 6 h 28 m
   
Default 05-19-2010, 03:14 AM

I am so confused man....
Can you explain it to me in english




Rest In Peace my brother, Abdulla (Cerebral995)
Born on December 22, 1995 - Died on April 13, 2012





^Thanks proph3t^
  
Old
  (#5 (permalink))
Asert One is Offline
Senior Member
image
 
Asert One's Avatar
 
Posts: 498
Cookies Given: 0
Cookies Received: 0
Time Online: 5 d 23 h 6 m
   
Default 05-19-2010, 03:14 AM

My bad, I apologize. Silabgarza does not really need to know the framework of Winterlove.
  
Old
  (#6 (permalink))
jexy_ohh is Offline
†Ska†
image
 
jexy_ohh's Avatar
 
Posts: 329
Cookies Given: 0
Cookies Received: 0
Time Online: 1 d 23 h 39 m
   
Default 05-19-2010, 08:00 AM

Quote:
Originally Posted by Asert One View Post
My bad, I apologize. Silabgarza does not really need to know the framework of Winterlove.
Some people like to explore new things.


Slick kidz, and their slick trickz.




OWD Jr S0N.
  
Old
  (#7 (permalink))
intrvention is Offline
<span style="color: chocolate">8 months ingame</span>
image
 
intrvention's Avatar
 
Posts: 502
Cookies Given: 0
Cookies Received: 0
Time Online: 1 d 15 h 50 m
Clan: TPOD !?
   
Default 07-01-2010, 08:54 AM

nice copy/paste skills



Quote:
Originally Posted by {gir} aka silabgarza on rune-server
project czar, is the most stable source you'll ever see
  
Old
  (#8 (permalink))
I R Maggot is Offline
Member
image
 
I R Maggot's Avatar
 
Posts: 64
Cookies Given: 0
Cookies Received: 0
Time Online: 3 h 28 m
   
Default 07-06-2010, 08:35 PM

I've known this.. Lul..

500ms should be 600ms.
  
Old
  (#9 (permalink))
Chaya is Offline
Member

image
 
Chaya's Avatar
 
Posts: 81
Cookies Given: 0
Cookies Received: 0
Time Online: 12 m
   
Default 07-07-2010, 01:23 AM

Well that was a long and boring post i just read. I obviously am not an explorer.
  
Old
  (#10 (permalink))
klk is Offline
Spermicidal
image
 
klk's Avatar
 
Posts: 3,391
Cookies Given: 105
Cookies Received: 240
Time Online: 46 d 15 h 32 m
   
Default 07-07-2010, 02:07 AM

Quote:
Originally Posted by Chaya View Post
Well that was a long and boring post i just read. I obviously am not an explorer.
^you and me both.

I'm not even gonna bother asking what i just read.





Soundcloud






Click for Stock Trading info:
  
adsense code2.3
Closed Thread

Bookmarks

An explanation of how Winterlove (BlakeScape) works

Programming




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
adsense2.6
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 10:36 AM.





Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.