Я использовал NetworkInterface.getNetworkInterfaces()
для запроса сетевых интерфейсов на моем компьютере.По сути, я пытаюсь найти сетевые карты.Они обычно называются что-то вроде eth0, eth1 и т. Д.
Отлично работает на win xp и даже виста с небольшой фильтрацией.
Я только что заметил, что в некоторых конфигурациях windows 7 я получаюбольшое количество перечисленных сетевых адаптеров.Намного больше, чем на XP и Vista.У меня настроена только одна карта, но, похоже, есть три различных сетевых интерфейса
- Сетевое соединение Intel® R (82567LM-3)
- Сетевое подключение Intel (R) 82567LM-3 -Планировщик пакетов QoS-0000
- Intel (R) 82567LM-3 Gigabit Network Connection-WFP LightWeight Filter-0000
Почему 3 разных точки по сути одно и то же.
У меня также есть шесть записей для чего-то под названием WAN MINIPORT.(См. Вывод ниже)
Я могу отфильтровать их, но, конечно, затраты на выполнение такого большого дерьма, конечно же, снижаются.Кто-нибудь знает, почему эти записи создаются и как их минимизировать?
В качестве примера на моей системе я написал такой код
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import static java.lang.System.out;
public class ListNetsEx {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Enumeration<NetworkInterface> nets;
try {
nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets))
displayInterfaceInformation(netint);
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
// TODO Auto-generated method stub
out.printf("Display name: %s\n", netint.getDisplayName());
out.printf("Name: %s\n", netint.getName());
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
out.printf("InetAddress: %s\n", inetAddress);
}
out.printf("Up? %s\n", netint.isUp());
out.printf("Loopback? %s\n", netint.isLoopback());
out.printf("PointToPoint? %s\n", netint.isPointToPoint());
out.printf("Supports multicast? %s\n", netint.supportsMulticast());
out.printf("Virtual? %s\n", netint.isVirtual());
out.printf("Hardware address: %s\n",
Arrays.toString(netint.getHardwareAddress()));
out.printf("MTU: %s\n", netint.getMTU());
out.printf("\n");
}
}
На Windows 7 вывод
Display name: Software Loopback Interface 1
Name: lo
InetAddress: /0:0:0:0:0:0:0:1
InetAddress: /127.0.0.1
Up? true
Loopback? true
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: []
MTU: -1
Display name: WAN Miniport (SSTP)
Name: net0
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: WAN Miniport (IKEv2)
Name: net1
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: WAN Miniport (L2TP)
Name: net2
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: WAN Miniport (PPTP)
Name: net3
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: WAN Miniport (PPPOE)
Name: ppp0
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: WAN Miniport (IPv6)
Name: eth0
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: WAN Miniport (Network Monitor)
Name: eth1
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: WAN Miniport (IP)
Name: eth2
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: RAS Async Adapter
Name: ppp1
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: Intel(R) 82567LM-3 Gigabit Network Connection
Name: eth3
InetAddress: /fe80:0:0:0:b1b1:7531:17b1:bf26%11
InetAddress: /172.24.9.148
Up? true
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: [120, 43, -53, 125, -80, 74]
MTU: 1500
Display name: Microsoft ISATAP Adapter
Name: net4
Up? false
Loopback? false
PointToPoint? true
Supports multicast? false
Virtual? false
Hardware address: [0, 0, 0, 0, 0, 0, 0, -32]
MTU: 1280
Display name: Teredo Tunneling Pseudo-Interface
Name: net5
InetAddress: /fe80:0:0:0:e0:0:0:0%13
Up? false
Loopback? false
PointToPoint? true
Supports multicast? false
Virtual? false
Hardware address: [0, 0, 0, 0, 0, 0, 0, -32]
MTU: 1280
Display name: Microsoft ISATAP Adapter #2
Name: net6
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: Intel(R) 82567LM-3 Gigabit Network Connection-QoS Packet Scheduler-0000
Name: eth4
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: Intel(R) 82567LM-3 Gigabit Network Connection-WFP LightWeight Filter-0000
Name: eth5
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: WAN Miniport (Network Monitor)-QoS Packet Scheduler-0000
Name: eth6
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: WAN Miniport (IP)-QoS Packet Scheduler-0000
Name: eth7
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1
Display name: WAN Miniport (IPv6)-QoS Packet Scheduler-0000
Name: eth8
Up? false
Loopback? false
PointToPoint? false
Supports multicast? true
Virtual? false
Hardware address: null
MTU: -1