tcp_scalable.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Tom Kelly's Scalable TCP
  2. *
  3. * See http://www.deneholme.net/tom/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 acked)
  16. {
  17. struct tcp_sock *tp = tcp_sk(sk);
  18. if (!tcp_is_cwnd_limited(sk))
  19. return;
  20. if (tcp_in_slow_start(tp))
  21. tcp_slow_start(tp, acked);
  22. else
  23. tcp_cong_avoid_ai(tp, min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT),
  24. 1);
  25. }
  26. static u32 tcp_scalable_ssthresh(struct sock *sk)
  27. {
  28. const struct tcp_sock *tp = tcp_sk(sk);
  29. return max(tp->snd_cwnd - (tp->snd_cwnd>>TCP_SCALABLE_MD_SCALE), 2U);
  30. }
  31. static struct tcp_congestion_ops tcp_scalable __read_mostly = {
  32. .ssthresh = tcp_scalable_ssthresh,
  33. .undo_cwnd = tcp_reno_undo_cwnd,
  34. .cong_avoid = tcp_scalable_cong_avoid,
  35. .owner = THIS_MODULE,
  36. .name = "scalable",
  37. };
  38. static int __init tcp_scalable_register(void)
  39. {
  40. return tcp_register_congestion_control(&tcp_scalable);
  41. }
  42. static void __exit tcp_scalable_unregister(void)
  43. {
  44. tcp_unregister_congestion_control(&tcp_scalable);
  45. }
  46. module_init(tcp_scalable_register);
  47. module_exit(tcp_scalable_unregister);
  48. MODULE_AUTHOR("John Heffner");
  49. MODULE_LICENSE("GPL");
  50. MODULE_DESCRIPTION("Scalable TCP");