Windows 适配器强制工作在 L2 而且内核网络栈不管适配器 ARP 帧的解析,所以 TAP Driver 想在 Windows 上跑 TUN 模式实际上实现的时候还是 TAP 模式然后自己处理 ARP 通过 ARP Spoofing 然后去掉 IP 头来达到TUN的效果。
How2Code
Windows 适配器强制工作在 L2 而且内核网络栈不管适配器 ARP 帧的解析,所以 TAP Driver 想在 Windows 上跑 TUN 模式实际上实现的时候还是 TAP 模式然后自己处理 ARP 通过 ARP Spoofing 然后去掉 IP 头来达到TUN的效果。
回过头来看 Linux 怎么处理的。实际上在 Linux 中创建 tun interface的时候 interface 的物理地址是全 0 而且会被设置 NOARP 标志表示关闭了 ARP 协议(这样就完全工作在 L3 了),并且最终到达 tun interface 的包没有 L2 的头部只有 L3 的头部,这是内核支持的。个人理解是不同 interface 有不同的封装成帧方式,内核只交付 L3 的包。
但是在 Windows 上可能天生缺少类似的设计,所以 TAP Driver 为了实现 TUN 模式只好拿 TAP 模式去模拟。
但是在 Windows 上可能天生缺少类似的设计,所以 TAP Driver 为了实现 TUN 模式只好拿 TAP 模式去模拟。
libpcap 捕获的包长度可能大于 MTU 吗?
其实是有可能的,关键在于网卡的 Offload,简单来说操作系统为了更好的 IO 性能,可能几个包一起交付给网卡然后硬件分片/分段,然而 libpcap 工作在操作系统和网卡之间所以虽然最后发出去的包小于 MTU 但是 libpcap 看到的是大于 MTU 的啦。
其实是有可能的,关键在于网卡的 Offload,简单来说操作系统为了更好的 IO 性能,可能几个包一起交付给网卡然后硬件分片/分段,然而 libpcap 工作在操作系统和网卡之间所以虽然最后发出去的包小于 MTU 但是 libpcap 看到的是大于 MTU 的啦。
struct base1
{
virtual ~base1() { }
int value1;
};
struct base2
{
virtual ~base2() { }
int value2;
};
struct derived : public base1, public base2
{
};
int main()
{
derived obj;
base1* p1 = &obj;
base2* p2 = &obj;
assert(static_cast<void*>(p1) == static_cast<void*>(p2));
}
C++ is amazing!好吧,其实就是多继承问题。
How2Code
struct base1 { virtual ~base1() { } int value1; }; struct base2 { virtual ~base2() { } int value2; }; struct derived : public base1, public base2 { }; int main() { derived obj; base1* p1 = &obj; base2* p2 = &obj; assert(static_cast<void*>(p1)…
struct base1More amazing.
{
virtual ~base1() { }
int value1;
};
struct base2
{
virtual ~base2() { }
int value2;
};
struct derived : public base1, public base2
{
};
int main()
{
derived obj;
base1* p1 = &obj;
base2* p2 = &obj;
assert(dynamic_cast<void*>(p1) == dynamic_cast<void*>(p2));
}
原因是 dynamic_cast 返回的地址是最派生类的起始地址,也就是 &obj.
Authors can include data for inline client-side scripts or server-side site-wide scripts to process using the data-*="" attributes. These are guaranteed to never be touched by browsers, and allow scripts to include data on HTML elements that scripts can then look for and process.
From <https://html.spec.whatwg.org/multipage/introduction.html#introduction>
From <https://html.spec.whatwg.org/multipage/introduction.html#introduction>