问题描述
我想知道为什么 GetIpAddrTable
返回的网络适配器少于 GetAdaptersAddresses
的根本原因.候选理由如下(根据答案更新).
I would like to know the root cause of why GetIpAddrTable
would return fewer network adapters than GetAdaptersAddresses
. Candidate reasons are given below (updated per answers).
- IPv6 适配器:这些只会显示
GetAdaptersAddresses
.在此示例中,我有一个适配器的案例,该适配器具有 IPv4 和 IPv6 的链路本地 IP 地址,但未显示在 GetIpAddrTable 的输出中.
- IPv6 adapters: These will only show up for
GetAdaptersAddresses
. In this example I have a case of an adapter with link-local IP addresses for both IPv4 and IPv6 that does not show up in output from GetIpAddrTable.
我正在调查运行 Windows 7 64 位家庭高级版(版本:6.1.7601 Service Pack 1 Build 7601)的特定戴尔笔记本电脑上 GetIpAddrTable
函数的问题.有问题的系统无法通过 GetIpAddrTable
检测到某些网络适配器.诊断结果如下.
I'm investigating a problem with the GetIpAddrTable
function on a specific Dell laptop running Windows 7 64-bit Home Premium (version: 6.1.7601 Service Pack 1 Build 7601). The system in question is unable to detect certain network adapters via GetIpAddrTable
. Diagnostic results are given below.
谁能解释为什么我会从这两个函数中看到如此截然不同的结果?我们已经使用 GetIpAddrTable
近两年没有出现任何问题.
Can anyone explain why I might see such wildly different results from these two functions? We've been using GetIpAddrTable
for close to two years without any problems.
文档 for GetIpAddrTable
表示链接状态检测可能会导致 XP 出现问题,但它没有给出适配器根本不显示的任何原因.似乎不包括虚拟适配器,但我们的设备不是虚拟适配器(它是基于 USB 的以太网).
The documentation for GetIpAddrTable
indicates that link state detection may cause problems for XP, but it does not give any reasons why adapters would not show up at all. It appears that virtual adapters are not included, but our device is not a virtual adapter (it is Ethernet over USB).
在 Windows Server 2008 和 Windows Vista 上,返回的 IPv4 地址通过 GetIpAddrTable 函数不受媒体感知的影响本地计算机上 TCP/IP 堆栈的功能.GetIpAddrTable函数仅返回有效的 IPv4 地址.
在我对这个系统进行的测试中,我们有一个有效的连接,但它只由 GetAdaptersAddresses
报告,而不是 GetIpAddrTable
.我怀疑 Windows 认为适配器无效,但我不确定要测试什么来确认这个理论.数据包流入和流出设备,只是在 IPv4 地址映射表中不可见.
In the testing I've conducted on this system we have a valid connection, but it is only reported by GetAdaptersAddresses
, not GetIpAddrTable
. I suspect that Windows thinks the adapter is not valid, but I'm not sure what to test to confirm this theory. Packets are flowing to and from the device, it just isn't visible in the IPv4 address mapping table.
- 我们使用 Belcarra USBLAN 以太网小工具驱动程序(为我们公司定制)
- 我们希望我们的设备通过 DHCP 为主机和设备注册
- 驱动程序提供 DHCP
- 我们的第一个主机适配器是 169.254.142.9
- 我们的第一个设备适配器是 169.254.142.10
- 不会从外部路由到我们设备的流量(本地链接)
通常我们希望看到两个或三个网络适配器,而不是环回适配器.也许此列表中存在 127.0.0.1 是问题的一部分 - 通常不会在工作机器上观察到.
Normally we would expect to see two or three network adapters and never the loopback adapter. Perhaps the presence of 127.0.0.1 in this list is part of the problem - it isn't normally observed on a working machine.
- 适配器 1:软件环回接口 1
- 适配器 2:英特尔(R) Centrino(R) Wireless-N 1030
我已经按照返回的顺序列出了此函数返回的适配器.强调来自第一次调用的匹配适配器.ipconfig 输出中唯一不存在的适配器是粗体.
I've listed the adapters returned by this function in the order that they were returned. Matching adapters from the first call are emphasized. The only adapter not present in ipconfig output is in bold.
- 适配器 1:USBLAN 适配器
- 适配器 2:Microsoft 虚拟 WiFi 微型端口适配器
- 适配器 3:蓝牙设备(个域网)
- 适配器 4:英特尔(R) Centrino(R) Wireless-N 1030
- 适配器 5:Realtek PCIe GBE 系列控制器
- 适配器 6:软件环回接口 1
- 适配器 7:Microsoft ISATAP 适配器
- 适配器 8:Microsoft ISATAP 适配器 #2
- 适配器 9:Teredo 隧道伪接口
- 适配器 10:Microsoft ISATAP 适配器 #3
- 适配器 11:Microsoft ISATAP 适配器 #4
- 适配器 12:Microsoft ISATAP 适配器 #5
请注意,软件环回适配器是唯一一个不存在的 - 这表明 ipconfig 正在使用第二个函数或内部类似的接口.
Notice that the software loopback adapter is the only one not present - which indicates that ipconfig is using the second function or a similar interface internally.
- 适配器 1:USBLAN 适配器
- 适配器 2:Microsoft 虚拟 WiFi 微型端口适配器
- 适配器 3:蓝牙设备(个域网)
- 适配器 4:英特尔(R) Centrino(R) Wireless-N 1030
- 适配器 5:Realtek PCIe GBE 系列控制器
- 适配器 6:Microsoft ISATAP 适配器
- 适配器 7:Microsoft ISATAP 适配器 #2
- 适配器 8:Teredo 隧道伪接口
- 适配器 9:Microsoft ISATAP 适配器 #3
- 适配器 10:Microsoft ISATAP 适配器 #4
- 适配器 11:Microsoft ISATAP 适配器 #5
看起来ipconfig/all
命令返回的数据与GetAdaptersAddresses
相同,但软件回送接口除外.我目前正在考虑将我们的库切换为使用 GetAdaptersAddresses
以解决此问题,但我担心 GetIpAddrTable
未返回预期结果的原因.提前感谢您的任何意见!
It appears that the ipconfig /all
command is returning the same data as GetAdaptersAddresses
with the exception of the software loopback interface. I am currently looking at switching our library to use GetAdaptersAddresses
in order to plug this issue, but I'm concerned about why GetIpAddrTable
is not returning expected results. Thanks in advance for any input!
推荐答案
GetIpAddrTable()
只返回 IPv4 接口.
GetIpAddrTable()
only returns IPv4 interfaces.
GetAdaptersAddresses()
返回 IPv4 和/或 IPv6 适配器,单个适配器可以分配多个 IP 地址.
GetAdaptersAddresses()
returns IPv4 and/or IPv6 adapters, and single adapter can have multiple IP addresses assigned to it.
您正在比较苹果和橙子,并想知道为什么您的苹果比橙子少.
You are comparing apples and oranges, and wondering why you have fewer apples than oranges.
这篇关于GetIpAddrTable 返回的适配器列表与 GetAdaptersAddresses 不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!