network topology
I'm trying to build an application that would display network topology, using c or maybe c++. I have knowledge of sockets. I know this a broad question with little details. It's just that i haven't found anyt开发者_如何学Pythonhing to start from. I have no idea what to do.
This, like any problem you are faced with in life, requires a clear definition of the problem. And you'll need to break it down into parts.
Firstly, do you need to "discover" the topology, or do you already have it supplied in a text file somewhere? Is your requirement merely to graph the topology (in which case a program called "graphviz" will probably already do the job you require)? If you have to discover the topology, what kind of network is it? LAN? WAN? TCP/IP? Something else?
Then you have to ask yourself why you want to use C or C++ - it would appear from your question that you have not much experience with networks - thus it is not apparent why you would want to go to the trouble of using a low-level language to undertake your chosen task. Perhaps a high level language would be appropriate in the near term.
Be aware that many have faced the same challenge you have - graphing a network topology; thus there are many applications that do just this. Perhaps you could elaborate on your reasons for wanting to attempt this task yourself?
I'm going to make some assumptions:
1. You have network connectivity to the equipment.
2. You have or can receive SNMP-read privileges.
Most network devices can communicate with SNMP. From the SNMP information you can determine loads of information about the device. Among the information you can get is "CDP" and "LLDP" information. "CDP" being Cisco's proprietary protocol for neighbour information and "LLDP" being and open standard which Cisco devices generally also support.
If the devices do not have CDP or LLDP running and you cannot turn it on you can instead use FDB (Forwarding Database). Which means that you match the MAC adress of an interface device, which you get with SNMP, to the MAC address table of other devices interfaces. This is a bit more complex since the MAC address can show up on multiple interfaces. I don't know the exact way it is represented though.
So for the logical part of figuring out how things are connected I thing this is the way to go. The graphical parts someone else will have to help you with.
精彩评论