Openkore.com

OpenKore Forums
It is currently 28 Jul 2017, 07:02

All times are UTC - 5 hours [ DST ]





Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: 01 - kali's beginning programming guide
PostPosted: 10 Jul 2017, 12:04 
Offline
OpenKore Monk
OpenKore Monk

Joined: 04 Apr 2008, 10:10
Posts: 445
So with all the hullabaloo about the new Ragnarok servers by Gravity, I thought this would be a great time to start inspiring people to start learning *actual* programming, instead of just being a script kiddie.

Programming is the future, and if I can even get some of your interest because it happens to be related to a game you play, then that's just bonus points.

I'm thinking of doing this as a series of sorts, and I'll try to cover stuff that will be both generally useful in programming, as well as stuff that's specific to openkore and of course, ragnarok. If anyone wants to help out by suggesting topics they want covered (serious suggestions only please. you all know i have a short fuse) please do so. And if anyone wants to answer questions feel free to do so as well.

So first lesson would be the network packets. If you've played around with Wireshark or WPE Pro, you've probably seen something like this:

Code:
00000000  76 0a 18 00 00 00 75 73 65 72 6e 61 6d 65 00 00  |v.....username..|
00000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 b9 2a  |...............*|
00000030  20 24 a9 31 59 db f6 77 fa b7 35 66 a3 a2 06 81  | $.1Y..w..5f....|
00000040  e9 a5 16 63 9f dc 6d 7e 73 d7 55 d8 f8 00 0f 00  |...c..m~s.U.....|


In Openkore parlance, we'd call this packet 0x0A76

But why do we call it 0x0A76 ? Why not call it 76 0a (the way it shows up in the network sniffer)? Why do we write it in reverse?

This is called Endianeness and most microporcessor code (stuff used by programming languages like C) come in the Little Endian format. See https://en.wikipedia.org/wiki/Endianness for a good explanation.

So there, we have packet 0x0A76 which is two bytes, packed in VAX byte order (aka Little Endian). https://apidock.com/ruby/Array/pack is a good reference for the various packing "formats" you can use. I know that OpenKore is in Perl, but Ruby gets a lot of inspiration from Perl so it has most of the powerful stuff that Perl has.

Another advantage of Ruby is that it's a bit easier to learn than Perl, so I'll be using Ruby for examples. Programming skills are transferable no matter the language, so don't get worried that you're wasting your time. You'll find that concepts are generally the same everywhere.

If you're feeling up to it, read up on http://openkore.com/index.php/Network_subsystem then come back here.

Okay, from that wiki article you'll know that the ragnarok network protocol (at least the older ones) came in "packets."

What's a packet?

Ask a Brazillian and they'll tell you the correct answer. It's basically a package of bytes. Bytes are just characters (like this wall of text). So they're like sentences in a language that only computers understand.

We have what we call internally in OpenKore as a "packet switch" although Message ID is a more appropriate name for it. The Message ID identifies a packet so the receiver knows what the package should contain. It's like the title of a book, or a label in a container.

There's a big problem though. TCP is a streaming protocol, meaning you never really disconnect from your partner. So if there are packets heading your way, how do you know when a packet ends and when a packet starts?

That's where `recvpackets.txt` comes in. This file is a table of packet lengths; it basically acts as a measuring type to find out where to cut the stream so we know we have a complete packet. If the lengths are wrong, then we won't be able to cut the stream in the correct place, and kore will get confused.

Next time we'll talk about AES-128, Rijndael, symmetric encryption, and why you shouldn't play ragnarok using free wifi hotspots.

_________________
Got your topic trashed by a mod?

Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.

Have a nice day.


Top
 Profile  
 
 Post subject: Re: 01 - kali's beginning programming guide
PostPosted: 12 Jul 2017, 18:50 
Offline
Noob
Noob

Joined: 08 Jul 2017, 21:31
Posts: 4
Thanks for the starters. I'll be waiting for the next post.


Top
 Profile  
 
 Post subject: Re: 01 - kali's beginning programming guide
PostPosted: 17 Jul 2017, 02:32 
Offline
Noob
Noob

Joined: 09 Jul 2017, 19:19
Posts: 5
Looks good bro. Learned a lot in one post, I'm anticipating the next topic.


Top
 Profile  
 
 Post subject: Re: 01 - kali's beginning programming guide
PostPosted: 19 Jul 2017, 01:24 
Offline
Noob
Noob

Joined: 03 Jul 2017, 08:32
Posts: 1
Thank you for this Kali. I'm in IT and in production support/product development for a multinational firm but as you know you can't really pick which technology/programming language you get to specialize in if you are someone like me. This guide is awesome for those who want to learn something new and interesting as well as related to the game we love. Can't wait for the next post. :D


Top
 Profile  
 
 Post subject: Re: 01 - kali's beginning programming guide
PostPosted: 26 Jul 2017, 11:13 
Offline
Human
Human

Joined: 05 Oct 2010, 09:46
Posts: 23
Thank you for this Kali, it really open "insights" instead of the tutorials, and we're fiddle with our heads to understand what it really means (like teach English to a Japanese), where the grammar and sentences is different between those two.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group