tcp_scalable.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. struct scalable {
  16. u32 loss_cwnd;
  17. };
  18. static void tcp_scalable_cong_avoid(struct sock *sk, u32 ack, u32 acked)
  19. {
  20. struct tcp_sock *tp = tcp_sk(sk);
  21. if (!tcp_is_cwnd_limited(sk))
  22. return;
  23. if (tcp_in_slow_start(tp))
  24. tcp_slow_start(tp, acked);
  25. else
  26. tcp_cong_avoid_ai(tp, min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT),
  27. 1);
  28. }
  29. static u32 tcp_scalable_ssthresh(struct sock *sk)
  30. {
  31. const struct tcp_sock *tp = tcp_sk(sk);
  32. struct scalable *ca = inet_csk_ca(sk);
  33. ca->loss_cwnd = tp->snd_cwnd;
  34. return max(tp->snd_cwnd - (tp->snd_cwnd>>TCP_SCALABLE_MD_SCALE), 2U);
  35. }
  36. static u32 tcp_scalable_cwnd_undo(struct sock *sk)
  37. {
  38. const struct scalable *ca = inet_csk_ca(sk);
  39. return max(tcp_sk(sk)->snd_cwnd, ca->loss_cwnd);
  40. }
  41. static struct tcp_congestion_ops tcp_scalable __read_mostly = {
  42. .ssthresh = tcp_scalable_ssthresh,
  43. .undo_cwnd = tcp_scalable_cwnd_undo,
  44. .cong_avoid = tcp_scalable_cong_avoid,
  45. .owner = THIS_MODULE,
  46. .name = "scalable",
  47. };
  48. static int __init tcp_scalable_register(void)
  49. {
  50. return tcp_register_congestion_control(&tcp_scalable);
  51. }
  52. static void __exit tcp_scalable_unregister(void)
  53. {
  54. tcp_unregister_congestion_control(&tcp_scalable);
  55. }
  56. module_init(tcp_scalable_register);
  57. module_exit(tcp_scalable_unregister);
  58. MODULE_AUTHOR("John Heffner");
  59. MODULE_LICENSE("GPL");
  60. MODULE_DESCRIPTION("Scalable TCP");