tcp_scalable.c 1.6 KB

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