TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Linux Raw Sockets

169 pointsby nudinabout 7 years ago

9 comments

FigBugabout 7 years ago
If you have to deal with raw sockets, I highly recommend libtins: <a href="https:&#x2F;&#x2F;github.com&#x2F;mfontanini&#x2F;libtins" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mfontanini&#x2F;libtins</a> Makes it very easy to support multiple platforms.<p>I recently had do support for a Digidesign Pro Control (<a href="https:&#x2F;&#x2F;medias.audiofanzine.com&#x2F;images&#x2F;normal&#x2F;digidesign-pro-control-22275.jpg" rel="nofollow">https:&#x2F;&#x2F;medias.audiofanzine.com&#x2F;images&#x2F;normal&#x2F;digidesign-pro...</a>) that used it&#x27;s own ethernet protocol. Libtins made it very easy and I didn&#x27;t need to write my own driver or anything like that.
评论 #16617200 未加载
nemanjaboricabout 7 years ago
&gt; Luckily it&#x27;s easy enough to support IPv6: just replace AF_INET by AF_INET6 and <i>it will work with both IPv4 and IPv6</i>! So don&#x27;t you dare to ever use AF_INET anymore without a good excuse<p>(emphasis mine)<p>AFAIK, on many systems (think FreeBSD) this is not true:<p><a href="https:&#x2F;&#x2F;www.unix.com&#x2F;man-page&#x2F;FreeBSD&#x2F;4&#x2F;inet6&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.unix.com&#x2F;man-page&#x2F;FreeBSD&#x2F;4&#x2F;inet6&#x2F;</a><p>&gt; By default, FreeBSD does not route IPv4 traffic to AF_INET6 sockets. The default behavior intentionally violates RFC2553 for security reasons. Listen to two sockets if you want to accept both IPv4 and IPv6 traffic. IPv4 traffic may be routed with certain per-socket&#x2F;per-node configuration, however, it is not recommended to do so. Consult ip6(4) for details.
评论 #16618003 未加载
lkrubnerabout 7 years ago
The article doesn&#x27;t say why I would want to use raw sockets. The only place it comes close to giving a reason is at the end:<p>&quot;<i>This is the lowest we can get: this way ethernet frames are passed from the device driver without any changes to your application, including the full level 2 header. Likewise, when writing to the socket the user-supplied buffer hast to contain all the headers of layer 2 to 4. This is the deepest we can go in userspace – at this point we have full control of the complete ethernet frame. I hope you enjoyed our journey into the rabbit hole.</i>&quot;<p>So, presumably, I&#x27;d prefer this to UDP in a situation where I need the complete ethernet frame. But when would that be? It would have been great if the mentioned a few scenarios where this is useful.
评论 #16621198 未加载
peterwwillisabout 7 years ago
Once you create software that processes raw socket data, besides the endianness issues, the next thing you&#x27;ll realize is the incredible breadth of RFCs that are covered for even &quot;common&quot; network traffic. Write your software to parse just one RFC, and a bunch of software using that protocol still won&#x27;t work. Don&#x27;t support the optional network layers that commercial network infrastructure splices into the packets, and you&#x27;ll again miss a lot of traffic. Modern tcp&#x2F;ip stacks are really complicated.
评论 #16615720 未加载
评论 #16616180 未加载
stagbeetleabout 7 years ago
Some smart soul archived it: <a href="http:&#x2F;&#x2F;archive.is&#x2F;nt67c" rel="nofollow">http:&#x2F;&#x2F;archive.is&#x2F;nt67c</a><p>At this point, there should be a bot running that archives any post that starts getting traction. Or maybe have a HN serve a cached copy to offload the traffic? Who knows, it just seems like every blog post is killed the instant it reaches the front page.
评论 #16615614 未加载
评论 #16616901 未加载
评论 #16615536 未加载
评论 #16615499 未加载
评论 #16615710 未加载
ibottyabout 7 years ago
Aside: Can someone has any pointers on HIP? What it solves, who is behind it (is there a chance to have it supported in mainstream OSs).
评论 #16649010 未加载
majewskyabout 7 years ago
Just in case the author is reading this: I can literally not read the article on my phone due to low contrast.
评论 #16617588 未加载
评论 #16617738 未加载
hacknatabout 7 years ago
Late to the convo, but I created a go library with no C dependencies that lets you play with raw sockets on Linux:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;nathanjsweet&#x2F;zsocket" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nathanjsweet&#x2F;zsocket</a>
encodererabout 7 years ago
This is great. Somewhat orthogonal, can anybody venture a guess on if we will ever be able to open raw sockets in AWS Lambda functions or if their continued restriction is necesary for their container security model?
评论 #16616238 未加载
评论 #16615867 未加载