Author Topic: RakNet 2.45 released  (Read 16504 times)

wrt

  • Full Member
  • ***
  • Posts: 139
  • Karma: 0
    • View Profile
Re: RakNet 2.45 released
« Reply #15 on: February 19, 2006, 06:03:06 AM »
oh, i didn't notice you're using the dll ...

just add BitStream.cpp to your project and you should be fine.

Skinney

  • Guest
Re: RakNet 2.45 released
« Reply #16 on: February 19, 2006, 06:14:22 AM »
nahh... didnt help, if it was me you were trying to help...
still the same linking errors... wierd :S

I'll try installing the vs2003 compiler and see if that helps...

pinniped

  • Full Member
  • ***
  • Posts: 133
  • Karma: -1
    • View Profile
Re: RakNet 2.45 released
« Reply #17 on: February 19, 2006, 06:15:01 AM »
The 'undefined reference' stuff for shared libs is something I would expect on MSVC because by default everything is hidden (on Linux everything is exported by default), but I'm not sure how GCC behaves.  Try a static link and see if the errors all disappear. (after all RakNet is not a large lib).  I can't help you until the latest version is available via svn and I have a look at the code myself.  (and I'll also have to get dev access at some stage - submitting patches all the time is a real nuisance)

wrt

  • Full Member
  • ***
  • Posts: 139
  • Karma: 0
    • View Profile
Re: RakNet 2.45 released
« Reply #18 on: February 19, 2006, 06:29:15 AM »
yeah, i was trying to help you

well, i thought he might be using the dll that is delifered in the package. But anyway, you're right, statically linking saves you quite a bit of trouble and doesn't really change things all that much, after all you'd have to delifer the dll as well, so you wouldn't save any space. 

Skinney

  • Guest
Re: RakNet 2.45 released
« Reply #19 on: February 19, 2006, 07:04:09 AM »
ok... im a newb unfortuanetly so its difficult to understand what you mean by static linking :S
I have added RakNetDLL and RakNetStaticLib to the linker settings in Codeblocks but im not sure if thats what you mean.
And yeah i am using the pre-compiled DLL with RakNet... Also adding BitStream.cpp didn't solve the problem...

And MSVC2003 didnt help either, got an error about not finding assert.h or something...
i hate when these things happen :(

wrt

  • Full Member
  • ***
  • Posts: 139
  • Karma: 0
    • View Profile
Re: RakNet 2.45 released
« Reply #20 on: February 19, 2006, 08:11:33 AM »
well, there are two forms of linking, dynamic and static. dynamic means that your programm just knows "i need this library", this is what you do with dlls. The programm will then load the dll when it starts or when it's needed. The other method is static linking, it means that the library is included in your programm. so if you link statically you don't need the respective dll and you don't need to worry about the library later on, however it will increase the size of your binary.

for static linking you'll need a static library, i don't know if  mingw likes the msvc compilled ones, but it's worth a try, so just add RakNetLibStatic.lib to your project and give it a try. You propably also need to add libws_32.a for the winsockets. Please search the forum if you don't know how to do it.

cu wrt

Skinney

  • Guest
Re: RakNet 2.45 released
« Reply #21 on: February 19, 2006, 09:15:45 AM »
there we go!
had to link libws2_32.a and compile worked:D
Thanks, helped alot :)

wrt

  • Full Member
  • ***
  • Posts: 139
  • Karma: 0
    • View Profile
Re: RakNet 2.45 released
« Reply #22 on: February 19, 2006, 05:46:58 PM »
damn, i should have checked if it actually works. I can compile and link fine, but connecting doesn't work any more. i've added a packet logger to the linux chat example and here's the output:
Code: [Select]
Starting server.
Server started, waiting for connections.
S|R,Typ,Pckt#,Frm #,PktID,BitLn,Time     ,Local IP:Port   ,RemoteIP:Port
'quit' to quit. 'stat' to show stats. 'ping' to ping.
'ban' to ban an IP from connecting. Type to talk.
Rcv,Raw,  NIL,  NIL,   14,    8,35147,1677721610:12345,16777343:32788
Snd,Raw,  NIL,  NIL,   15,    8,35147,1677721610:12345,16777343:32788
Rcv,Ack,    0,    0,  NIL,    1,35179,1677721610:12345,16777343:32788
Rcv,Ack,    0,    1,  NIL,    1,38165,1677721610:12345,16777343:32788
Rcv,Ack,    0,    2,  NIL,    1,41176,1677721610:12345,16777343:32788
Rcv,Ack,    0,    3,  NIL,    1,44194,1677721610:12345,16777343:32788
           

and here the client:
Code: [Select]
Attempting connection
'quit' to quit. 'stat' to show stats. 'ping' to ping. Type to talk.
S|R,Typ,Pckt#,Frm #,PktID,BitLn,Time     ,Local IP:Port   ,RemoteIP:Port
Snd,Raw,  NIL,  NIL,   14,    8,47,1677721610:32789,16777343:12345
Rcv,Raw,  NIL,  NIL,   15,    8,79,1677721610:32789,16777343:12345
Snd,Nrm,    0,    0,    5,    8,79,1677721610:32789,16777343:12345
Snd,Nrm,    0,    1,    5,    8,3094,1677721610:32789,16777343:12345
Snd,Nrm,    0,    2,    5,    8,6107,1677721610:32789,16777343:12345
Snd,Nrm,    0,    3,    5,    8,9115,1677721610:32789,16777343:12345
3หวท@หวท
         

i don't know where the strange stuff comes from, but maybe this output helps you find the problem. I'll have a deeper look at the source later, but maybe you can help me save some time.

cu wrt


fatgy

  • Not-a-newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Re: RakNet 2.45 released
« Reply #23 on: February 21, 2006, 02:42:18 AM »
when i complied project it doesn't make zlibStatic.lib for me. it has only zlibStaticDebug.lib

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: RakNet 2.45 released
« Reply #24 on: February 21, 2006, 11:31:23 AM »
Wrt, it's sending and getting ID_CONNECTION_REQUEST.  The easiest way to resolve this is for you to put a breakpoint in RakPeer::ParseConnectionRequestPacket because I didn't see any reply in the packet logger and it should have replied with something.  Is the output you posted the whole output?

wrt

  • Full Member
  • ***
  • Posts: 139
  • Karma: 0
    • View Profile
Re: RakNet 2.45 released
« Reply #25 on: February 21, 2006, 12:08:57 PM »
jepp, that's the whole output i get

in my real program i also get a "ReceiveConnectionAttemptFailed"

hmm, ParseConnectionRequestPacket doesn't actually gets called, but that's for secure connections only as far as i understand? But that part of the code looks really messed up from my point of view.
Code: [Select]
const char *password = data + sizeof(unsigned char);
int passwordLength = byteSize - sizeof(unsigned char);

if ( incomingPasswordBitStream.GetNumberOfBytesUsed() == passwordLength &&
memcmp( password, incomingPasswordBitStream.GetData(), passwordLength ) == 0 )
{
remoteSystem->connectMode=RemoteSystemStruct::HANDLING_CONNECTION_REQUEST;

if ( usingSecurity == false )
{
#ifdef _TEST_AES
unsigned char AESKey[ 16 ];
// Save the AES key
for ( i = 0; i < 16; i++ )
AESKey[ i ] = i;

OnConnectionRequest( remoteSystem, AESKey, true );
#else
// Connect this player assuming we have open slots
OnConnectionRequest( remoteSystem, 0, false );
#endif
}
else
SecuredConnectionResponse( playerId );
}


so you're checking if the passwort is correct, than afterwards you check if security is wanted, this is strange, cause i would count passworts as security and also i don't have one, so this would fail? second strange thing is that part about saving the AES key, which is done by overwriting a newly created array? but the most strange thing about this is that all this happens if security is DISABLED.

cu wrt

ps: sorry if this sounds a bit aggresive/unfriendly, i don't mean it that way
« Last Edit: February 21, 2006, 02:21:29 PM by wrt »

wrt

  • Full Member
  • ***
  • Posts: 139
  • Karma: 0
    • View Profile
Re: RakNet 2.45 released
« Reply #26 on: February 21, 2006, 02:31:58 PM »
hmm, that's not really the problem it seams. I commented out everything exept
remoteSystem->connectMode=RemoteSystemStruct::HANDLING_CONNECTION_REQUEST;
OnConnectionRequest( remoteSystem, 0, false );

but it still doesn't work

i don't know what to look for, so i might just as well stop looking around for now
« Last Edit: February 21, 2006, 03:43:55 PM by wrt »

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: RakNet 2.45 released
« Reply #27 on: February 21, 2006, 04:29:25 PM »
Now that I look at it more carefully I see what is happening is one system is doing normal sends and the other system interprets those sends as acks, incorrectly.

The code that does this is in ReliabilityLayer.cpp

Code: [Select]
// Write the packet number (2 bytes)
bitStream->Write( internalPacket->messageNumber );

// Write if this packet is an acknowledgement (1 bit)
bitStream->Write( internalPacket->isAcknowledgement );

And the receiver:
Code: [Select]
if ( bitStream->GetNumberOfUnreadBits() < sizeof( internalPacket->messageNumber ) * 8 )
return 0; // leftover bits

internalPacket = internalPacketPool.GetPointer();

#ifdef _DEBUG
// Remove accessing undefined memory error
memset( internalPacket, 255, sizeof( InternalPacket ) );
#endif

internalPacket->creationTime = time;

//bitStream->AlignReadToByteBoundary();

// Read the packet number (2 bytes)
bitStreamSucceeded = bitStream->Read( internalPacket->messageNumber );

#ifdef _DEBUG
// 10/08/05 - Disabled assert since this hits from offline packets
//assert( bitStreamSucceeded );
#endif

if ( bitStreamSucceeded == false )
{
internalPacketPool.ReleasePointer( internalPacket );
return 0;
}

// Read if this packet is an acknowledgement (1 bit)
bitStreamSucceeded = bitStream->Read( internalPacket->isAcknowledgement );

#ifdef _DEBUG
// 10/08/05 - Disabled assert since this hits from offline packets
//assert( bitStreamSucceeded );
#endif

if ( bitStreamSucceeded == false )
{
internalPacketPool.ReleasePointer( internalPacket );
return 0;
}

What you can do is put a breakpoint in the sending function and trace into

Code: [Select]
bitStream->Write( internalPacket->isAcknowledgement );

Make sure that it's going into the boolean write template specilization.

Then on the recipient, make sure it's doing the correct equivalent in

Code: [Select]
bitStreamSucceeded = bitStream->Read( internalPacket->isAcknowledgement );

In both cases, isAcknowlegement should be false for the send of the packet with the ID 5, which is ID_CONNECTION_REQUEST.  On the sender, you can see if the packet you are looking at has the ID 5 by viewing (unsigned char) internalPacket->data[0].  On the receiver, you'll have to trace down to ReadAlignedBytes in the same function before you can tell what it is you got.

If that all works, you can put a breakpoint here:
Code: [Select]
// For unknown senders we only accept a few specific packets
if (remoteSystem->connectMode==RemoteSystemStruct::UNVERIFIED_SENDER)
{
if ( (unsigned char)(data)[0] == ID_CONNECTION_REQUEST )
{
ParseConnectionRequestPacket(remoteSystem, playerId, data, byteSize);
delete [] data;
}

See if it ever hits the first if.
« Last Edit: February 21, 2006, 04:31:55 PM by Rak'kar »

wrt

  • Full Member
  • ***
  • Posts: 139
  • Karma: 0
    • View Profile
Re: RakNet 2.45 released
« Reply #28 on: February 21, 2006, 05:30:55 PM »
okay, it definitly was a problem wiht the bitstream templates ...  in an older version

somehow i got everything mixed up and used a somewhat older version. AAH!

well now everything works fine and thanks a lot for your troubles, I'm very sorry i bothered you with this.

But there are still some good points about this, i now know the raknet source way better and also my debugger :-D

cu and sorry again wrt

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: RakNet 2.45 released
« Reply #29 on: February 24, 2006, 01:08:58 AM »
Add the relevant cpp files.  The DLL only exports part of the codebase.  I suggest you use the static library instead, so you don't have to do that.