It is currently Thu Jul 02, 2020 10:55 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: ProtoN (network protocol)
PostPosted: Tue Mar 31, 2020 10:55 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Oct 26, 2015 2:55 am
Posts: 923
Location: UA
Hi. Didn't posted much stuff here for a long time. Well this one is large enough.

This is my new UDP-based protocol. I had an old need to create something like this, going to use it in some project later (even in some online game, I'm expecting it will be fine for this too).
The concept is something like "TCP-over-UDP" and a bit similar to Google's QUIC protocol (for example, there are others of such type).

Advantages comparing to raw TCP:
- it should be faster/more responsible
- it should be more fault-tolerant (provide faster reaction in cases of packet lost)
- it can work with much lower traffic overhead (TCP overhead is 2.8% minimum, often much higher)
- it is UDP-based, this brings lesser problems with NAT or firewall

Comparing to raw UDP:
- it takes care of packet loss
- provides retransmission mechanism
- provides connection state control/timeouts/keepalive
- all such things that UDP lacks by design

General:
- it's usage is much more reliable than any raw protocol
- it can be customized to fit different tasks (for example, large "session size" is very good to transfer files)

Disadvantages:
- it is software-level protocol, though it is optimized a bit, it anyway consumes much more resources than raw TCP or UDP
- for now I didn't test it in any real project and conditions, only synthetic tests
- there is no encryption at protocol layer. I'm planning RSA+AES, but for now all goes to application responsibility

Implementation:
- a standalone code module

Download:
https://github.com/Lunasole/ProtoN
(oh at last I've started to use modules in my purebasic codes...)

That's all^^ Look at this stuff if interesting.

_________________
Kind of copyleft notify: all the source code created by me and posted on Purebasic official forums is free to use and modification in all possible (and several impossible) ways for anyone, without asking my permission


Last edited by Lunasole on Sun Apr 05, 2020 7:10 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ProtoN (network protocol)
PostPosted: Tue Mar 31, 2020 11:05 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 3525
Location: New Zealand
looks interesting, thanks for sharing.


Top
 Profile  
Reply with quote  
 Post subject: Re: ProtoN (network protocol)
PostPosted: Wed Apr 01, 2020 11:09 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14065
Location: France
Put it on github so you can get some traction ! Looks interesting


Top
 Profile  
Reply with quote  
 Post subject: Re: ProtoN (network protocol)
PostPosted: Wed Apr 01, 2020 7:25 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Oct 26, 2015 2:55 am
Posts: 923
Location: UA
Hope the code looks not too terrible to read by someone else ^^ It still needs reviews.

Fred wrote:
Put it on github so you can get some traction ! Looks interesting

Would be a good idea, but I still have no github in 2020. Maybe somehow later

_________________
Kind of copyleft notify: all the source code created by me and posted on Purebasic official forums is free to use and modification in all possible (and several impossible) ways for anyone, without asking my permission


Top
 Profile  
Reply with quote  
 Post subject: Re: ProtoN (network protocol)
PostPosted: Wed Apr 01, 2020 7:52 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4786
Location: Germany
I had just a short look over the code:

You should add the possibillity for the BindIP$ option.
Because if you have more then one network card, you want not always that both cards are listening.

I personally restrict all servers to the address which is really used.

If your procedures using ProcedureReturn, the type of the returnvalue should be specified at Procedure.
(This is also written in the help to Procedure)

I would do it the other way round:
Code:
Global NewList ProtoNList.PROTON_INSTANCE_IT()
:
*Proton = AddElement(ProtoNList())
If *Proton
:
endif


And if you use your module in threads, you should also add a Mutex to lock the list accesses.
Else it is possible that you do 2 concurrent things to the list.


Top
 Profile  
Reply with quote  
 Post subject: Re: ProtoN (network protocol)
PostPosted: Thu Apr 02, 2020 2:56 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4786
Location: Germany
Just look a bit deeper inside:

If you use a module, it makes no sense to put the name also in front of the procedures.
Code:
ProtoN::ProtoNTick()

It is easier if it is like:
Code:
ProtoN::Tick()

The name in front makes only sense if it is not a module, to unify the name.

In the demo:
Code:
Case *Connection
Case *Server

You should not use a global variable in the callback.
Better use 2 callbacks.

Or Better:
Code:
Prototype ProtoNCallback(*Instance.ProtoN::PROTON_INSTANCE, *Link.ProtoN::PROTON_LINK, *Data, nLen, *UserData=#Null)

Then the user can add an own structure with variables inside

And please use
Code:
CompilerIf #PB_Compiler_IsMainFile
CompilerEndIf

Arround the demo code.


Top
 Profile  
Reply with quote  
 Post subject: Re: ProtoN (network protocol)
PostPosted: Thu Apr 02, 2020 10:13 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Oct 26, 2015 2:55 am
Posts: 923
Location: UA
infratec wrote:
I had just a short look over the code:
You should add the possibillity for the BindIP$ option.
Because if you have more then one network card, you want not always that both cards are listening.


Yes, that's one of small things to be improved.
infratec wrote:
And if you use your module in threads, you should also add a Mutex to lock the list accesses.
Else it is possible that you do 2 concurrent things to the list.

Maybe for this will be better to make list and other global variables "Threaded" itself.
Anyway for now it's not "officially" threadsafe.


What about demo it's simple and dirty, for anyone who will use the module it's anyway better to remove the demo part completely.
Maybe later I'll take it to separate file (if will not forget^^).


PS. Generally I'm interesting to move all my stuff to github, as that hosting I'm using is HTTP-only and dramatically outdated.
Looks like github can be used to host it all for free so good idea.

_________________
Kind of copyleft notify: all the source code created by me and posted on Purebasic official forums is free to use and modification in all possible (and several impossible) ways for anyone, without asking my permission


Top
 Profile  
Reply with quote  
 Post subject: Re: ProtoN (network protocol)
PostPosted: Sat Apr 04, 2020 6:15 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4685
Location: Lyon - France
Apparently that work here
Thanks for sharing 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: ProtoN (network protocol)
PostPosted: Sun Apr 05, 2020 7:11 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Oct 26, 2015 2:55 am
Posts: 923
Location: UA
GitHub looks fine both for homepage hosting and as a place for some code, I've finally migrated to it^^
Updated link in 1st post + updated code a bit (with some changes mentioned above).
Not sure I really need github for code (as I'm coding in single-mode approximately 100% of all things), but let it be and going to post few more projects sometime.

_________________
Kind of copyleft notify: all the source code created by me and posted on Purebasic official forums is free to use and modification in all possible (and several impossible) ways for anyone, without asking my permission


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye