✅ Mysterious byte problem
https://github.com/MellowZippy1/Networking
I am working on a school project, I need to make a UDP-based FTP server, it should send a file using a slow-start approach, this has not been implemented yet. I do have a quite unique problem which is that even though I should be sending the same amount of bytes to the client (1024 bytes plus a JSON overhead) it keeps sending different amounts of overhead as shown in the picture below. It is sending all the data but I am wondering why the amount of bytes keeps changing? Is this an issue or just something that I should deal with?
GitHub
GitHub - MellowZippy1/Networking: Networking assignments met Naud
Networking assignments met Naud . Contribute to MellowZippy1/Networking development by creating an account on GitHub.
28 Replies
Unsure what difficulty to tag this problem at.
I just pushed the new version, if there's any bugs please attempt to clone again
Did you try debugging to see what gets sent?
Yeah
It sends an array of 1024 bytes, a MessageType enum which is Data and then some json overhead.
I am unsure why this would keep changing? Its 1024 bytes, the same MessageType and it should be the same json overhead, right?
Is the content of the JSON the same each time?
No, it would be different parts of the hamlet.
But it would still be 1024 bytes
Same amount of bytes, different bytes.
Then the length will differ as well
How so?
{"name":"bob"}
is shorter than {"name":"phranephrates"}
no think of it like this:
or
It would be the same amount of bytes, correct?
Yeah
So why does it send a different amount of bytes
Place a breakpoint at where the data gets serialized, and double-check that it actually always gets serialized to a string of the same length
A string gets put into a byte[1024]
a string gets put into a
byte[]
Of whatever is the length requiredno
the length is always 1024
yes
so hamlet (a big file) gets split into multiple packets of 1024 byes.
I don't see you setting 1024 anywhere here
Ah, I was looking at the client
Is okay
Huh
At which point does the size become not-1024?
wow
cool
In theory, the content of each packet should be 1024 bytes (plus overhead, which should be the same). In practice, the total amount of bytes keeps changing everytime it gets sent.
Yeah, but where?
How deep did you try placing the breakpoints?
I'd step through the code from the moment you split the file text, and see where does the length change
We figured it out, its because we encoded the chunk of hamlet text twice.
We encode it, then convert it to json, encode it again and send it
How do I close a ticket?
$close
Use the /close command to mark a forum thread as answered