linux TCP协议
文章平均质量分 70
already_skb
协议设计 — 用最简单的逻辑,最大化可实现的软件功能。
展开
-
TCP cookie代码走读
TCP syncookie原创 2022-03-06 18:42:24 · 3295 阅读 · 1 评论 -
BPF_PROG_TYPE_SOCKET_FILTER 功能实现
BPF_PROG_TYPE_SOCKET_FILTER,从宏字面意思比较容易想到实现的是socket filter功能,它区别于sockops和tracepoint等功能,需要额外借助setsockopt能力将功能函数和socket绑定,功能才能真正生效。如何定该类型在内核态功能函数中定义SEC("socketxxxx"),则会被解析为BPF_PROG_TYPE_SOCKET_FILTER类型功能。比如内核中实现的三个example程序:samples/bpf/sockex1_kern.c -原创 2022-02-20 14:07:02 · 1700 阅读 · 0 评论 -
ebpf xdp 挂载点分析
1. 查看支持xdp功能的网卡drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c:218: case XDP_SETUP_PROG:drivers/net/ethernet/cavium/thunder/nicvf_main.c:1848: case XDP_SETUP_PROG:drivers/net/ethernet/intel/i40e/i40e_main.c:11845: case XDP_SETUP_PROG:drivers/net/ethern原创 2022-02-19 22:00:41 · 1135 阅读 · 0 评论 -
ebpf tracepoint 功能分析
1. 查看系统支持的所有tracepointfind /sys/kernel/debug/tracing/events -type d可以查看到当前系统支持的所有tracepoint函数点,大家在利用tracepoint功能的时候最好先看看对应的子系统在那些地方有hook点,评估是否能满足功能。比如说你想内视TCP协议栈,那么你可以先tcp trace 支持那些功能:[root@xxx tcp]# ls /sys/kernel/debug/tracing/events/tcpenable t..原创 2022-02-19 22:08:02 · 1564 阅读 · 0 评论 -
ebpf sockops 代码解读
2032 static inline int tcp_call_bpf(struct sock *sk, int op, u32 nargs, u32 *args)2033 {2034 struct bpf_sock_ops_kern sock_ops;2035 int ret;20362037 memset(&sock_ops, 0, offsetof(struct bpf_sock_ops_kern, temp));2038 .原创 2022-02-19 18:08:54 · 1636 阅读 · 0 评论 -
ebpf sockops 功能分析
ebpf sockops 实现原理大家肯定好奇为什么通过ebpf sockops可以提取我们想要的数据 ?正常来说实现方式有两种,第一种是关键路径上埋钩子函数;第二种是kprobe的粘贴插入。 ebpf sockops 是通过第一种实现的,在关键路径上埋钩子函数了,所以想要扩展功能难哦,一般在内核版本升级时可以提前规划埋好钩子函数。ebpf sockops 支持那些功能ebpf sockops支持那些功能(关键看在什么路径上埋了钩子函数),看 下面代码吧...原创 2022-02-18 11:34:39 · 1578 阅读 · 3 评论 -
BBR 每秒带宽换算逻辑
/* Scale factor for rate in pkt/uSec unit to avoid truncation in bandwidth* estimation. The rate unit ~= (1500 bytes / 1 usec / 2^24) ~= 715 bps.* This handles bandwidths from 0.06pps (715bps) to 256Mpps (3Tbps) in a u32.* Since the minimum window i...原创 2022-01-19 15:04:59 · 300 阅读 · 0 评论 -
BBR拥塞控制状态机分析
目录BBR 源码文件的描述四个阶段理想状态图STARTUP进入和退出条件DRAIN进入和退出条件PROBE_BW进入和退出条件PROBE_RTT进入和退出条件PROBE_BW内部状态分析PROBE_UP状态进入和退出PROBE_DOWN状态进入和退出PROBE_USE状态进入和退出后续BBR 源码文件的描述* A BBR flow starts in STARTUP, and ramps up its sending rate quic..原创 2022-01-19 11:47:55 · 2562 阅读 · 0 评论 -
TCP receive_queue prequeue backlog
接收到数据包时struct sock *sk 可能被进程下上文或者中断上下文占用:1、如果被进程上下文使占用时,软中断暂时拿不到锁,所以数据只能暂存在后备队列中(backlog),当进程上下文逻辑处理完成后会回调tcp_v4_do_rcv处理backlog队列作为补偿,具体看tcp_sendmsg 函数 release_sock的实现。2、如果sk被软中断占用时,那么数据可能被放置到rec原创 2015-03-31 09:46:32 · 1464 阅读 · 1 评论 -
tso硬件分片是头部拷贝问题
//skb->date指向了二层头部地址,下面是计算 以太网头 + IP头 大小static inline int skb_transport_offset(const struct sk_buff *skb){ return skb_transport_header(skb) - skb->data;}static int e1000_tso(struct e1000_adapter...原创 2018-06-28 16:40:20 · 853 阅读 · 0 评论 -
SYSCALL_DEFINE5 setsockopt 代码流程
SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname, char __user *, optval, int, optlen){ int err, fput_needed; struct socket *sock; if (optlen < 0) return -...原创 2018-12-14 14:47:41 · 609 阅读 · 0 评论 -
RFC 793 为什么要发送reset,什么情况下发送reset
A variety of other cases are possible, all of which are accounted for by the following rules for RST generation and processing. Reset Generation As a general rule, reset (RST) must be sent w...原创 2018-05-19 11:02:45 · 425 阅读 · 0 评论 -
什么时候去发送 update windos报文
/* Clean up the receive buffer for full frames taken by the user, * then send an ACK if necessary. COPIED is the number of bytes * tcp_recvmsg has given to the user so far, it speeds up the * calcula...原创 2018-05-18 22:35:01 · 453 阅读 · 0 评论 -
mysql bin 安装
mysql 安装原创 2016-07-16 08:42:36 · 411 阅读 · 0 评论 -
Controlling which congestion control algorithm is used in Linux
set congestion control algorithm per-socket转载 2016-07-11 21:11:29 · 375 阅读 · 0 评论 -
数据包在用户空间的状态
iptable 状态转载 2016-06-24 18:46:01 · 1090 阅读 · 0 评论 -
Coping with the TCP TIME-WAIT state on busy Linux servers
Coping with the TCP TIME-WAITstate on busy Linux serversVincent BernatFebruary 24, 2014Also available in FrançaisFiled under NetworkTwitter Google+转载 2015-04-06 09:43:37 · 807 阅读 · 0 评论 -
linux kernel 2.6.35中RFS特性详解
本文链接地址: linux kernel 2.6.35中RFS特性详解前面我介绍过google对内核协议栈的patch,RPS,它主要是为了软中断的负载均衡,这次继续来介绍google 的对RPS的增强path RFS(receive flow steering),RPS是把软中断map到对应cpu,而这个时候还会有另外的性能影响,那就是如果应用程序所在的cpu和软中断处理的cpu不是转载 2015-03-31 15:20:52 · 612 阅读 · 0 评论 -
MTU与MSS的关系
网上看到一张MTU与MSS关系图,非常直观,图如下:转载 2015-03-08 12:23:21 · 603 阅读 · 0 评论 -
linux tcp SACK分析(一)
why should SACK be designed ? TCP may experience poor performance when multiple packets are lost from one window of data. With the limited information available from cumulative acknowledgments原创 2015-03-08 10:39:06 · 2286 阅读 · 0 评论 -
Blind Data Injection Attack
TCP has historically been considered to be protected against spoofedoff-path packet injection attacks by relying on the fact that it is difficult to guess the 4-tuple (the source and destination IP原创 2015-03-04 08:57:22 · 1282 阅读 · 0 评论 -
Linux Per-CPU Data
Linux Per-CPU DataReasons for Using Per-CPU DataThere are a couple benefits to using per-CPU data. The first is the reduction inlocking requirements(减少locking的使用需求). Depending on thesemantics by原创 2015-03-01 21:44:22 · 823 阅读 · 0 评论 -
TCP BIC 拥塞控制源码分析
对于TCP协议数据传输优化来说最大的难点就在于物理带宽的估计,网络的复杂性决定了拥塞控制算法作用的有限性和Linux内核支持的拥塞控制算法(reno newreno hybla bic cubic westwood vegas yeah等)的多样性。 只有准确的带宽估计才能够充分的利用带宽,所以当前的主要难点是带宽估计。 BIC 主要用来解决高速大延时网络(High-spe原创 2015-02-12 09:01:12 · 1440 阅读 · 0 评论 -
/proc/kallsyms
T The symbol is in the text(code) sectionD The symbol is in the initialized data sectionR The sysbol is in a read only data sectiont staticd staticR constr static const转载 2016-08-04 15:46:12 · 501 阅读 · 0 评论 -
wireshark 关键词
wireshark词义转载 2016-10-17 11:20:38 · 548 阅读 · 0 评论 -
Tcpdump抓包内核代码分析
注册pf_packet协议 .create函数是在PF_PACKET类型socket创建时调用,调用时注册了钩子函数具体看packet_create函数的实现。static const struct net_proto_familypacket_family_ops = { .family= PF_PACKET, .create= packet_creat...原创 2018-05-08 20:10:41 · 1998 阅读 · 0 评论 -
Linux awk正则表达式简介
awk正则匹配转载 2017-09-12 11:22:58 · 576 阅读 · 0 评论 -
收包函数调用流程
linux 内核数据报文接收流程[70977.808241] [] ? tcp_ack+0xd8a/0x1390 [70977.887555] [] ? tcp_rcv_established+0x18a/0x6a0[70977.978619] [] ? tpacket_rcv+0x50/0x800[70978.044437] [] ? tcp_v4_do_rcv+0x1原创 2017-07-31 09:40:03 · 693 阅读 · 0 评论 -
TCP 指定源端口
TCP 指定源端口转载 2017-06-20 19:51:04 · 3129 阅读 · 0 评论 -
tcp jprobe 利用问题定位
tcp问题定位jprobe原创 2017-03-20 13:05:08 · 402 阅读 · 0 评论 -
Kernel Debugging Tricks
Kernel Debugging Tricks转载 2017-02-28 18:50:04 · 389 阅读 · 0 评论 -
kretprobe 使用
Kretporbe使用原创 2017-01-15 11:36:21 · 1706 阅读 · 0 评论 -
内核gdb模块调试
内核模块gdb调试原创 2016-12-31 13:49:09 · 726 阅读 · 2 评论 -
tcp_clean_rtx_queue函数
tcp_clean_rtx_queue函数阅读浅记原创 2016-12-12 09:26:57 · 1361 阅读 · 0 评论 -
Hybrid Start(混合慢启动)
Standard slow start does not work well under large bandwidth-delay product (BDP) networks. We find two causes of this problemin existing three popular operating systems, Linux, FreeBSD and Windows X原创 2015-02-11 13:29:11 · 1870 阅读 · 0 评论