Raknet - Whats WRONG with it??

Blitz3D Forums/Blitz3D Userlibs/Raknet - Whats WRONG with it??

Sake906(Posted 2010) [#1]
This post is pretty much out of desperation. I have been trying out the Raknet wrapper that's made for both BlitzMax and Blitz3D; coming with examples for both and documentation on the library. Worthy to mention is that this is not Kurix's wrapper but another by RepeatUntil which is somewhat based on Kurix'.

So Here is the problem: Raknet just lags, it hogs up to 100% on CPU process once "RN_Startup" is called and a connection is successfully established. It works, but I just can't get why it causes such a slowdown and it definitely comes from the dll; once the connection and peer is closed, the Blitz3D application speed goes back to normal.

Even tested this on a raw and empty B3D code sheet, the lib will just cause terrible framerates even on computers with more than one single core.

I am with B3D 1.103, downgraded to each version down to 1.98 to try it out on each, it gives the same result... Any ideas?


Sake906(Posted 2010) [#2]
RN_Startup%(rakPeerInterface%,maxConnections%, threadSleepTimer%, localPort%):"RN_Startup@16"

Think I found it, it could be that sleepTimer has to be a higher value.


ZJP(Posted 2010) [#3]
Hi,

Raknet is cool, but, try this : http://www.blitzbasic.com/Community/posts.php?topic=83448

JP


Sake906(Posted 2010) [#4]
..I'm not really looking to have people telling me to use a different library when I'm trying to solve this issue with the current one I'm using.

anyways, SleepTimer does not seem to be the case. Could it be that the dll needs to be recompiled with certain preprocessor directives enabled for minimal CPU usage?


ZJP(Posted 2010) [#5]
:(
I responded because I thought you had solved your problem. It was a reminder that there were other engines networks.
Lesson learned. Good luck.


Pinete(Posted 2010) [#6]
Dear Sake906,
you will have to be more patient and have better understanding with people who try to help you.
I could understand your answer in terms of paid-per-help, but it is not the case..
So what you're going get with that attitude is that people don't mind what you ask in the future.


Sake906(Posted 2010) [#7]
..And what exactly is so "impatient" about my answer to ZJP? it was an honest reply and I think getting a "whatever, try this other thing: *links*" and completely overlooking the topic (and library in question) is more impolite than my "impatient" response, but the person already clarified it was because they thought I solved my problem.

I did look into XNET but will keep it as an option in case everything I try with RakNet fails.


Ferret(Posted 2010) [#8]
I'm using the same lib.

I'm just getting into RakNet but have not encounterd any problems with framerate or cpu usage.
With a client and server running on the same machine mi cpu usage is 67%

This is code from the client
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Global peer = 0
Global serverIp$ = "127.0.0.1"
Global serverPort = 61019
Global packet = 0

Global BitStreamIN = RN_BitStreamCreate1(0)
Global B = RN_BitStreamCreate1(0)

Const ID_CHAT = 101

Include "Include/raknet.bb"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function Connect()
	peer = RN_GetRakPeerInterface()
	RN_Startup(peer,1,0,0)   ;1 player allowed To connect -> client
	
	Local ok = 0
	ok = RN_Connect(peer,serverIp, serverPort, "", 0)
	If ok = 1
		Connected = True
		Return True
	Else
		Return False
	EndIf
End Function
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function UpdateNet()
	packet = RN_Receive(peer)
	If (packet) Then
		Local msg$ = RN_PacketGetData(packet)
		Local msgType = Asc(msg$)
		
		Select msgType
			Case ID_CONNECTION_REQUEST_ACCEPTED
				lastentry$ = "Connected"
			
			Case ID_CONNECTION_ATTEMPT_FAILED
				lastentry$ = "Connection Failed"
				
			Case ID_CHAT
				lastentry$ = "Chat Message: " + msg
				
		End Select
	EndIf
End Function
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Ferret(Posted 2010) [#9]
I can also run some of your code on mi system if you want.


Baystep Productions(Posted 2010) [#10]
IMPATIENT ANSWER!

I wrote a network library along time ago, it worked fine and was easy to make.
Raknet sucks.
Download the other library.


Sake906(Posted 2010) [#11]
Ferret thank you very much. The code seems to be the same I'm having over here, only that I created some types to handle stuff on a more OOP way.

I do not see a main loop in your code though, but I guess you know that. I'm going to fetch my code and place it here in a bit just to show you what I'm using, though I doubt that's going to make a difference since the demos that came with the lib are also having the issue.

Have you recompiled the DLL or something like that? I'd like to know and also what version of it you are using.

Thanks in advance.


Sake906(Posted 2010) [#12]
Ferret:

Tried your client code, still gives me the same results as all the other raknet samples and my own samples. I wonder if you'd be able to provide the DLL you are using for your program? I am not sure if the one I have is optimized...


Ferret(Posted 2010) [#13]
Not sure about what version i'm using.
I did not recompile the DLL, i downloaded it from this link.
http://repeatuntil.free.fr/raknet/index.html

I can provide the DLL i'm using if i'm allowed by the author, so ill send him a mail if you still want it. But i think the download still contains the same version as when i downloaded it.

UpdateNet() is what i call first in mi main loop, before i do anything else.


Sake906(Posted 2010) [#14]
I really don't get this...

The problem is not in the update check, simply starting the "rakpeer interface" it already takes an insane amount of process, with or without the update loop.

Even tested it on another machine with multiple cores, slowdown is present.


ZJP(Posted 2010) [#15]
;)