shovon / node-rudp

Reliable UDP for Node.js
33 stars 14 forks source link

getting corrupted data in one end point #16

Open amiiigh opened 5 years ago

amiiigh commented 5 years ago

Heyyy it's me again :D

So I have a new problem. The thing is I encrypt my data before sending it to my client and the client has to decrypt the data obviously! So I add some data before the real data as a header and I validate the header on the client. So if I couldn't read the header correctly that means there is something wrong with the data.

which is happening when I'm using the library. Should I split the data before sending it? Is there something that I'm missing here? How should I approach this problem?

How would the library react if packets received unordered?

Thanks <3

shovon commented 5 years ago

Thanks for bringing up this issue. I will be looking into it on Saturday.

It's an insanely busy week for me.

Cheers.

amiiigh commented 5 years ago

I think there is a missing 'var' behind 'bools' on line 16 of Packet.js btw

amiiigh commented 5 years ago

Hey An update on the problem. I tried sending an html file from my laptop to a server using rudp and the server got the file with no problem ( file size: 200K) But when I tried the library with a large file ( a pdf file 9M) the received file had different size every time I tried. So I think it does not work with large files apparently. I would appreciate if you could take a look at this. In the meantime, I'm trying to read the code and to see if I can find something.

Thanks brother

amiiigh commented 5 years ago

Thanks for bringing up this issue. I will be looking into it on Saturday.

It's an insanely busy week for me.

Cheers.

Hey, After banging my head on my wall enough I found the problem. The problem was when we have enough windows to make the random function to generate the baseSequenceNumber same for two consecutive windows.

if (packet.getSequenceNumber() === this._syncSequenceNumber) { this._packetSender.send(Packet.createAcknowledgementPacket(packet.getSequenceNumber())); return; }

In this case, the server will stay desynced and send the ack for the sync packet. The client after seeing the ack for sync packet would continue sending data. Since the server is desynced, the server will ignore the incoming packets which make the system break!

Fix: I will submit a pull request soon. I fixed this if and also changed a couple of small things. I would appreciate if you take a look at it.

Cheers <3

amiiigh commented 5 years ago

I made the pull request.

btw since I read the whole code I think I can write documentation for this library like what are the classes and what does each one do.