Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Scheduler dev #465

Draft
wants to merge 27 commits into
base: mptcp_v0.95
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0468cec
added mptcp_ratio.c and modified some headers
phdinh94 Jan 31, 2022
6ba0de8
Fix Kconfig indentation
phdinh94 Feb 2, 2022
b673851
change mptcp_ratio.c to the one in musher percent_threshold branch
phdinh94 Feb 7, 2022
0e9fe50
change all mptcp_for_each_sk function call to mptcp_for_each_sub
phdinh94 Feb 8, 2022
75a4ae0
adding debugging log for mptcp_ratio_is_enabled
phdinh94 Feb 8, 2022
c3dfe7a
fixed indentation
phdinh94 Feb 14, 2022
fda6250
merged mptcp_rtt from musher_v0.94
phdinh94 Feb 14, 2022
28b10e8
remove some printk
phdinh94 Feb 15, 2022
0ddc101
finalize sched_probe and musher intergration
phdinh94 Feb 25, 2022
29f8cac
add trigger condition logs
phdinh94 Feb 27, 2022
4255d69
enabled sysctl mptcp_rate_sample
phdinh94 Mar 3, 2022
1c1e66d
#acks, srtt, min_srtt instrumentation
phdinh94 Mar 5, 2022
c29bbaf
routine refactoring, not yet checked on phone
phdinh94 Mar 16, 2022
458aca9
checked with phone for new updates
phdinh94 Mar 18, 2022
47a14ad
regular refactoring and comment, tested
phdinh94 Mar 19, 2022
2f75473
Shorten printk and add per-socket buffer probe
phdinh94 Mar 20, 2022
75a743f
per-socket buffer probe, fixed
phdinh94 Mar 20, 2022
ae08214
independent threshold count
phdinh94 Mar 26, 2022
3457d6a
change printk line formatting
phdinh94 Mar 28, 2022
cc53f8e
remove unecessary else to print values
phdinh94 Mar 29, 2022
4703ebc
allow search above 90 percent
phdinh94 Mar 31, 2022
fbf9ba2
allow search above 90 percent fixed
phdinh94 Mar 31, 2022
faea95c
add some comments
phdinh94 Apr 22, 2022
ff7b5e8
head cutting optimization
phdinh94 Apr 25, 2022
e97fab7
mptcp module build script
phdinh94 Apr 25, 2022
ab95cb7
remove abs rate_diff
phdinh94 Apr 26, 2022
b7576e0
fixed negative # ACKs
phdinh94 Apr 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion include/linux/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req)

struct tcp_md5sig_key;

/*phuc*/
typedef enum {
RIGHT_RATIO_SET,
LEFT_RATIO_SET,
SEARCH_RATE,
RIGHT_RATIO_FINE,
LEFT_RATIO_FINE
}ratio_search_state;

