Last active
September 11, 2015 06:01
-
-
Save yanfenglee/0c08d49ce29c49d1d0b5 to your computer and use it in GitHub Desktop.
stupid tcp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* stupid congestion control | |
* | |
*/ | |
#include <linux/module.h> | |
#include <net/tcp.h> | |
static int fixed_cwnd __read_mostly = 1000; | |
module_param(fixed_cwnd, int, 0644); | |
MODULE_PARM_DESC(fixed_cwnd, "fixed cwnd"); | |
static void hstcp_init(struct sock *sk) | |
{ | |
struct tcp_sock *tp = tcp_sk(sk); | |
tp->snd_cwnd_clamp = fixed_cwnd; | |
tp->snd_cwnd = fixed_cwnd; | |
} | |
static void hstcp_cong_avoid(struct sock *sk, u32 ack, u32 acked) | |
{ | |
struct tcp_sock *tp = tcp_sk(sk); | |
tp->snd_cwnd = fixed_cwnd; | |
tp->snd_cwnd_clamp = fixed_cwnd; | |
} | |
static u32 hstcp_ssthresh(struct sock *sk) | |
{ | |
return fixed_cwnd; | |
} | |
static void on_pkt_acked(struct sock *sk, u32 pkts_acked, s32 rtt) | |
{ | |
struct tcp_sock *tp = tcp_sk(sk); | |
tp->snd_cwnd = fixed_cwnd; | |
tp->snd_cwnd_clamp = fixed_cwnd; | |
} | |
static struct tcp_congestion_ops tcp_highspeed __read_mostly = { | |
.init = hstcp_init, | |
.ssthresh = hstcp_ssthresh, | |
.cong_avoid = hstcp_cong_avoid, | |
.pkts_acked = on_pkt_acked, | |
.owner = THIS_MODULE, | |
.name = "htcp" | |
}; | |
static int __init hstcp_register(void) | |
{ | |
return tcp_register_congestion_control(&tcp_highspeed); | |
} | |
static void __exit hstcp_unregister(void) | |
{ | |
tcp_unregister_congestion_control(&tcp_highspeed); | |
} | |
module_init(hstcp_register); | |
module_exit(hstcp_unregister); | |
MODULE_AUTHOR("yanfeng lee"); | |
MODULE_LICENSE("GPL"); | |
MODULE_DESCRIPTION("Stupid htcp"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment