Created
February 15, 2021 16:04
-
-
Save janev94/690b6d51dc5f4a01cd50d911232dff9d to your computer and use it in GitHub Desktop.
Verbose Reno Example
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
sudo sysctl net.ipv4.tcp_congestion_control=reno_verbose |
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
obj-m += tcp_reno_verbose.o | |
IDIR= /lib/modules/$(shell uname -r)/kernel/net/ipv4/ | |
KDIR := /lib/modules/$(shell uname -r)/build | |
PWD := $(shell pwd) | |
all: | |
make -C $(KDIR) M=$(PWD) modules | |
install: | |
install -v -m 644 tcp_reno_verbose.ko $(IDIR) | |
depmod | |
modprobe tcp_reno_verbose | |
sysctl -w net.ipv4.tcp_allowed_congestion_control="cubic reno reno_verbose" | |
clean: | |
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean | |
rm -rf Module.markers modules.order Module.symvers tcp_reno_verbose.ko tcp_reno_verbose.mod.c tcp_reno_verbose.mod.o tcp_reno_verbose.o |
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
#include <linux/module.h> | |
#include <net/tcp.h> | |
#include <linux/vmalloc.h> | |
void tcp_vreno_in_ack_event(struct sock *sk, u32 flags){ | |
const struct tcp_sock *tp = tcp_sk(sk); | |
const struct inet_sock *isock = inet_sk(sk); | |
printk(KERN_INFO "ACK Received. sourcep: %u dstp: %u proto%u send window: %u recv window %u\n", | |
ntohs(isock->inet_sport), ntohs(isock->inet_dport), sk->sk_protocol, tp->snd_cwnd, tp->rcv_wnd); | |
} | |
struct tcp_congestion_ops tcp_reno_verbose = { | |
.flags = TCP_CONG_NON_RESTRICTED, | |
.name = "reno_verbose", | |
.owner = THIS_MODULE, | |
.ssthresh = tcp_reno_ssthresh, | |
.cong_avoid = tcp_reno_cong_avoid, | |
.undo_cwnd = tcp_reno_undo_cwnd, | |
.in_ack_event = tcp_vreno_in_ack_event, | |
}; | |
static int __init tcp_reno_verbose_register(void) | |
{ | |
printk(KERN_INFO "Verbose Reno Going Up4"); | |
return tcp_register_congestion_control(&tcp_reno_verbose); | |
} | |
static void __exit tcp_reno_verbose_unregister(void) | |
{ | |
printk(KERN_INFO "Verbose Reno Shutting Down4"); | |
tcp_unregister_congestion_control(&tcp_reno_verbose); | |
} | |
module_init(tcp_reno_verbose_register); | |
module_exit(tcp_reno_verbose_unregister); | |
MODULE_AUTHOR("Yanev"); | |
MODULE_LICENSE("GPL"); | |
MODULE_DESCRIPTION("Verbose reno"); |
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
sudo sysctl net.ipv4.tcp_congestion_control=cubic | |
sudo rmmod tcp_reno_verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment