首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Kubernetes 中的 eBPF

    BPF (Berkeley Packet Filter) 最早是用在 tcpdump 里面的,比如 tcpdump tcp and dst port 80 这样的过滤规则会单独复制 tcp 协议并且目的端口是 80 的包到用户态。整个实现是基于内核中的一个虚拟机来实现的,通过翻译 BPF 规则到字节码运行到内核中的虚拟机当中。最早的论文是这篇,这篇论文我大概翻了一下,主要讲的是原本的基于栈的过滤太重了,而 BPF 是一套能充分利用 CPU 寄存器,动态注册 filter 的虚拟机实现,相对于基于内存的实现更高效,不过那个时候的内存比较小才几十兆。bpf 会从链路层复制 pakcet 并根据 filter 的规则选择抛弃或者复制,字节码是这样的,具体语法就不介绍了,一般也不会去直接写这些字节码,然后通过内核中实现的一个虚拟机翻译这些字节码,注册过滤规则,这样不修改内核的虚拟机也能实现很多功能。

    02

    Python 中的 socket 模块

    import socket help(socket)     Functions:     socket() -- create a new socket object     socketpair() -- create a pair of new socket objects [*]     fromfd() -- create a socket object from an open file descriptor [*]     gethostname() -- return the current hostname     gethostbyname() -- map a hostname to its IP number     gethostbyaddr() -- map an IP number or hostname to DNS info     getservbyname() -- map a service name and a protocol name to a port number     getprotobyname() -- map a protocol name (e.g. 'tcp') to a number     ntohs(), ntohl() -- convert 16, 32 bit int from network to host byte order     htons(), htonl() -- convert 16, 32 bit int from host to network byte order     inet_aton() -- convert IP addr string (123.45.67.89) to 32-bit packed format     inet_ntoa() -- convert 32-bit packed format IP to string (123.45.67.89)     ssl() -- secure socket layer support (only available if configured)     socket.getdefaulttimeout() -- get the default timeout value     socket.setdefaulttimeout() -- set the default timeout value     create_connection() -- connects to an address, with an optional timeout and optional source address. 简单的介绍一下这些函数的作用: 一、socket类方法(直接可以通过socket 类进行调用) 1、gethostbyname() -- map a hostname to its IP number

    02
    领券