网络与分布式2017tuprints.ulb.tu-darmstadt.de
RAW 套接字入门
Introduction to RAW-sockets
进阶 · 约 35 分钟读完前置知识:C 语言、Socket 编程、TCP/IP 基础
导读
这是一份来自达姆施塔特工业大学的英文技术报告,系统介绍原始套接字(RAW sockets)的编程方法:并排展示原始套接字 API 与常用库的用法,覆盖 socket 家族选择等基础内容。评论者认为,它是适合入门的实用手册,但在 IPv6 细节(如 recvmsg 与辅助数据获取)上略显单薄。
HN 关注点:这份少见且讲解清楚的原始套接字入门资料,讨论很快转向更深入的学习路径,即直接阅读 Linux 内核源码,以及手册本身的错误与不足。
HN 评论精选
这几条评论里:质疑 1 补充 1 亲历 1
补充认可并排对比 API 与库的做法,但指出 IPv6 内容不足、漏掉 recvmsg。
手册不错,它把原始套接字 API 和常用库并排展示,值得肯定。不过粗略翻下来,IPv6 部分偏薄,比如没有提到 recvmsg,而要从 IPv6 ICMP 包接收辅助数据时,这个函数必不可少。
d215查看英文原文
Nice manual. Good to see that they show the raw sockets api and libraries using them side by side. Skimming through it though, it a eems a bit thin on ipv6 details, e.g. recvmsg is not mentioned, but is indispensable for receiving ancillary data from ipv6 icmp packets.
亲历亲历建议:直接读内核源码比教程更有效,并附上 PACKET_MMAP 笔记与源码检索工具。
这是不错的入门,但以我个人学 Linux 原始套接字编程的经历,我强烈建议直接去读内核源码。我原本担心 C 只是业余爱好、会太难,结果这反而是理解一切如何运作的最好方式;读懂内核源码之后,我后悔没早点这么做。比如教程提到 AF_PACKET 是可选 socket 家族之一,我想深入了解它提供的 PACKET_MMAP,但内核文档和示例我看不懂;因为害怕,我把读源码放到最后,其实应该最先做。要做这事建议记笔记,并注意特性随内核版本变化。我把 v2、v3 的 PACKET_MMAP 发送流程笔记放在 GitHub wiki 上,接收部分的笔记还没上传,v4 就已写完并将进入最新内核,所以按内核版本记笔记很有用。另外 elixir.free-electrons.com 用来阅读和搜索内核源码非常方便。
jwbensley查看英文原文
A good introduction but through my personal journey to learn about raw socket programming in Linux, I can't recommend just diving in and reading the kernel source code enough. I feared this as C is a hobby for me so I assumed it would be too difficult but for me it turned out to be the best way to understand how everything works and I was able to understand the Kernel source, I wish I had done this earlier. E.g. AF_PACKET is mentioned in this tutorial as one of the potential socket families, I wanted to learn more about the PACKET_MMAP feature AF_PACKET provides however the kernel documentation and examples weren't clear to me. I ended up reading the kernel source last because I was intimidated and should have done that first. If anyone is going to do this I recommend you take notes. Note that features change between kernel versions. I started making notes on how v2 and v3 transmition of PACKET_MMAP works here: https://github.com/jwbensley/EtherateMT/wiki/Linux-Kernel-tracing-for-sendto()-using-AF_PACKET,-PACKET_MMAP-and-PACKET_FANOUT I actually need to upload the receive notes. But before I've had time to do that, v4 has been written and is about to drop in the latest kernel version. So making notes in relation to kernel version I have found to be very helpful. Also this site is super helpful for reading and searching the kernel source: http://elixir.free-electrons.com/linux/latest/source
相关资源
从这篇论文所有 HN 讨论帖的全部评论里整理出来的链接。
历次讨论
- 2017Hacker News 讨论帖145 分 · 8 评
同领域还值得读
Paxos vs. Raft:分布式共识是否已达成共识?
Paxos vs. Raft: Have we reached consensus on distributed consensus?
重新审视了 Paxos 与 Raft 两种分布式共识算法之间的差异,试图在一个统一的框架下比较它们,并论证二者的相似程度远高于通常的认知,许多所谓的差别只是表述层面的。
网络与分布式2020 · 343 分 · 65 评 · 引用 10进阶 · 约 28 分钟编辑精选Stellar 协议:互联网级共识的联邦模型
Stellar Protocol: A Federated Model for Internet-Level Consensus (2016)
提出 Stellar Consensus Protocol(SCP),一种面向互联网级共识的联邦拜占庭协议模型。
网络与分布式2018 · 301 分 · 61 评专业 · 约 90 分钟编辑精选拜占庭将军问题(1982)
The Byzantine Generals Problem (1982)
这篇 1982 年论文提出并形式化了拜占庭将军问题:在分布式系统中,部分节点可能叛变或故障、通信不可完全信任时,忠诚节点如何达成一致行动。
网络与分布式2018 · 290 分 · 77 评进阶 · 约 75 分钟编辑精选Google 变差了吗?对搜索引擎中 SEO 垃圾的纵向调查
Is Google Getting Worse? A Longitudinal Investigation of SEO Spam in Search
对搜索引擎结果中的 SEO 垃圾内容做了纵向追踪:作者团队在一段时间内持续采集 Google、Bing、DuckDuckGo 等引擎针对商品评测类查询的结果,用分类器识别联盟营销…
网络与分布式2024 · 276 分 · 274 评入门 · 约 45 分钟编辑精选使 CRDT 能够容忍拜占庭故障
Making CRDTs Byzantine Fault Tolerant
Martin Kleppmann 等人的论文研究如何让 CRDT(无冲突复制数据类型)抵御拜占庭故障节点,即部分参与者恶意篡改数据时仍能保证一致性。
网络与分布式2022 · 266 分 · 40 评进阶 · 约 90 分钟编辑精选