V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
1314258
V2EX  ›  分享发现

原来 socket.SOCK_RAW 在 os x 下不能抓到包。

  •  
  •   1314258 · 2015-05-25 18:18:36 +08:00 · 2382 次点击
    这是一个创建于 3273 天前的主题,其中的信息可能已经有所发展或是发生改变。
    IGMP包是可以的。但tcp和udp是不能的。
    第 1 条附言  ·  2015-05-25 18:57:02 +08:00
    FreeBSD takes another approach. It *never* passes TCP or UDP packets to raw
    sockets. Such packets need to be read directly at the datalink layer by using
    libraries like libpcap or the bpf API. It also *never* passes any fragmented
    datagram. Each datagram has to be completeley reassembled before it is passed
    to a raw socket.
    FreeBSD passes to a raw socket:
    a) every IP datagram with a protocol field that is not registered in
    the kernel
    b) all IGMP packets after kernel finishes processing them
    c) all ICMP packets (except echo request, timestamp request and address
    mask request) after kernel finishes processes them
    2 条回复    2018-10-25 00:12:15 +08:00
    auser
        1
    auser  
       2015-05-25 22:13:58 +08:00 via Android
    可以在内核里头写扩展抓 ╯﹏╰
    autogen
        2
    autogen  
       2018-10-25 00:12:15 +08:00
    macOS 下居然能发 raw ip 包,不会[Error 22] invalid argument 吗
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2598 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:53 · PVG 23:53 · LAX 08:53 · JFK 11:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.