A kind of method based on SNMP and HTML5 realization web network topology
Technical field
The present invention relates to the network management technology field, be specifically related to a kind of based on SNMP(Simple Network Management Protocol, Simple Network Management Protocol) and HTML5(Hypertext Markup Language 5, HTML 5) realize the method for web network topology.
Background technology
Along with the continuous quickening of information-based step, each business unit also grows with each passing day for the dependence of network office.The scale of network and complexity are also just increasing like this, difficulty to network management is also increasing, the Internet resources controllability is reduced, the stability of whole network has also been brought very large risk, so the concept of network topology occurred, the structural relation of each inter-entity in the network topology energy reaction network.Network Topology Design ground quality has significant impact to performance and the economy of whole network.The network management personnel locates fast to malfunctioning node on the basis of topological diagram.The network topology technology of present basic B/S structure mainly contains following several technology Flex SVG etc., but drawback is arranged separately.
The network topology that realizes based on technology such as Flex SVG now accounts for very most of, and these several technology are each have their own drawback all, although the Flex effect is fine, but relies on third-party service with Java data interaction sexual needs.Although SVG is good aspect drawing, browser will plug the part support, and compatible aspect is not fine, experiences existing problems the user.Select general limitation very large in self-defined topological sum self-discovery topology, can not be good be joined together.
Summary of the invention
The invention provides a kind of method based on SNMP and HTML5 realization web network topology, described method comprises:
Step S1 selects to carry out self-defined topology or self-discovery topology, when selecting to carry out described self-defined topology, and execution in step S2 ', when selecting to carry out described self-discovery topology, execution in step S2;
Step S2 ' utilizes SNMP that all resources in the network of the IP of appointment tabulation or the network segment are surveyed, with the IP, resource name and the resource type that detect together as in the self-defined network topology resource write into Databasce, execution in step S3 ';
Step S3 ', the topological relation of User Defined network, execution in step S4 ';
Step S4 ', resource type according to each topological resource loads all described topological resources to the network topology edit page, calculate the coordinate of each described topological resource on described network topology edit page, picture corresponding to resource type that shows each described topological resource at described network topology edit page, draw Topology Management line, execution in step S5 according to topological relation with the painting function of the Canvas of HTML5;
Step S2 utilizes SNMP that all resources are surveyed, and the self-discovery network topology resource that detects is write in the described database execution in step S3;
Step S3, resource analysis obtains self-discovery network topology, execution in step S4 according to described self-discovery network topology;
Step S4, attribute according to described topological resource is shown to described topological resource in the described network topology edit page painting canvas, calculate the coordinate of each described topological resource on described network topology edit page, draw Topology Management line, execution in step S5 according to described self-discovery network topology with the painting function of the Canvas of HTML5;
Step S5 carries out network availability according to the IP of described topological resource to described topological resource and detects, and the problem that detects is write carry out alarm prompt in the alarm subsystem.
In the first preferred embodiment provided by the invention: described step S3, resource analysis obtains the self-discovery network topology and specifically comprises according to the self-discovery network topology:
Step S301, obtain the subnet tabulation of existence by the default gateway router, then specify all vehicular equipments in the subnet by the traversal of the ARP information in ICMP Ping or the router, judge group's name that whether can find a certain vehicular equipment with group of system name storehouse, be, execution in step S302, no execution in step S303;
Step S302 obtains the essential information of vehicular equipment with snmp protocol according to group's name of vehicular equipment, judge the details of obtaining this vehicular equipment after the type of vehicular equipment;
Step S303, giving tacit consent to described vehicular equipment is main frame;
Step S304 finds the routing gateway of acquiescence;
Be specially: search the ipRouteTable among the SNMP MIBII of Topology Discovery program place computer, if find that the ipRouteDest value is the record of 0.0.0.0, then the computer installation at read-me place default gateway, the ipRouteNextHop value is the address of default gateway; Check the ipForwarding value of default gateway, if be 1, show that then described default gateway is routing device, otherwise be not;
Step S305 obtains the subnet tabulation of existence;
Be specially: all objects in the IP management group of traversal router mib II under the management object ipRouteDest, take each route purpose network number as index, the value of inquiry ipRouteType field; If the value of described field is 3 to be indicated as direct route, if the value of described field is 4 then is indirect route; Obtain the network number that directly links to each other with router; Again according to its route mask of every record queries in the described network number; According to the described route mask of obtaining, determine the IP address range of the network subnet of each existence;
Step S306 finds other routing device;
Be specially: search that type is the route table items of indirect route in the IP management group routing table of default route gateway MIBII, obtain the next hop address of route; The routing device that the traversal next hop address provides obtains larger network topology;
Step S307, the annexation of discovering network layer equipment;
Be specially: the annexation of subnet and router determines by traveling through the subnet that comprises under each router, and the relation of main frame and subnet is determined by host ip and subnet mask.
In the second preferred embodiment provided by the invention: among described step S3 ' and the step S3, obtain also comprising after the described topological relation described topological resource and described topological relation write and carry out persistence in the described database.
In the 3rd preferred embodiment provided by the invention: among described step S4 ' and the step S4, the method of calculating the coordinate of each topological resource on described network topology edit page is: the coordinate of self-defined first topological resource, next topological resource coordinate are that previous abscissa adds upper topology resource map target size and adds spacing;
When the abscissa of arranging during more than or equal to the width of described network topology edit page painting canvas, the ordinate of arrangement adds height and the line space of an icon, and abscissa is got back on this basic point of ordinate of described first topological resource simultaneously.
In the 4th preferred embodiment provided by the invention: determine each described topological resource on described network topology edit page behind the coordinate in the painting canvas, described coordinate is written back in the relation table in the described database.
In the 5th preferred embodiment provided by the invention: among described step S4 ' and the step S4, the method of drawing the Topology Management line with the painting function of the Canvas of HTML5 is: read the described relation table in the described database, read the coordinate of starting point topology resource and the coordinate of end point topology resource and carry out line.
In the 6th preferred embodiment provided by the invention: drag icon and adjust irrational layout, described topological relation is revised in online editing, the described adjustment of preservation or amended coordinate after adjustment or modification are finished.
In the 7th preferred embodiment provided by the invention: among the described step S5, the foundation of topological resource being carried out the network availability detection is the IP of this topology resource to be carried out the operation of three ping, if three times are not passed through, represents that then this topology resource is inaccurate.
Provided by the inventionly a kind ofly realize that based on SNMP and HTML5 the beneficial effect of the method for web network topology comprises:
1, a kind of method based on SNMP and HTML5 realization web network topology provided by the invention, the network topology of utilizing HTML5 to do the B/S structure represents.
2, self-defined network topology and automatic network topology shares, and the user can select to carry out self-defined network topology and automatic network topology.
3, represent on network availability detection and the network topological diagram, can edit network topological diagram based on the network topological diagram editting function of browser.
Description of drawings
Be illustrated in figure 1 as a kind of method flow diagram of realizing the method for web network topology based on SNMP and HTML5 provided by the invention;
Be illustrated in figure 2 as the structure principle chart of the embodiment of a kind of method that realizes the web network topology based on SNMP and HTML5 provided by the invention.
Embodiment
The invention provides a kind of method that realizes the web network topology based on SNMP and HTML5, its method flow as shown in Figure 1, as shown in Figure 1, the method comprises:
Step S1 selects to carry out self-defined topology or self-discovery topology, execution in step S2 ' when selecting to carry out self-defined topology, execution in step S2 when selecting to carry out the self-discovery topology.
Step S2 ' utilizes SNMP that all resources in the network of the IP of appointment tabulation or the network segment are surveyed, with the IP, resource name and the resource type that detect together as in the self-defined network topology resource write into Databasce, execution in step S3 '.
Step S3 ', the topological relation of User Defined network, execution in step S4 '.
Step S4 ', resource type according to each topological resource loads all topological resources to the network topology edit page, calculate the coordinate of each topological resource on the page, picture corresponding to resource type that shows each topological resource at the page, situation according to reality is drawn Topology Management line, execution in step S5 with the painting function of the Canvas of HTML5.
Step S2 utilizes SNMP that all topological resources of appointment are surveyed, in the self-discovery network topology resource write into Databasce that detects, and execution in step S3.
Step S3, resource analysis obtains self-discovery network topology, execution in step S4 according to the self-discovery network topology.
Step S4, the topology resource according to the attribute display of this topology resource in page painting canvas, calculate the coordinate of each topological resource on the page, draw Topology Management line, execution in step S5 according to this self-discovery network topology with the painting function of the Canvas of HTML5.
Step S5 carries out network availability according to the IP of topological resource to topological resource and detects, and the problem that detects is write carry out alarm prompt in the alarm subsystem.
Embodiment one:
A kind of method based on SNMP and HTML5 realization web network topology that embodiments of the invention one provide, its structure principle chart as shown in Figure 2.
When realizing the self-discovery network topology, wherein, step S3, resource analysis obtains the self-discovery network topology and specifically comprises according to the self-discovery network topology:
Step S301, obtain the subnet tabulation of existence by the default gateway router, then by ARP (the Address Resolution Protocol in ICMP Ping or the router, address resolution protocol) the information traversal is specified all vehicular equipments in the subnet, judge group's name that whether can find a certain vehicular equipment with group of system name storehouse, be execution in step S302, no execution in step S303.
Step S302 obtains the essential information of vehicular equipment with snmp protocol according to group's name of vehicular equipment, judge the details of obtaining this vehicular equipment after the type of vehicular equipment.
Step S303, giving tacit consent to this vehicular equipment is main frame.
Step S304 finds the routing gateway of acquiescence.Search the ipRouteTable among the SNMP MIBII of Topology Discovery program place computer, if find that the ipRouteDest value is the record of 0.0.0.0, then the computer installation at read-me place default gateway, the ipRouteNextHop value is the address of default gateway.Then check the ipForwarding value of default gateway.If be 1, show that then this default gateway is routing device really, otherwise be not.
Step S305 obtains the subnet tabulation of existence.
All objects in the IP management group of traversal router mib II under the management object ipRouteDest, take each route purpose network number as index, the value of inquiry ipRouteType field.Be 3(direct if this is worth) be indicated as direct route, be 4(indirect if this is worth) then be indirect route.Indirect route shows will lead to the purpose network or destination host also will pass through other router, and direct route shows with purpose network or destination host and directly links to each other, and so just can obtain the network number that directly links to each other with router.Again according to its route mask (ipRouteMask) of every in network number record queries.According to obtaining the route mask, just can determine the IP address range of the network subnet of each existence.
Step S306 finds other routing device.
Search that type is the route table items of indirect route in the IP management group routing table of default route gateway MIBII, obtain the next hop address (ipRouteNextHop) of route.The routing device that the traversal next hop address provides just can obtain larger network topology.
Step S307, the annexation of discovering network layer equipment.
The annexation of subnet and router travels through the subnet that comprises under each router to be determined, the relation of main frame and subnet can be determined by host ip and subnet mask.
Preferably, among step S3 ' and the step S3, obtain also comprising and to carry out persistence in topological resource and the topological relation write into Databasce after the topological relation.
Among step S4 ' and the step S4, the method of calculating the coordinate of each topological resource on the page is: the coordinate of determining first first topological resource, this coordinate can customize, for example (20,20), then next topological resource coordinate is exactly that previous abscissa adds upper topology resource map target size and adds spacing.When the abscissa of arranging during more than or equal to the width of painting canvas, the ordinate of arrangement adds height and the line space of an icon, and abscissa is got back on this basic point of ordinate of first topological resource simultaneously.
After determining the coordinate of each topological resource in painting canvas, this coordinate is written back in the relation table in the database.
The method of drawing the Topology Management line with the painting function of the Canvas of HTML5 is: the relation table in the read data storehouse, and read the coordinate of starting point topology resource and the coordinate of end point topology resource and carry out line, need two coordinate points can finish line.Code sample:
var?canvas=document.getElementById('diagonal');
var?context=canvas.getContext('2d');
context.beginPath();
context.moveTo(70,140);
context.lineTo(140,70);
context.stroke();
Because layout is automatic generation, there is irrational layout can oneself drag the icon adjustment after finishing, also can online editing revises topological relation, this adjustment of preservation or amended coordinate after adjustment or modification are finished.
Among the step S5, the foundation of topological resource being carried out the network availability detection is the IP of this topology resource to be carried out the operation of three ping, if three times are not passed through, represents that then this topology resource is inaccurate.
Although abovely with reference to the accompanying drawings embodiments of the invention are had been described in detail, be not limited only to this embodiment, those skilled in the art is according to this concrete technical scheme variously being equal to of carrying out, deformation process, also within protection scope of the present invention.