---
lang: ja
breaks: false
---
<style>
.ui-infobar, #doc.markdown-body { max-width: 1100px; }
</style>
# 2021-01-20 Transport Layer Protocol TCP Congestion Ops
```c=
struct tcp_congestion_ops {
struct list_head list;
u32 key;
u32 flags;
/* initialize private data (optional) */
void (*init)(struct sock *sk);
/* cleanup private data (optional) */
void (*release)(struct sock *sk);
/*
* return slow start threshold (required)
*
* Slow start phaseから高速リカバリ、輻輳回避なんかに
* 入るときに呼ばれる
*
* tcp_enter_loss(再送タイムアウトのハンドラ)で呼ばれる
*/
u32 (*ssthresh)(struct sock *sk);
/*
* do new cwnd calculation (required)
*
* ackを受けたときに呼ばれる
*
* tcp_ack(ackセグメントのハンドラ)で呼ばれる
*/
void (*cong_avoid)(struct sock *sk, u32 ack, u32 acked);
/*
* call before changing ca_state (optional)
*
* 読んで字のごとく
*/
void (*set_state)(struct sock *sk, u8 new_state);
/*
* call when cwnd event occurs (optional)
*
* enum tcp_ca_eventを参照、いろんな輻輳制御のイベントのハンドラ
* set_stateとは何が違うのか?
*/
void (*cwnd_event)(struct sock *sk, enum tcp_ca_event ev);
/*
* call when ack arrives (optional)
*
* dctcpとwestwoodでしか使われてない
*/
void (*in_ack_event)(struct sock *sk, u32 flags);
/*
* new value of cwnd after loss (required)
*
* undo == 輻輳windowを減らすのをやめる
*
* https://par.nsf.gov/servlets/purl/10105050
* のtcp undo schenario
* パケットロス検知が誤っていた場合に輻輳ウィンドウを元の状態に戻す
*/
u32 (*undo_cwnd)(struct sock *sk);
/*
* hook for packet ack accounting (optional)
*/
void (*pkts_acked)(struct sock *sk, const struct ack_sample *sample);
/* override sysctl_tcp_min_tso_segs */
u32 (*min_tso_segs)(struct sock *sk);
/* returns the multiplier used in tcp_sndbuf_expand (optional) */
u32 (*sndbuf_expand)(struct sock *sk);
/* call when packets are delivered to update cwnd and pacing rate,
* after all the ca_state processing. (optional)
*/
void (*cong_control)(struct sock *sk, const struct rate_sample *rs);
/* get info for inet_diag (optional) */
size_t (*get_info)(struct sock *sk, u32 ext, int *attr,
union tcp_cc_info *info);
char name[TCP_CA_NAME_MAX];
struct module *owner;
};
```
### Memo
- Linuxの輻輳制御の実装解説: https://par.nsf.gov/servlets/purl/10105050