struct tcp_sock {
/* inet_connection_sock has to be the first member of tcp_sock */
struct inet_connection_sock inet_conn;
Expand Down Expand Up @@ -273,6 +282,9 @@ struct tcp_sock {
u32 end_seq; /* Ending TCP sequence of the skb */
u32 last_delivered; /* tp->delivered at last reo_wnd adj */
u8 reo_wnd_steps; /* Allowed reordering window */
/*Phuc*/
u8 reord; /* reordering detected */
/****/
#define TCP_RACK_RECOVERY_THRESH 16
u8 reo_wnd_persist:5, /* No. of recovery since last adj */
dsack_seen:1, /* Whether DSACK seen after last adj */
Expand Down Expand Up @@ -494,6 +506,31 @@ struct tcp_sock {
char mptcp_sched_name[MPTCP_SCHED_NAME_MAX];
char mptcp_pm_name[MPTCP_PM_NAME_MAX];
#endif /* CONFIG_MPTCP */
/* shivanga: Ratio Scheduler Variables */
u32 last_probe_tstamp;
u32 in_probe;
u32 last_ac_rate;
u32 last_ratio;
u64 prev_tx_bytes;
u64 prev_tstamp;
u32 rate_est_val;
u32 rate_est_cnt;
u32 last_rate_search_start[5]; /* 5 because that's the search trigger threshold */
u32 init_buffer_size[2];
u32 last_buffer_size[2];
u8 buffer_threshold_cnt;
s32 buffer_trigger_threshold;
ratio_search_state search_state;
//u8 buf_size_acc;
struct sock *prev_sk;
unsigned int num_segments_flow_one;
int ratio_search_step;
unsigned int ratio_rate_sample;
bool run_started;
bool init_search;
/*Phuc: Ratio scheduler optimization*/
u16 head_length;
u32 num_acks_head[2];
};

enum tsq_enum {
Expand Down Expand Up @@ -536,7 +573,7 @@ struct tcp_timewait_sock {
/* The time we sent the last out-of-window ACK: */
u32 tw_last_oow_ack_time;

int tw_ts_recent_stamp;
long tw_ts_recent_stamp;
#ifdef CONFIG_TCP_MD5SIG
struct tcp_md5sig_key *tw_md5_key;
#endif
Expand Down
85 changes: 82 additions & 3 deletions include/net/mptcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ struct mptcp_options_received {

struct mptcp_tcp_sock {
struct hlist_node node;
struct tcp_sock *next; /* Next subflow socket */
struct hlist_node cb_list;
struct mptcp_options_received rx_opt;

Expand All @@ -166,6 +167,7 @@ struct mptcp_tcp_sock {
u16 map_data_len;
u16 slave_sk:1,
fully_established:1,
establish_increased:1,
second_packet:1,
attached:1,
send_mp_fail:1,
Expand All @@ -187,7 +189,7 @@ struct mptcp_tcp_sock {
u8 rem_id;
u8 sk_err;

#define MPTCP_SCHED_SIZE 16
#define MPTCP_SCHED_SIZE 64
u8 mptcp_sched[MPTCP_SCHED_SIZE] __aligned(8);

int init_rcv_wnd;
Expand Down Expand Up @@ -261,6 +263,8 @@ struct mptcp_sched_ops {
struct mptcp_cb {
/* list of sockets in this multipath connection */
struct hlist_head conn_list;
/*phuc*/
struct tcp_sock *connection_list;
/* list of sockets that need a call to release_cb */
struct hlist_head callback_list;

Expand All @@ -285,9 +289,13 @@ struct mptcp_cb {
rcv_hiseq_index:1, /* Index in rcv_high_order of rcv_nxt */
tcp_ca_explicit_set:1; /* was meta CC set by app? */

/* socket count in this connection */
u8 cnt_subflows;
u8 cnt_established;
#define MPTCP_SCHED_DATA_SIZE 8
u8 mptcp_sched[MPTCP_SCHED_DATA_SIZE] __aligned(8);
const struct mptcp_sched_ops *sched_ops;
//const struct mptcp_sched_ops *sched_ops;
struct mptcp_sched_ops *sched_ops;

struct sk_buff_head reinject_queue;
/* First cache-line boundary is here minus 8 bytes. But from the
Expand Down Expand Up @@ -343,6 +351,11 @@ struct mptcp_cb {
u32 orig_window_clamp;

struct tcp_info *master_info;

/* swetank */
u32 cnt_in_order;
u32 cnt_out_of_order;
/* end:swetankk */
};

#define MPTCP_VERSION_0 0
Expand Down Expand Up @@ -459,6 +472,18 @@ extern bool mptcp_init_failed;
#define MPTCPHDR_INF 0x08
#define MPTCP_REINJECT 0x10 /* Did we reinject this segment? */

/* swetankk */
#define MPTCP_SCHED_PROBE
#ifdef CONFIG_MPTCP_QUEUE_PROBE
#define MPTCP_QUEUE_PROBE
#endif

#ifdef MPTCP_QUEUE_PROBE
#define MPTCP_RCV_QUEUE 0x00
#define MPTCP_OFO_QUEUE 0x01
#endif
/* end: swetankk */

struct mptcp_option {
__u8 kind;
__u8 len;
Expand Down Expand Up @@ -647,6 +672,35 @@ struct mp_prio {
__u8 addr_id;
} __attribute__((__packed__));

/* swetankk */
#ifdef MPTCP_SCHED_PROBE
struct mptcp_sched_probe {
unsigned long id;
struct sock *sk;
bool selector_reject;
bool found_unused_reject;
bool def_unavailable;
bool temp_unavailable;
bool srtt_reject;
bool selected;
int split;
int skblen;
u32 tx_bytes;
u32 trans_start;
};
#endif
#ifdef MPTCP_QUEUE_PROBE
struct mptcp_queue_probe {
u8 q_id;
struct tcp_sock *meta_tp;
u32 skb_seq;
u32 skb_end_seq;
u8 op_id;
u32 q_size;
};
#endif
/* end:swetankk */

static inline int mptcp_sub_len_dss(const struct mp_dss *m, const int csum)
{
return 4 + m->A * (4 + m->a * 4) + m->M * (10 + m->m * 4 + csum * 2);
Expand All @@ -659,6 +713,22 @@ extern int sysctl_mptcp_version;
extern int sysctl_mptcp_checksum;
extern int sysctl_mptcp_debug;
extern int sysctl_mptcp_syn_retries;
/* swetankk */
extern int sysctl_mptcp_scheduler_optimizations_disabled;
extern int sysctl_mptcp_set_backup;
/* end: swetankk */
/* shivanga */
extern int sysctl_num_segments_flow_one;
extern int sysctl_mptcp_rate_sample;
extern int sysctl_mptcp_ratio_trigger_search;
extern int sysctl_mptcp_ratio_search_step;
extern int sysctl_mptcp_trigger_threshold;
extern int sysctl_mptcp_probe_interval_secs;
extern int sysctl_mptcp_ratio_static;

#define MPTCP_BYTES_NOT_SENT_MAX 165
//#define MPTCP_RATE_MAX 50
/* end: shivanga */

extern struct workqueue_struct *mptcp_wq;

Expand All @@ -668,6 +738,7 @@ extern struct workqueue_struct *mptcp_wq;
pr_err(fmt, ##args); \
} while (0)

/* Iterates over all subflows */
static inline struct sock *mptcp_to_sock(const struct mptcp_tcp_sock *mptcp)
{
return (struct sock *)mptcp->tp;
Expand All @@ -676,7 +747,6 @@ static inline struct sock *mptcp_to_sock(const struct mptcp_tcp_sock *mptcp)
#define mptcp_for_each_sub(__mpcb, __mptcp) \
hlist_for_each_entry_rcu(__mptcp, &((__mpcb)->conn_list), node)

/* Must be called with the appropriate lock held */
#define mptcp_for_each_sub_safe(__mpcb, __mptcp, __tmp) \
hlist_for_each_entry_safe(__mptcp, __tmp, &((__mpcb)->conn_list), node)

Expand Down Expand Up @@ -903,6 +973,15 @@ bool subflow_is_backup(const struct tcp_sock *tp);
struct sock *get_available_subflow(struct sock *meta_sk, struct sk_buff *skb,
bool zero_wnd_test);
extern struct mptcp_sched_ops mptcp_sched_default;
/* swetankk */
#ifdef MPTCP_SCHED_PROBE
extern void mptcp_sched_probe_init(struct mptcp_sched_probe *sprobe);
extern struct mptcp_sched_probe* mptcp_sched_probe_log_hook(struct mptcp_sched_probe* sprobe, bool selected, unsigned long sched_probe_id, struct sock *sk);
#endif
#ifdef MPTCP_QUEUE_PROBE
extern struct mptcp_queue_probe* mptcp_queue_probe_log_hook(u8 q_id, struct tcp_sock *meta_tp, struct sk_buff *skb, u8 op_id);
#endif
/* end: swetankk */

/* Initializes function-pointers and MPTCP-flags */
static inline void mptcp_init_tcp_sock(struct sock *sk)
Expand Down
4 changes: 4 additions & 0 deletions make_mptcp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
make -j8
make modules -j8
make modules_install
make install
9 changes: 9 additions & 0 deletions make_mptcp_ratio_only.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
echo "Unloading mptcp_ratio..."
rmmod mptcp_ratio
echo "Buiding mptcp submodules..."
make -C . M=net/mptcp
echo "Copying mptcp_ratio.ko..."
cp net/mptcp/mptcp_ratio.ko /lib/modules/4.19.224/kernel/net/mptcp/mptcp_ratio.ko
echo "Reloading mptcp_ratio..."
modprobe mptcp_ratio
echo "Done!"
44 changes: 44 additions & 0 deletions net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,50 @@ config NET_PKTGEN
To compile this code as a module, choose M here: the
module will be called pktgen.

config NET_TCPPROBE
tristate "TCP connection probing"
depends on INET && PROC_FS && KPROBES
---help---
This module allows for capturing the changes to TCP connection
state in response to incoming packets. It is used for debugging
TCP congestion avoidance modules. If you don't understand
what was just said, you don't need it: say N.

Documentation on how to use TCP connection probing can be found
at:

http://www.linuxfoundation.org/collaborate/workgroups/networking/tcpprobe

To compile this code as a module, choose M here: the
module will be called tcp_probe.

config NET_MPTCP_SCHED_PROBE
tristate "MPTCP scheduler probing"
depends on INET && PROC_FS && KPROBES && (MPTCP=y)
---help---
This module allows for probing the MPTCP scheduler decision and state. For
now, only the RTT scheduler is supported. If you don't understand what was
just said, you don't need it: say N. Design heavily borrowed from the famous
tcp_probe module:

http://www.linuxfoundation.org/collaborate/workgroups/networking/tcpprobe

To compile this code as a module, choose M here: the module will be called
mptcp_sched_probe.

config NET_MPTCP_QUEUE_PROBE
tristate "MPTCP meta recv and ofo queue probing"
depends on INET && PROC_FS && KPROBES && (MPTCP=y) && (MPTCP_QUEUE_PROBE=y)
---help---
This module allows for probing the MPTCP meta-level receive and out-of-order
queues. If you don't understand what was just said, you don't need it: say N.
Design heavily borrowed from the famous tcp_probe module:

http://www.linuxfoundation.org/collaborate/workgroups/networking/tcpprobe

To compile this code as a module, choose M here: the module will be called
mptcp_queue_probe.

config NET_DROP_MONITOR
tristate "Network packet drop alerting service"
depends on INET && TRACEPOINTS
Expand Down
33 changes: 33 additions & 0 deletions net/mptcp/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ config MPTCP_REDUNDANT
This scheduler sends all packets redundantly over all subflows to decreases
latency and jitter on the cost of lower throughput.

config MPTCP_RTT
tristate "MPTCP RTT"
depends on (MPTCP=y)
---help---
This is a round-trip time (RTT) based scheduler (copy of the default one). It sends
packets to the flow with the lower RTT.

config MPTCP_RATIO
tristate "MPTCP Ratio"
depends on (MPTCP=y)
---help---
This is a quota based scheduler that assigns packets to subflows based on given ratio.
It based on the design of the ROUNDROBIN scheduler which gives equal quota to all subflows.

choice
prompt "Default MPTCP Scheduler"
default DEFAULT_SCHEDULER
Expand All @@ -133,6 +147,18 @@ choice
This is the redundant scheduler, sending packets redundantly over
all the subflows.

config DEFAULT_RTT
bool "RTT" if MPTCP_RTT=y
---help---
This is a copy of default RTT-based scheduler. The only difference is that
it is built as a seperate module, making it easier to make changes to it.

config DEFAULT_RATIO
bool "Ratio" if MPTCP_RATIO=y
---help---
This is a quota based scheduler that assigns packets to subflows based on given ratio.
It based on the design of the ROUNDROBIN scheduler which gives equal quota to all subflows.

endchoice
endif

Expand All @@ -142,5 +168,12 @@ config DEFAULT_MPTCP_SCHED
default "default" if DEFAULT_SCHEDULER
default "roundrobin" if DEFAULT_ROUNDROBIN
default "redundant" if DEFAULT_REDUNDANT
default "rtt" if DEFAULT_RTT
default "ratio" if DEFAULT_RATIO
default "default"

config MPTCP_QUEUE_PROBE
bool "MPTCP Meta-Queues Instrumentation"
depends on (MPTCP=y)
---help---
This adds instrumentation in the MPTCP stack to trace meta rcv and ofo queues.
6 changes: 5 additions & 1 deletion net/mptcp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
obj-$(CONFIG_MPTCP) += mptcp.o

mptcp-y := mptcp_ctrl.o mptcp_ipv4.o mptcp_pm.o \
mptcp_output.o mptcp_input.o mptcp_sched.o
mptcp_output.o mptcp_input.o mptcp_sched.o mptcp_sched_probe_log_hook.o

obj-$(CONFIG_TCP_CONG_LIA) += mptcp_coupled.o
obj-$(CONFIG_TCP_CONG_OLIA) += mptcp_olia.o
Expand All @@ -20,5 +20,9 @@ obj-$(CONFIG_MPTCP_NETLINK) += mptcp_netlink.o
obj-$(CONFIG_MPTCP_ROUNDROBIN) += mptcp_rr.o
obj-$(CONFIG_MPTCP_REDUNDANT) += mptcp_redundant.o
obj-$(CONFIG_MPTCP_BLEST) += mptcp_blest.o
obj-$(CONFIG_MPTCP_RTT) += mptcp_rtt.o
obj-$(CONFIG_MPTCP_RATIO) += mptcp_ratio.o
obj-$(CONFIG_NET_MPTCP_SCHED_PROBE) += mptcp_sched_probe.o
obj-$(CONFIG_NET_MPTCP_QUEUE_PROBE) += mptcp_queue_probe.o

mptcp-$(subst m,y,$(CONFIG_IPV6)) += mptcp_ipv6.o
Loading