A kind of method realizing web network topology based on SNMP and HTML5
Technical field
The present invention relates to technical field of network management, be specifically related to a kind of based on SNMP(SimpleNetworkManagementProtocol, Simple Network Management Protocol) and HTML5(HypertextMarkupLanguage5, 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 such network and complexity are also just increasing, also increasing to the difficulty of network management, Internet resources controllability is reduced, very large risk is also brought to the stability of whole network, so there is the concept of network topology, the structural relation of each inter-entity in network topology energy reaction network.Network Topology Design ground quality has significant impact to the performance of whole network and economy.Network management personnel carries out quick position to malfunctioning node on the basis of topological diagram.The network topologies of present base B/S structure mainly contains following several technology FlexSVG etc., but has drawback separately.
The network topology realized based on technology such as FlexSVG now accounts for very most of, all each have their own drawback of this several technology, although Flex effect is fine, but relies on third-party service with Java data interaction sexual needs.Although SVG is good in drawing, browser will plug part support, and compatible aspect is not fine, and Consumer's Experience has problems.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 realizing web network topology based on SNMP and HTML5, 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, performs step S2 ', when selecting to carry out described self-discovery topology, perform step S2;
Step S2 ', utilizes SNMP to detect all resources in the network of the IP list of specifying or the network segment, and the IP detected, resource name as in a self-defined network topology resource write into Databasce, are performed step S3 ' together with resource type;
Step S3 ', the topological relation of User Defined network, performs step S4 ';
Step S4 ', resource type according to each topology resource loads all described topology resource to network topology edit page, calculate the coordinate of each described topology resource on described network topology edit page, described network topology edit page shows the picture that described in each, resource type of topology resource is corresponding, painting function according to the Canvas of topological relation HTML5 draws Topology Management line, performs step S5;
Step S2, utilizes SNMP to detect all resources, writes in described database by the self-discovery network topology resource detected, and performs step S3;
Step S3, obtains self-discovery network topology according to the resource analysis of described self-discovery network topology, performs step S4;
Step S4, described topology resource is shown in described network topology edit page painting canvas by the attribute according to described topology resource, calculate the coordinate of each described topology resource on described network topology edit page, painting function according to the Canvas of described self-discovery network topology HTML5 draws Topology Management line, performs step S5;
Step S5, the IP according to described topology resource carries out network availability detection to described topology resource, carries out alarm prompt by the problem detected write alarm subsystem.
In first preferred embodiment provided by the invention: described step S3, obtain self-discovery network topology according to the resource analysis of self-discovery network topology and specifically comprise:
Step S301, the Subnet List existed is obtained by default gateway router, then vehicular equipments all in subnet is specified by the ARP information traversal in ICMPPing or router, whether judgement system group's name storehouse can find group's name of a certain vehicular equipment, be, perform step S302, no execution step S303;
Step S302, according to group's name essential information of snmp protocol acquisition vehicular equipment of vehicular equipment, obtains the details of this vehicular equipment after judging 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 in the SNMPMIBII of Topology Discovery program place computer, if find that ipRouteDest value is the record of 0.0.0.0, the then computer installation default gateway at read-me place, ipRouteNextHop value is the address of default gateway; Check the ipForwarding value of default gateway, if be 1, then show that described default gateway is routing device, otherwise be not;
Step S305, obtains the Subnet List of existence;
Be specially: all objects in the IP management group of traversal router mib II under management object ipRouteDest, with each route object network number for index, the value of inquiry ipRouteType field; If the value of described field is 3 be indicated as direct routing, if the value of described field is 4, is indirect route; Obtain the network number be directly connected with router; Again according to its route mask of every bar record queries in described network number; According to the described route mask obtained, determine the IP address range of each network subnet existed;
Step S306, finds other routing device;
Be specially: searching type in the IP management group routing table of default route gateway MIBII is the route table items of indirect route, obtains the next hop address of route; The routing device that traversal next hop address provides, obtains larger network topology;
Step S307, finds the annexation of network layer device;
Be specially: the annexation of subnet and router is determined by the subnet comprised under traveling through each router, and the relation of main frame and subnet is determined by host ip and subnet mask.
In second preferred embodiment provided by the invention: in described step S3 ' and step S3, also comprise described topology resource and described topological relation to write in described database after obtaining described topological relation and carry out persistence.
In 3rd preferred embodiment provided by the invention: in described step S4 ' and step S4, calculating the seat calibration method of each topology resource on described network topology edit page is: the coordinate of self-defined first topology resource, and next topology resource coordinate is that previous abscissa adds that the size of topology resource icon adds spacing;
When the abscissa arranged is 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 topology resource simultaneously.
In 4th preferred embodiment provided by the invention: after determining the coordinate of each described topology resource on described network topology edit page in painting canvas, described coordinate is written back in the relation table in described database.
In 5th preferred embodiment provided by the invention: in described step S4 ' and step S4, the method of drawing Topology Management line with the painting function of the Canvas of HTML5 is: read the described relation table in described database, and the coordinate of the coordinate and end point topology resource that read starting point topology resource carries out line.
In 6th preferred embodiment provided by the invention: drag icon and adjust irrational layout, described topological relation is revised in online editing, adjusts or has revised the described adjustment of rear preservation or amended coordinate.
In 7th preferred embodiment provided by the invention: in described step S5, the foundation of topology resource being carried out to network availability detection is the operation IP of this topology resource being carried out to three ping, if three times are not passed through, then represents that this topology resource is inaccurate.
A kind of beneficial effect realizing the method for web network topology based on SNMP and HTML5 provided by the invention comprises:
1, a kind of method realizing web network topology based on SNMP and HTML5 provided by the invention, the network topology utilizing HTML5 to do B/S structure represents.
2, self-defined network topology and automatic network topology share, and user can select to carry out self-defined network topology and automatic network topology.
3, network availability detects and network topological diagram represents, and the network topological diagram editting function based on browser can be edited network topological diagram.
Accompanying drawing explanation
Be illustrated in figure 1 a kind of method flow diagram realizing the method for web network topology based on SNMP and HTML5 provided by the invention;
Be illustrated in figure 2 a kind of structure principle chart realizing the embodiment of the method for web network topology based on SNMP and HTML5 provided by the invention.
Embodiment
The invention provides a kind of method realizing web network topology based on SNMP and HTML5, as shown in Figure 1, as shown in Figure 1, the method comprises its method flow:
Step S1, selects to carry out self-defined topology or self-discovery topology, performs step S2 ' when selecting to carry out self-defined topology, selects to perform step S2 when carrying out self-discovery topology.
Step S2 ', utilizes SNMP to detect all resources in the network of the IP list of specifying or the network segment, and the IP detected, resource name as in a self-defined network topology resource write into Databasce, are performed step S3 ' together with resource type.
Step S3 ', the topological relation of User Defined network, performs step S4 '.
Step S4 ', resource type according to each topology resource loads all topology resource to network topology edit page, calculate the coordinate of each topology resource on the page, the page shows the picture that the resource type of each topology resource is corresponding, painting function according to the Canvas of the situation HTML5 of reality draws Topology Management line, performs step S5.
Step S2, utilizes SNMP to detect all topology resource of specifying, and by the self-discovery network topology resource write into Databasce that detects, performs step S3.
Step S3, obtains self-discovery network topology according to the resource analysis of self-discovery network topology, performs step S4.
Step S4, topology resource according to the attribute display of this topology resource in page painting canvas, calculate the coordinate of each topology resource on the page, the painting function according to the Canvas of this self-discovery network topology HTML5 draws Topology Management line, performs step S5.
Step S5, the IP according to topology resource carries out network availability detection to topology resource, carries out alarm prompt by the problem detected write alarm subsystem.
Embodiment one:
A kind of method realizing web network topology based on SNMP and HTML5 that embodiments of the invention one provide, its structure principle chart as shown in Figure 2.
When realizing self-discovery network topology, wherein, step S3, obtains self-discovery network topology according to the resource analysis of self-discovery network topology and specifically comprises:
Step S301, the Subnet List existed is obtained by default gateway router, then by the ARP (AddressResolutionProtocol in ICMPPing or router, address resolution protocol) information traversal specifies vehicular equipments all in subnet, whether judgement system group's name storehouse can find group's name of a certain vehicular equipment, perform step S302, no execution step S303.
Step S302, according to group's name essential information of snmp protocol acquisition vehicular equipment of vehicular equipment, obtains the details of this vehicular equipment after judging 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 in the SNMPMIBII of Topology Discovery program place computer, if find that ipRouteDest value is the record of 0.0.0.0, the then computer installation default gateway at read-me place, ipRouteNextHop value is the address of default gateway.Then the ipForwarding value of default gateway is checked.If be 1, then show that this default gateway is routing device really, otherwise be not.
Step S305, obtains the Subnet List of existence.
All objects in the IP management group of traversal router mib II under management object ipRouteDest, with each route object network number for index, the value of inquiry ipRouteType field.If this value is 3(direct) be indicated as direct routing, if this value is 4(indirect), be indirect route.Indirect route shows also will to pass through other router towards object network or destination host, and direct routing shows directly to be connected with object network or destination host, so just can obtain the network number be directly connected with router.Again according to its route mask (ipRouteMask) of the every bar record queries in network number.According to obtaining route mask, the IP address range of each network subnet existed just can be determined.
Step S306, finds other routing device.
Searching type in the IP management group routing table of default route gateway MIBII is the route table items of indirect route, obtains the next hop address (ipRouteNextHop) of route.The routing device that traversal next hop address provides, just can obtain larger network topology.
Step S307, finds the annexation of network layer device.
The subnet comprised under the annexation of subnet and router travels through each router is determined, the relation of main frame and subnet can be determined by host ip and subnet mask.
Preferably, in step S3 ' and step S3, also comprise after obtaining topological relation and carry out persistence by topology resource and topological relation write into Databasce.
In step S4 ' and step S4, calculating the seat calibration method of each topology resource on the page is: the coordinate first determining first topology resource, this coordinate can customize, such as (20,20), then next topology resource coordinate is exactly that previous abscissa adds that the size of topology resource icon adds spacing.When the abscissa arranged is 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 topology resource simultaneously.
After determining the coordinate of each topology resource in painting canvas, this coordinate is written back in the relation table in database.
The method of drawing Topology Management line with the painting function of the Canvas of HTML5 is: the relation table in read data storehouse, and the coordinate of the coordinate and end point topology resource that read starting point topology resource carries out line, needs two coordinate points to complete line.Code sample:
varcanvas=document.getElementById('diagonal');
varcontext=canvas.getContext('2d');
context.beginPath();
context.moveTo(70,140);
context.lineTo(140,70);
context.stroke();
Because layout is automatic generation after completing, but there is irrational layout oneself to drag icon adjustment, also online editing can revise topological relation, adjust or revised this adjustment of rear preservation or amended coordinate.
In step S5, the foundation of topology resource being carried out to network availability detection is the operation IP of this topology resource being carried out to three ping, if three times are not passed through, then represents that this topology resource is inaccurate.
Although be described in detail embodiments of the invention with reference to the accompanying drawings above, be not limited only to this embodiment, various equivalent, the deformation process that those skilled in the art carries out according to this concrete technical scheme, also within protection scope of the present invention.