config.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package kcp
  2. /*AdvancedConfig define behavior of KCP in detail
  3. MaximumTransmissionUnit:
  4. Largest protocol data unit that the layer can pass onwards
  5. can be discovered by running tracepath
  6. SendingWindowSize , ReceivingWindowSize:
  7. the size of Tx/Rx window, by packet
  8. ForwardErrorCorrectionGroupSize:
  9. The the size of packet to generate a Forward Error Correction
  10. packet, this is used to counteract packet loss.
  11. AcknowledgeNoDelay:
  12. Do not wait a certain of time before sending the ACK packet,
  13. increase bandwich cost and might increase performance
  14. Dscp:
  15. Differentiated services code point,
  16. be used to reconized to discriminate packet.
  17. It is recommanded to keep it 0 to avoid being detected.
  18. ReadTimeout,WriteTimeout:
  19. Close the Socket if it have been silent for too long,
  20. Small value can recycle zombie socket faster but
  21. can cause v2ray to kill the proxy connection it is relaying,
  22. Higher value can prevent server from closing zombie socket and
  23. waste resources.
  24. */
  25. /*Config define basic behavior of KCP
  26. Mode:
  27. can be one of these values:
  28. fast3,fast2,fast,normal
  29. <<<<<<- less delay
  30. ->>>>>> less bandwich wasted
  31. */
  32. type Config struct {
  33. Mode string
  34. Mtu int
  35. Sndwnd int
  36. Rcvwnd int
  37. Acknodelay bool
  38. Dscp int
  39. ReadTimeout int
  40. WriteTimeout int
  41. }
  42. func (this *Config) Apply() {
  43. effectiveConfig = *this
  44. }
  45. var (
  46. effectiveConfig = Config{
  47. Mode: "normal",
  48. Mtu: 1350,
  49. Sndwnd: 1024,
  50. Rcvwnd: 1024,
  51. Dscp: 0,
  52. ReadTimeout: 600,
  53. WriteTimeout: 500,
  54. Acknodelay: false,
  55. }
  56. )