The content of the invention
The present invention provides a kind of method of testing and system of DUT port collisions disposal ability, overcomes above-mentioned prior art
Defect so that Devices to test port collision disposal ability test become more rigorous and simple and easy to apply, reduce and test into
This, improves testing efficiency.
On the one hand, the present invention provides a kind of method of testing of DUT port collisions disposal ability, including:
S100 configuration DUT port forwarding rules and DMZ host functions;
Corresponding test port in S200 call instruction snoopy test systems;
S300 is connected by telnet agreements with accompanying survey PC to set up, and creates multithreading;
S400 call instructions are tested from accompanying to survey PC and initiate the multithreading to the DUT;
S500 disconnects the connection that PC is surveyed with accompanying, and obtains the snoop results of corresponding test port;
S600 judges whether the port collision disposal ability of the DUT is qualified according to the snoop results.
Port forwards (Port forwarding), is a kind of method used for secure communication of network.Port forwarding is to turn
Behavior of the network port from a network node to another network node is sent out, it makes an external user from the outside through mistake
One NAT router being activated reaches an a port on privately owned implicit IP address (inside LAN).
DMZ is that " demilitarized zone " abbreviation, Chinese is " isolated area ", also referred to as " demilitarization to English
Area ".It is in order to solve to install the problem of access user of external network can not access internal network server after fire wall, and
The buffering area between non-security system and security system set up.The buffering area is located at Intranet and external network
Between small network area in.Some can be placed in this small network area must disclosed server utility, such as enterprise
Web server, ftp server and forum etc..On the other hand, by such a DMZ regions, inside is more efficiently protected
Network.
Telnet agreements are a member in TCP/IP protocol suite, are standard agreement and the master of the service of Internet telnets
Want mode.It has provided the user the ability for completing distance host work on the local computer.In the computer of terminal user
Upper use telnet programs, server is connected to it.Terminal user can input order in telnet programs, these lives
Order can be run on the server, just as being inputted directly on the console of server.Service can be just controlled local
Device.
Further, the step S100 includes:
S110 configures a port forwarding rule on DUT, and configuration server IP is the IP that DUT distributes to test system,
And configure the second port that DUT WAN-side IP first port maps test system;So as to by the first of DUT WAN-side IP
The bag of port request is forwarded to the second port of the test system of mapping;
S120 opens DMZ host functions, and the DMZ IP of configuration DMZ host functions are the IP of test system, so as to will be to DUT
The WAN-side IP bag of first port request be forwarded to the 3rd port of corresponding test system.
Step S110 and step S120 are respectively provided with a port rule, and this two rule is conflict in fact.
Further, the step S300 includes:
S310 calls telnet functions to accompany survey PC by the connection of telnet agreements;
S320 accompanies the test script surveyed on PC by ordering to start;
Test script described in S330 calls two threads of thread function creations, and described two threads are to call nc orders
The bag that the first port of from the WAN-side IP to DUT makes requests on is sent from survey PC is accompanied.
Further, the step S400 includes:
S410 calls thread.start orders while initiating two threads created in previous step, by accompanying survey PC same
When send two bags made requests on to DUT WAN-sides IP first port.
Further, the step S600 includes:
S610 judges whether the snoop results meet port collision rule, and the port collision rule is the rule first configured
Then come into force;
S620 ought listen to the second port and receive the request bag sent, and the 3rd port does not receive and sent
Request bag, then judge that the DUT meets port collision rule, the DUT port collisions disposal ability is qualified;
S630 then judges that the DUT is unsatisfactory for port collision when listening to the request bag that the 3rd port reception is sent
Rule, the DUT port collisions disposal ability is unqualified.
On the other hand, present invention additionally comprises a kind of test system of DUT port collisions disposal ability, including:Rule configuration
Module, monitoring module, thread creation module, test module, control module, the control module configure mould with the rule respectively
Block, monitoring module, thread creation module and test module are connected;Wherein:The rule configuration module call function is matched somebody with somebody on DUT
Put DUT ports forwarding rule and open DMZ host functions;It is corresponding in the monitoring module call instruction snoopy test system to survey
Try port;The thread creation module is connected by telnet agreements with accompanying survey PC to set up, and creates multithreading;The test module
Call instruction is tested from accompanying to survey PC and initiate the multithreading to the DUT;The control module call instruction disconnects described
Test system and the connection for accompanying survey PC, and pass through the snoop results that the monitoring module obtains test port;The control module
According to the snoop results, judge whether the port collision disposal ability of the DUT is qualified.
Further, the rule configuration module includes:First rule configuration submodule, Second Rule configuration submodule,
Wherein:The first rule configuration submodule call function configures a port forwarding rule on DUT, and configuration server IP is
DUT distributes to the IP of test system, and configures the second port that DUT WAN-side IP first port maps test system;So as to
The bag of first port request to DUT WAN-side IP is forwarded to the second port of the test system of mapping;The Second Rule
Configure submodule and open DMZ host functions, the DMZ IP of configuration DMZ host functions are the IP of test system, so as to by DUT's
The bag of WAN-side IP first port request is forwarded to the 3rd port of corresponding test system.
Further, the thread creation module includes:Connection submodule, script startup submodule and thread set up submodule
Block, the script startup submodule is connected with the connection submodule, the thread setting up submodule respectively, wherein:The company
Connecing submodule calls telnet functions to accompany survey PC by the connection of telnet agreements;The script startup submodule is started by ordering
Accompany the test script surveyed on PC;The thread setting up submodule calls two lines of thread function creations by the test script
Journey, described two threads are to call nc orders to be made requests on from the first port for accompanying survey PC to send the WAN-side IP to DUT
Bag.
Further, the test module calls thread.start orders while initiating two created in previous step
Thread, by accompanying survey PC to be simultaneously emitted by two bags made requests on to DUT WAN-sides IP first port.
Further, the control module includes:Operation submodule, the judgement submodule being connected with the operation submodule
Block;Wherein:The operation submodule disconnects and accompanied the connection for surveying PC after the test module initiates test, pass through the prison
Module is listened to obtain second port, the snoop results of the 3rd port;The judging submodule judges the second port, the 3rd port
Snoop results whether meet port collision rule, port collision rule is the taking effect rules that first configure;Monitored when described
Module listens to the second port and receives the request bag sent, and the 3rd port does not receive the request bag sent,
Then the judging submodule judges that the DUT meets port collision rule, and the DUT port collisions disposal ability is qualified;Work as institute
State monitoring module and listen to the request bag that the 3rd port reception is sent, then the judging submodule judges that the DUT is discontented with
Sufficient port collision rule, the DUT port collisions disposal ability is unqualified.
The present invention tests DUT port collision disposal abilities by sending request bag to DUT same port simultaneously;Using many
The method of thread is realized to send to DUT same ports simultaneously and asked.At least include with the next item down beneficial effect:
(1) difficulty of test is simplified.
(2) testing efficiency is improved.
(3) tester's work difficulty is mitigated.
(4) test period is shortened.
(5) product cost is reduced.
Embodiment
In order that the object, technical solutions and advantages of the present invention are clearer, below in conjunction with accompanying drawing the present invention is made into
One step it is described in detail, it is clear that described embodiment is only embodiment of the invention a part of, rather than whole implementation
Example.Based on the embodiment in the present invention, what those of ordinary skill in the art were obtained under the premise of creative work is not made
All other embodiment, belongs to the scope of protection of the invention.
The invention discloses a kind of method of testing of DUT port collisions disposal ability, embodiment one as shown in figure 1, including:
S100 configuration DUT port forwarding rules and DMZ host functions;
Corresponding test port in S200 call instruction snoopy test systems;
S300 is connected by telnet agreements with accompanying survey PC to set up, and creates multithreading;
S400 call instructions are tested from accompanying to survey PC and initiate the multithreading to the DUT;
S500 disconnects the connection that PC is surveyed with accompanying, and obtains the snoop results of corresponding test port;
S600 judges whether the port collision disposal ability of the DUT is qualified according to the snoop results.
Idea of the invention is that configuring a plurality of port rule on Devices to test (DUT), this several port rules are mutually to rush
Prominent, the test port that the packet of reception can be sent to rule agreement by DUT is gone, and therefore, only needs the number of snoopy test port
According to bag reception condition, it is possible to which Devices to test is known in which rule forwarding is according to.One qualified product is running into conflict
Port rule when, can carry out port forwarding according to the rule first configured, therefore it may only be necessary to detect the monitoring knot of test port
Fruit is it may determine that whether the port collision disposal ability for going out this Devices to test is qualified.
Step S100 in above-described embodiment 1 includes:
S110 configures a port forwarding rule on DUT, and configuration server IP is the IP that DUT distributes to test system,
And configure the second port that DUT WAN-side IP first port maps test system;So as to by the first of DUT WAN-side IP
The bag of port request is forwarded to the second port of the test system of mapping;
S120 opens DMZ host functions, and the DMZ IP of configuration DMZ host functions are the IP of test system, so as to will be to DUT
The WAN-side IP bag of first port request be forwarded to the 3rd port of corresponding test system.
Test system call function configures a port forwarding rule on DUT, and server ip is that DUT distributes to test system
The IP of system, is 8000 as the first port of outside port if being 80 as the second port of internal port;So first
Port rule is:80 ports of server ip will be forwarded to the bag of DUT WAN-side IP 8000 port requests, that is,
Say the internal port 80 for forwarding a packet to test system for asking the outside port 8000 of Devices to test.
After first port forwarding rule of configuration, DMZ host functions are then turned on, the DMZ IP of DMZ host functions are set
It is set to consistent with the inside IP of port forwarding function, therefore, the Article 2 port rule of setting is:By to DUT WAN-side IP's
The bag of arbitrary port request is forwarded to the corresponding ports of server ip, and the of DUT WAN-side IP first port and test system
Three ports are corresponding, i.e. DUT WAN-side first port is 8000, and the corresponding port of test system the 3rd is also 8000.Turn
During hair, the bag asked to DUT WAN-side IP port 8000 is forwarded to the port 8000 of corresponding test system.
After this good two rule of configuration, then only need to 80 ports and 8000 ports of snoopy test system, after test just may be used
Test result is obtained with situation about being arrived according to the two port snoops.
Step S200 in above-described embodiment 1, can be by calling nc orders at test system end to the 80 of test system
Port and 8000 ports are monitored.
Nc is writing a Chinese character in simplified form for netcat, the Swiss Army Knife good reputation for having the dotcom world.Because its short and pithy, practical function, quilt
It is designed as a simple, reliable network tool.Nc effect has:
(1) intercepting for any TCP/UDP ports is realized, nc in TCP or UDP modes can intercept designated ends as server
Mouthful
(2) scanning of port, nc can initiate TCP or UDP connections as client
(3) file is transmitted between machine
(4) network tests the speed between machine.
Step S300 in above-described embodiment 1 includes:
S310 calls telnet functions to accompany survey PC by the connection of telnet agreements;
S320 accompanies the test script surveyed on PC by ordering to start;
Test script described in S330 calls two threads of thread function creations, and described two threads are to call nc orders
The bag that the first port of from the WAN-side IP to DUT makes requests on is sent from survey PC is accompanied.
Test system calls telnet functions to accompany survey PC by the connection of telnet agreements, and is accompanying survey PC by ordering to start
On script;Script calls two threads of thread function creations (such as according to the port rule above set, can create thread
1 content is:Call nc orders from accompany survey PC send the bag that 8000 ports of from the WAN-side IP to DUT make requests on;Thread 2
Content is:Call nc orders from accompany survey PC send the bag that 8000 ports of from the WAN-side IP to DUT make requests on).
Step S400 in above-described embodiment 1 includes:
S410 calls thread.start orders while initiating two threads created in previous step, by accompanying survey PC same
When send two bags made requests on to DUT WAN-sides IP first port.
Thread is started using thread.start modes, multithreading operation is truly realized.
Step S600 in above-described embodiment 1 includes:
S610 judges whether the snoop results meet port collision rule, and the port collision rule is the rule first configured
Then come into force;
S620 ought listen to the second port and receive the request bag sent, and the 3rd port does not receive and sent
Request bag, then judge that the DUT meets port collision rule, the DUT port collisions disposal ability is qualified;
S630 then judges that the DUT is unsatisfactory for port collision when listening to the request bag that the 3rd port reception is sent
Rule, the DUT port collisions disposal ability is unqualified.
It can be seen from the step of above, first port of setting forwarding rule is by DUT WAN-side IP first end
The bag of mouth request is forwarded to the second port of the test system of mapping.According to the port collision of the taking effect rules first configured rule,
Understand that only second port listens to the request bag sent, and the 3rd port does not receive request bag, can just verify to be measured
The port collision disposal ability of equipment (DUT) is OK;If from the 3rd port snoop to the request bag sent, illustrating do not have
Meet port collision rule, then, the port collision disposal ability for illustrating Devices to test is underproof.
Following several situations occur in the second port of snoopy test system and the 3rd port of test system:
1st, listen to second port and receive the request bag sent, the 3rd port is then not received by request bag;
2nd, listen to second port and the 3rd port have received the request bag sent;
3rd, listen to second port and do not receive the request bag sent, the 3rd port but have received request bag;
4th, listen to second port and the 3rd port is not received by request bag.
In above-mentioned four kinds of situations, in addition to the first situation is test passes, three kinds are test failures in addition.Because
The rule set before is conflict, and the port forwarding rule first set before is to connect DUT WAN-side IP first port
The request bag of receipts is transmitted to the second port of test system, therefore, if detecting the 3rd port has the number for receiving and sending
According to bag, then the principle that explanation does not come into force first according to the rule first configured, also it is determined that Devices to test handles port collision
Ability is unqualified.
Here it is necessary illustratively, the present embodiment is tested without a thread is only initiated.But employ two lines
Journey, and be to be initiated simultaneously to DUT first port simultaneously, also for the test environment for constructing port collision, in addition, it
Two port rules of preceding setting are also conflict, and test equipment under test is running into same interface while at when running into multiple threads
Manage port collision disposal ability.
The second embodiment of the present invention, as shown in Fig. 2 including step:
S110 configures a port forwarding rule on DUT, and configuration server IP is the IP that DUT distributes to test system,
And configure the second port that DUT WAN-side IP first port maps test system;So as to by the first of DUT WAN-side IP
The bag of port request is forwarded to the second port of the test system of mapping;
S120 opens DMZ host functions, and the DMZ IP of configuration DMZ host functions are the IP of test system, so as to will be to DUT
The WAN-side IP bag of first port request be forwarded to the 3rd port of corresponding test system;
Second port and the 3rd port in S210 call instruction snoopy test systems;
S310 calls telnet functions to accompany survey PC by the connection of telnet agreements;
S320 accompanies the test script surveyed on PC by ordering to start;
Test script described in S330 calls two threads of thread function creations, and described two threads are to call nc orders
The bag that the first port of from the WAN-side IP to DUT makes requests on is sent from survey PC is accompanied;
S410 calls thread.start orders while initiating two threads created in previous step, by accompanying survey PC same
When send two bags made requests on to DUT WAN-sides IP first port;
S510 disconnects the connection that PC is surveyed with accompanying, and obtains the second port and the snoop results of the 3rd port;
S610 judges whether the snoop results meet port collision rule, and the port collision rule is the rule first configured
Then come into force;
S620, which works as, listens to the request bag that the second port reception is sent, and the 3rd port does not receive what is sent
Request bag, then judge that the DUT meets port collision rule, the DUT port collisions disposal ability is qualified;
S630 then judges that the DUT is unsatisfactory for port collision when listening to the request bag that the 3rd port reception is sent
Rule, the DUT port collisions disposal ability is unqualified.
In order to which the Expected Results of the present invention is better described, the third embodiment of the present invention is said with K3C automatic test
Bright, technique according to the invention scheme is described in further detail.
Test topology schematic diagram is as shown in Figure 3.
Test prepares:Tester is by the DUT WAN-side address input test systems obtained and starts test system;Test
Method flow as shown in figure 4, including:
Step S1, system call function configures a port forwarding rule on DUT, and server ip is that DUT distributes to survey
The IP of test system, internal port is that 90, outside port is 9000, is then turned on DMZ host functions, by the DMZ of DMZ host functions
IP is arranged to consistent with the inside IP of port forwarding function;(two rule contents are:Port is forwarded, by DUT WAN-side IP
The bags of 9000 port requests be forwarded to 90 ports of server ip;DMZ host functions, by DUT WAN-side IP arbitrary end
The bag of mouth request is forwarded to the corresponding ports of server ip, i.e. the WAN-side port of DUT is 9000, and corresponding ports are also for 9000)
Step S2, test system calls nc orders to be supervised at test system end to 90 and 9000 ports of test system
Listen;
Step S3, test system calls telnet functions to accompany survey PC by the connection of telnet agreements, and is started by ordering
Script on survey PC is accompanied;Script calls two threads of thread function creations, and (content of thread 1 is:Nc orders are called from accompanying
Survey PC and send the bag that 9000 ports of from the WAN-side IP to DUT make requests on;The content of thread 2 is:Call nc orders from accompany survey PC
Send the bag that 9000 ports of from the WAN-side IP to DUT make requests on.)
Step S4, calls thread.start orders while initiating two threads, that is, accompanies survey PC to be simultaneously emitted by two to DUT
The bag that WAN-side IP 9000 ports make requests on;
Step S5, call instruction disconnects test system and accompanies the telnet connections surveyed between computer;
Step S6, checks the result that test system end nc is monitored, judges whether to meet conflict rule.If test system
90 ports receive the request bag sent, and 9000 ports of test system do not receive request bag, then are PASS, if test system
It is then FAIL that 9000 ports of system, which receive the request bag sent,;(port collision rule is the taking effect rules first configured.)
Step S7, returns to test result and terminates test.
The key point of the present invention is to test at DUT port collisions by sending request bag to DUT same port simultaneously
Reason ability;Realize to send to DUT same ports simultaneously using the method for multithreading and ask.Those skilled in the art without departing substantially from
On the premise of the principle and essence of the present invention, various changes or modifications can be made to these embodiments, but these changes and
Modification each falls within protection scope of the present invention
Based on identical technical concept, the embodiment of the present invention also provides a kind of test system of DUT port collisions disposal ability
System, the test system can perform above method embodiment.The test system that fourth embodiment of the invention is provided is as shown in figure 5, bag
Include:Rule configuration module 10, monitoring module 20, thread creation module 30, test module 40, control module 50, the control mould
Block 50 is connected with the rule configuration module 10, monitoring module 20, thread creation module 30 and test module 40 respectively;Wherein:
The call function of rule configuration module 10 configures forwarding rule in DUT ports on DUT and opens DMZ host functions;The prison
Listen corresponding test port in the call instruction snoopy test system of module 20;The thread creation module 30 passes through telnet agreements
It is connected with accompanying survey PC to set up, creates multithreading;The call instruction of test module 40 from accompany survey PC to the DUT initiate it is described many
Thread is tested;The call instruction of control module 50 disconnects the test system and accompanies the connection for surveying PC, and by described
Monitor the snoop results that module 20 obtains test port;The control module 50 judges the DUT's according to the snoop results
Whether port collision disposal ability is qualified.
The fifth embodiment of the present invention, as shown in fig. 6, on the basis of above-described embodiment four, the rule of the test system
Then configuration module 10 includes:First rule configuration submodule 11, Second Rule configuration submodule 12, wherein:First rule
The configuration call function of submodule 11 configures a port forwarding rule on DUT, and configuration server IP is that DUT distributes to test system
The IP of system, and configure the second port that DUT WAN-side IP first port maps test system;So as to by DUT WAN-side
The bag of IP first port request is forwarded to the second port of the test system of mapping;The Second Rule configuration submodule is opened
DMZ host functions, the DMZ IP of configuration DMZ host functions are the IP of test system, so as to by the first of DUT WAN-side IP
The bag of port request is forwarded to the 3rd port of corresponding test system.
Preferably, the thread creation module 30 includes:Submodule 31, script startup submodule 32 and thread is connected to set up
Submodule 33, the script startup submodule 32 is connected with the connection submodule 31, the thread setting up submodule 33 respectively,
Wherein:The connection submodule 31 calls telnet functions to accompany survey PC by the connection of telnet agreements;The script startup submodule
Block 32 accompanies the test script surveyed on PC by ordering to start;The thread setting up submodule 33 is called by the test script
Two threads of thread function creations, described two threads are to call nc orders to survey PC and send WAN-side IP to DUT from accompanying
The bag that first port makes requests on.
Preferably, the test module 40 calls thread.start orders while initiating two created in previous step
Thread, by accompanying survey PC to be simultaneously emitted by two bags made requests on to DUT WAN-sides IP first port.
Preferably, the control module 50 includes:Operation submodule 51, judgement being connected with the operation submodule 51
Module 52;Wherein:The operation submodule 51 disconnects and accompanied the connection for surveying PC after the test module 40 initiates test, leads to
Cross the monitoring module 20 and obtain second port, the snoop results of the 3rd port;The judging submodule 52 judges described second
Whether port, the snoop results of the 3rd port meet port collision rule, and the port collision rule is raw for the rule first configured
Effect;The request bag sent is received when the monitoring module 20 listens to the second port, and the 3rd port does not receive hair
The request come, then the judging submodule 52 judge that the DUT meets port collision rule, the DUT port collisions handle energy
Power is qualified;The request bag sent is received when the monitoring module 20 listens to the 3rd port, then the judging submodule 52
Judge that the DUT is unsatisfactory for port collision rule, the DUT port collisions disposal ability is unqualified.
The test system of the embodiment of the present invention is used for the test of the port collision ability of device under test, and Devices to test includes
SOHO products, such as interchanger, router etc..
, but those skilled in the art once know basic creation although preferred embodiments of the present invention have been described
Property concept, then can make other change and modification to these embodiments.So, appended claims are intended to be construed to include excellent
Select embodiment and fall into having altered and changing for the scope of the invention.
Obviously, those skilled in the art can carry out the essence of various changes and modification without departing from the present invention to the present invention
God and scope.So, if these modifications and variations of the present invention belong to the scope of the claims in the present invention and its equivalent technologies
Within, then the present invention is also intended to comprising including these changes and modification.