tcp_scalable.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Tom Kelly's Scalable TCP
  2. *
  3. * See htt://www-lce.eng.cam.ac.uk/~ctk21/scalable/
  4. *
  5. * John Heffner <jheffner@sc.edu>
  6. */
  7. #include <linux/module.h>
  8. #include <net/tcp.h>
  9. /* These factors derived from the recommended values in the aer:
  10. * .01 and and 7/8. We use 50 instead of 100 to account for
  11. * delayed ack.
  12. */
  13. #define TCP_SCALABLE_AI_CNT 50U
  14. #define TCP_SCALABLE_MD_SCALE 3
  15. static void tcp_scalable_cong_avoid(struct sock *sk, u32 ack, u32 rtt,
  16. u32 in_flight, int flag)
  17. {
  18. struct tcp_sock *tp = tcp_sk(sk);
  19. if (!tcp_is_cwnd_limited(sk, in_flight))
  20. return;
  21. if (tp->snd_cwnd <= tp->snd_ssthresh)
  22. tcp_slow_start(tp);
  23. else {
  24. tp->snd_cwnd_cnt++;
  25. if (tp->snd_cwnd_cnt > min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT)){
  26. if (tp->snd_cwnd < tp->snd_cwnd_clamp)
  27. tp->snd_cwnd++;
  28. tp->snd_cwnd_cnt = 0;
  29. }
  30. }
  31. }
  32. static u32 tcp_scalable_ssthresh(struct sock *sk)
  33. {
  34. const struct tcp_sock *tp = tcp_sk(sk);
  35. return max(tp->snd_cwnd - (tp->snd_cwnd>>TCP_SCALABLE_MD_SCALE), 2U);
  36. }
  37. static struct tcp_congestion_ops tcp_scalable = {
  38. .ssthresh = tcp_scalable_ssthresh,
  39. .cong_avoid = tcp_scalable_cong_avoid,
  40. .min_cwnd = tcp_reno_min_cwnd,
  41. .owner = THIS_MODULE,
  42. .name = "scalable",
  43. };
  44. static int __init tcp_scalable_register(void)
  45. {
  46. return tcp_register_congestion_control(&tcp_scalable);
  47. }
  48. static void __exit tcp_scalable_unregister(void)
  49. {
  50. tcp_unregister_congestion_control(&tcp_scalable);
  51. }
  52. module_init(tcp_scalable_register);
  53. module_exit(tcp_scalable_unregister);
  54. MODULE_AUTHOR("John Heffner");
  55. MODULE_LICENSE("GPL");
  56. MODULE_DESCRIPTION("Scalable TCP");