63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
#include <linux/module.h>
|
|
#include <net/tcp.h>
|
|
|
|
static u32 const_cwnd = 1000;
|
|
module_param(const_cwnd, uint, 0664);
|
|
|
|
static void const_main(struct sock *sk, u32,int,const struct rate_sample *rs)
|
|
{
|
|
tcp_sk(sk)->snd_cwnd = const_cwnd;
|
|
}
|
|
|
|
static void const_cong_avoid(struct sock *sk, u32 ack, u32 acked)
|
|
{
|
|
tcp_sk(sk)->snd_cwnd = const_cwnd;
|
|
}
|
|
|
|
static void const_init(struct sock *sk)
|
|
{
|
|
tcp_sk(sk)->snd_cwnd = const_cwnd;
|
|
}
|
|
|
|
static u32 const_ssthresh(struct sock *sk)
|
|
{
|
|
return const_cwnd;
|
|
}
|
|
|
|
static void const_set_state(struct sock *sk, u8 new_state)
|
|
{
|
|
if (new_state == TCP_CA_Loss) {
|
|
tcp_sk(sk)->snd_cwnd = const_cwnd;
|
|
}
|
|
}
|
|
|
|
static u32 const_undo(struct sock *sk)
|
|
{
|
|
return tcp_sk(sk)->snd_cwnd;
|
|
}
|
|
|
|
static struct tcp_congestion_ops tcp_const_cong_ops __read_mostly = {
|
|
.name = "const",
|
|
.undo_cwnd = const_undo,
|
|
.init = const_init,
|
|
.cong_control = const_main,
|
|
/*.cong_avoid = const_cong_avoid,*/
|
|
.ssthresh = const_ssthresh,
|
|
.set_state = const_set_state,
|
|
};
|
|
|
|
static int __init const_register(void)
|
|
{
|
|
return tcp_register_congestion_control(&tcp_const_cong_ops);
|
|
}
|
|
|
|
static void __exit const_unregister(void)
|
|
{
|
|
tcp_unregister_congestion_control(&tcp_const_cong_ops);
|
|
}
|
|
|
|
module_init(const_register);
|
|
module_exit(const_unregister);
|
|
|
|
MODULE_LICENSE("GPL");
|