网络编程

ObjectSNMP网络拓扑发现和物理拓扑发现入门

发布制作:admin  发布日期:2011/6/8
ObjectSNMP自动搜索发现快速入门
自动搜索发现的典型API如下:
1.根据网络号和一系列SNMP参数搜索设备
public List<DeviceInfo> searchDevice(String subNetIP,List<SNMPTarget> snmpTargetList, boolean isUseICMP)

2.通过多个网络号和一系列SNMP参数(端口号、读共同体),搜索设备
public List<DeviceInfo> searchDeviceByNetList(List<String> subNetIPList,List snmpTargetList, boolean isUseICMP)

3.通过IP范围,和一系列SNMP参数(端口号、读共同体),搜索设备
public List<DeviceInfo> searchDevice(String startIP, String endIP,List snmpTargetList, boolean isUseICMP)

4.从一个或多个已知的网络,按漫游深度和漫游广度,漫游搜索到其他设备
public List<DeviceInfo> searchDeviceByIPRoaming(List<String> subNetIPList,List<SNMPTarget> snmpTargetList, boolean isUseICMP,int depth,int maxDevice)

5.从路由器上搜索设备
public List<DeviceInfo> searchDeviceByRouterNet(String subNetIP,List snmpTargetList, boolean isUseICMP)

6.获取设备的资源信息
public List<ResourceInfo> searchDeviceResource(DeviceInfo deviceInfo)

7.发现任意网络设备之间的连接关系
public List<LinkInfo> searchLinkInfo(List<DeviceInfo> allDeviceList)


一个典型搜索网络设备信息、设备类型、设备连接关系的代码如下:
List<DeviceInfo> deviceList = discoverAPI.searchDevice("192.168.1.0-92.168.10.0","public,ciscopublic");
for (DeviceInfo device : deviceList)
{
System.out.println("设备基础信息:" + device);
System.out.println("设备类型:" + device.getDeviceType());
System.out.println("主MAC地址:" + device.getDeviceMAC());
System.out.println("网管协议:" + device.getDeviceProtocol());
for (String mac : device.getDeviceMacList())
{
System.out.println("设备的MAC地址:" + mac);
}
for (MibIfEntry mibIf : device.getIfTableList())
{
System.out.println("设备的网络接口:"+mibIf);
}
for (MibMacIP mibMacIP : device.getMibMacIPList())
{
System.out.println("设备的MAC-IP地址学习表,ARP:"+mibMacIP);
}
//打印更多设备信息......
}
List<LinkInfo> linkList = discoverAPI.searchLinkInfo(deviceList);//获取连接关系
for (LinkInfo link : linkList)
{
System.out.println("发现的连接关系:"+link);
}