sniffer.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:Charlie 作者: nxintech 项目源码 文件源码
def __init__(self, interface_name, on_ip_incoming, on_ip_outgoing):

        self.interface_name = interface_name
        self.on_ip_incoming = on_ip_incoming
        self.on_ip_outgoing = on_ip_outgoing

        # The raw in (listen) socket is a L2 raw socket that listens
        # for all packets going through a specific interface.
        # SOL_SOCKET: SO_LINGER, SO_RCVBUF, SO_SNDBUF, TCP_NODELAY
        # SO_LINGER ???????????????????TIME_WAIT?????
        # ????????????????????tcp??
        # SO_RCVBUF?SO_SNDBUF ????????????????
        # SO_SNDBUF ?? MSS??????? 2MSS
        # TCP_NODELAY  ?? nagle ??
        self.sock = socket.socket(
            socket.AF_PACKET, socket.SOCK_RAW, socket.htons(ETH_P_IP))
        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 2 ** 30)
        self.sock.bind((self.interface_name, ETH_P_IP))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号