config.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package kcpv
  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. type AdvancedConfig struct {
  26. Mtu int `json:"MaximumTransmissionUnit"`
  27. Sndwnd int `json:"SendingWindowSize"`
  28. Rcvwnd int `json:"ReceivingWindowSize"`
  29. Fec int `json:"ForwardErrorCorrectionGroupSize"`
  30. Acknodelay bool `json:"AcknowledgeNoDelay"`
  31. Dscp int `json:"Dscp"`
  32. ReadTimeout int `json:"ReadTimeout"`
  33. WriteTimeout int `json:"WriteTimeout"`
  34. }
  35. /*Config define basic behavior of KCP
  36. Mode:
  37. can be one of these values:
  38. fast3,fast2,fast,normal
  39. <<<<<<- less delay
  40. ->>>>>> less bandwich wasted
  41. EncryptionKey:
  42. a string that will be the EncryptionKey of
  43. All KCP connection we Listen-Accpet or
  44. Dial, We are not very sure about how this
  45. encryption hehave and DO use a unique randomly
  46. generated key.
  47. */
  48. type Config struct {
  49. Mode string `json:"Mode"`
  50. Key string `json:"EncryptionKey"`
  51. AdvancedConfigs *AdvancedConfig `json:"AdvancedConfig,omitempty"`
  52. }
  53. var DefaultAdvancedConfigs = &AdvancedConfig{
  54. Mtu: 1350, Sndwnd: 1024, Rcvwnd: 1024, Fec: 4, Dscp: 0, ReadTimeout: 600, WriteTimeout: 500, Acknodelay: false,
  55. }