kcp-go icon indicating copy to clipboard operation
kcp-go copied to clipboard

kcp.UDPSession reads upto 1348 bytes

Open caustav opened this issue 4 years ago • 7 comments

When I read a kcp.UDPSession to a buffer, it always read upto 1348 bytes. Can I increase it ?

caustav avatar Aug 02 '20 12:08 caustav

https://pkg.go.dev/github.com/xtaci/kcp-go?tab=doc#KCP.SetMtu max 1500

xtaci avatar Aug 02 '20 13:08 xtaci

Thanks for the info. Actually I was transferring a file of 60 mb from client to server using the code from the sample example. But it was taking more than 2 minutes. I was thinking if I can improve the performance. Not sure whether I am thinking in the right direction. I choosed this one over TCP for better speed. Am I doing it in a wrong way ?

caustav avatar Aug 02 '20 17:08 caustav

@caustav This problem is complex, you need to test every part of your program to determine the problem. (Could your program handle file efficiently? Is your bandwith enough?)

Rouzip avatar Sep 23 '20 09:09 Rouzip

@Rouzip ı have 1 question.

Does this also mean that we can send a maximum of 1300 bytes at a time (for example 1 second)?

What algorithm should we follow if the data sent is larger than 1300 bytes? What is best practice here?

SeanTolstoyevski avatar Apr 17 '21 00:04 SeanTolstoyevski

My own solution is to add \n to the end of the content. This way I can read with bufio.NewReader until the data is finished. So NewReader.ReadString('\n') If there is a newline in the raw data, you can convert the data to base64.

SeanTolstoyevski avatar Apr 18 '21 17:04 SeanTolstoyevski

@Rouzip ı have 1 question.

Does this also mean that we can send a maximum of 1300 bytes at a time (for example 1 second)?

What algorithm should we follow if the data sent is larger than 1300 bytes? What is best practice here?

  1. It is depended on your network max mtu. And your example is not relative with your question.
  2. You can learn something from HTTP.

Rouzip avatar Apr 19 '21 01:04 Rouzip

Hello @Rouzip, Thank you for your answer. I'm pretty new to network and don't know anything. I'm learning network. I researched for MTU. It's about something different.

SeanTolstoyevski avatar Apr 19 '21 05:04 SeanTolstoyevski