A kind of port mapping system and its port mapping method based on reversed multi-connection
Technical field
The present invention relates to technical field of computer information processing, and in particular to a kind of port mapping based on reversed multi-connection
System and its port mapping method.
Background technique
The method of the current equipment for solving access NAT is port mapping, i.e. a port of the IP address of borde gateway is reflected
It is mapped to a machine in NAT Intranet, corresponding service is provided.Port mapping saves as problem in data from far-off regions acquisition, mainly
Two aspects:First is that the multiple NAT situation of this scene is relatively more, across multiple networks, edge port mapping becomes infeasible;Second is that same
When to improve reliability cable network and movement (4G) network redundancy backup simultaneously, cannot directly use port mapping.
Summary of the invention
For problem involved in above-mentioned background technique, the object of the present invention is to provide a kind of based on reversed multi-connection
Port mapping system and its port mapping method solve the problems, such as the port mapping of multiple NAT and multi-connection.Opposite direction connection one kind by
Server of the equipment to outside NAT network under NAT network initiates the NAT through method of TCP connection, reversed multi-connection creation
The connection in Multi net voting path ensures reliability that NAT is passed through.
To achieve the above object, the present invention provides the following technical solutions:
A kind of port mapping system based on reversed multi-connection is reversed more including needing by the internal unit of port mapping
Connect gateway, reversed multi-connection server, client;Wherein reversed multi-connection gateway includes connection management module,
Mobile network's module, data forwarding module, cable network module;
Internal unit:Internal unit provides the TCP equipment of service for client, and internal unit and client be not in same net
In network, internal unit finally provides clients with service by providing TCP connection to reversed multi-connection gateway;
Client:Client is the terminal device for needing to access internal unit service, and client is with internal unit not same
In one network, client passes through TCP connection to reversed multi-connection server, the final TCP server for accessing internal unit;
Reversed multi-connection server:Reversed multi-connection server is the intermediate axle of client Yu reversed multi-connection gateway
Equipment is connect, reversed multi-connection server is supplied to the TCP connection service of client Yu reversed multi-connection gateway, is responsible for simultaneously
It forwards the TCP data message of client and reversed multi-connection gateway to forward to service;
Reversed multi-connection gateway:Reversed multi-connection gateway is in reversed multi-connection server and internal unit
Between bridging device and management equipment, reversed multi-connection gateway is connected to reversed multi-connection server and internal unit simultaneously,
The TCP data message for being responsible for the reversed multi-connection server of forwarding and internal unit simultaneously forwards service;Reversed multi-connection gateway is set
TCP port mapping relations of the TCP port of standby management internal unit to reversed multi-connection server;
Connection management module:TCP port for managing TCP port to the reversed multi-connection server of internal unit maps
Relationship, manage reversed multi-connection gateway to internal unit and reversed multi-connection server TCP connection;
Data forwarding module:For be responsible for management multi-connection gateway and internal unit between and multi-connection gateway
TCP connection between equipment and reversed multi-connection server is responsible for management and forwards reversed multi-connection server and internal unit
The forwarding service of TCP data message;
Mobile network's module:It is logical for realizing the movement between reversed multi-connection gateway and reversed multi-connection server
News connection, respectively connection management module and data forwarding module provide network service;Movement can be used in mobile network's module
Operator moves 4G, 3G, GPRS network, and network bandwidth is smaller, for connecting backup;
Cable network module:For realizing the cable modem between reversed multi-connection gateway and reversed multi-connection server
News connection, respectively connection management module and data forwarding module provide network service;The network bandwidth of cable network module compared with
Greatly, primary data communication channel;
The present invention also provides a kind of port mapping methods based on reversed multi-connection, include the following steps:
Step (1), connection management module establish reversed multi-connection server redundancy signaling connection, cable network module with
Mobile network's module establishes the TCP signaling connection of reversed multi-connection server respectively;
Step (2), connection management module preferentially use cable network module and the TCP signaling of reversed multi-connection server to connect
Connect news;After the TCP connection is interrupted, connection management module just uses mobile network's module and reversed multi-connection server
The communication of TCP signaling connection;
Step (3), connection management module the port of internal unit (such as:192.168.29.12:4000) mapping request is sent out
Give reversed multi-connection server;
Step (4), reversed multi-connection server receive mapping request, (such as the port of internal unit:
192.168.29.12:4000) it is being mapped to reversed multi-connection server mappings port (such as:10.2.3.4:12211), and handle reflects
The relationship of penetrating is saved in Hash Map h1;
Step (5), reversed multi-connection server mappings port are (such as:10.2.3.4:12211) client TCP company is received
It connects, inquiry Hash Map h1 obtains mapping relations, sends client connection request to connection management module;
Step (6), connection management module receive connection request, and notification data forwarding module establishes reverse data connection;
Step (7), data forwarding module selection establish the port of internal unit (such as:192.168.29.12:4000)
TCP data connection;
Step (8), data forwarding module, which are established, connect process with reversed multi-connection server reverse data
(8.1), it when the TCP signaling connection connected state of cable network module and reversed multi-connection server, selects wired
Network module is established TCP data with reversed multi-connection server and is connect;
(8.2), when the TCP signaling connection interrupt status of cable network module and reversed multi-connection server, selection movement
Network module is established TCP data with reversed multi-connection server and is connect;
(8.3), when cable network module and the TCP signaling data failure of reversed multi-connection server, it is switched to movement
Network module establishes TCP data connection to reversed multi-connection server (6);
(8.4), when mobile network's module and the TCP signaling data also failure of reversed multi-connection server, notice connection
Management module disconnecting terminates this TCP mapping connection business;
(8.5), because being the reversed multi-connection server of data forwarding module active TCP connection, even if reversed connect more
Gateway is connect still to be able to realize that NAT is penetrated in multiple NAT;
Internally equipment sends datagram process for step (9), client
(9.1), client sends the data message of reversed multi-connection server;
(9.2), reversed multi-connection server increases by eight byte packet headers after receiving the data packet text of client, forwards data
Forwarding module;Eight byte packet headers include nybble length and nybble serial number, and nybble length is used for the TCP of data forwarding module
Subpackage, nybble serial number are incremented by serial number, for cable network module, mobile network's module and reversed multi-connection server
TCP data connection switching message resumes;
(9.3), the data packet that reversed multi-connection server is transmitted to data forwarding module saves in caching of giving out a contract for a project;It is reversed more
Connection server receives serial number confirmation request, and the data for caching of giving out a contract for a project are understood according to serial number;
(9.4), data forwarding module receives the data packet text of reversed multi-connection server, removes eight byte packet headers,
Data message forwarding is to internal unit;Data forwarding module takes out the nybble serial number of eight byte packet headers, passes through connection management mould
The TCP signaling connection of block and reversed multi-connection server sends sequence number confirmation request, understands hair for reversed multi-connection server
Wrap the data of caching;
(9.5), when the TCP signaling data failure of cable network module and reversed multi-connection server, mobile network's module
TCP data connection is re-established to reversed multi-connection server (6);Reversed multi-connection server the message of caching of giving out a contract for a project again
It is sent to data forwarding module, when guaranteeing connection switching, the data message that client is sent to internal unit is not lost;
Step (10), internal unit send datagram process to client
(10.1), internal unit sends the data message of data forwarding module;
(10.2), data forwarding module increases by eight byte packet headers after receiving the data packet text of internal unit, forwards data
Forwarding module, eight byte packet headers include nybble length and nybble serial number;
(10.3), the data packet that data forwarding module is transmitted to reversed multi-connection server saves in caching of giving out a contract for a project;Reversely
Data forwarding module receives serial number confirmation request, and the data for caching of giving out a contract for a project are understood according to serial number;
(10.4), reversed multi-connection server receives the data packet text of data forwarding module, removes eight byte packet headers,
Data message forwarding is to client;Reversed multi-connection server takes out the nybble serial number of eight byte packet headers, passes through connection management
The TCP signaling connection of module and reversed multi-connection server sends sequence number confirmation request;
(10.5), when the TCP signaling data failure of cable network module and reversed multi-connection server, mobile network's module
TCP data connection is re-established to reversed multi-connection server (6);Data forwarding module retransmits the message for caching of giving out a contract for a project
To reversed multi-connection server;When guaranteeing connection switching, the data message that internal unit is sent to client is not lost;
Step (11), the practical connection of TCP for establishing reversed multi-connection server (6) by client in this way, it is reversed to connect more
Connect the practical connection of TCP that gateway establishes internal unit, and reversed multi-connection gateway is to reversed multi-connection server
(6) two practical connections of the reversed TCP of redundancy backup give client direct-connected TCP virtual link similar with internal unit offer, most
The port mapping of cable network and movement (4G) network redundancy backup and multiple NAT is realized eventually.
Compared with prior art, the beneficial effects of the invention are as follows:
Using technical solution of the present invention, effectively solves the problems, such as the port mapping of multiple NAT and multi-connection, pass through client
The practical connection of TCP of reversed multi-connection server (6) is established, the TCP that reversed multi-connection gateway establishes internal unit is practical
Connection, and reversed multi-connection gateway is to (6) the two practical connections of the reversed TCP of redundancy backup of reversed multi-connection server,
Give client direct-connected TCP virtual link similar with internal unit offer, it is final to realize that cable network and mobile network's redundancy are standby
The port mapping of part and multiple NAT.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with
It obtains other drawings based on these drawings.
Fig. 1 is a kind of port mapping system allomeric function structural block diagram based on reversed multi-connection in the present invention.
Number mark in figure:Internal unit (1), connection management module (2), mobile network's module (3), data forwarding module
(4), cable network module (5), reversed multi-connection server (6), client (7)
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
As shown in Figure 1:The present invention provides a kind of specific embodiment of port mapping system based on reversed multi-connection, a kind of
Port mapping system based on reversed multi-connection, including needing by the internal unit 1 of port mapping, reversed multi-connection gateway is set
It is standby, reversed multi-connection server 6, client 7;Wherein reversed multi-connection gateway includes connection management module 2, mobile network
Module 3, data forwarding module 4, cable network module 5;
Internal unit 1:Internal unit 1 is that client 7 provides the TCP equipment of service, and internal unit 1 and client 7 do not exist
In consolidated network, internal unit 1 finally provides clothes to client 7 by providing TCP connection to reversed multi-connection gateway
Business;
Client 7:Client 7 is the terminal device for needing to access the service of internal unit 1, and client 7 and internal unit 1 are not
In consolidated network, client 7 passes through TCP connection to reversed multi-connection server 6, the final TCP service for accessing internal unit 1
Device;
Reversed multi-connection server 6:Reversed multi-connection server 6 is in client 7 and reversed multi-connection gateway
Between bridging device, reversed multi-connection server 6 is supplied to the TCP connection service of client 7 Yu reversed multi-connection gateway, together
When be responsible for forwarding the TCP data message forwarding of client 7 and reversed multi-connection gateway to service;
Reversed multi-connection gateway:Reversed multi-connection gateway is reversed multi-connection server 6 and internal unit 1
Intermediate bridging device and management equipment, reversed multi-connection gateway are connected to reversed multi-connection server 6 simultaneously and set with inside
Standby 1, while the TCP data message forwarding for being responsible for the reversed multi-connection server 6 of forwarding and internal unit 1 services;Reversed multi-connection
Gateway manages the TCP port of internal unit 1 to the TCP port mapping relations of reversed multi-connection server 6;
Connection management module 2:For managing the TCP port of internal unit 1 to the TCP port of reversed multi-connection server 6
Mapping relations, manage reversed multi-connection gateway to internal unit 1 and reversed multi-connection server 6 TCP connection;
Data forwarding module 4:For be responsible for management multi-connection gateway and internal unit 1 between and multi-connection net
The TCP connection between equipment and reversed multi-connection server 6 is closed, is responsible for management and reversed multi-connection server 6 is forwarded to set with inside
Standby 1 TCP data message forwards service;
Mobile network's module 3:For realizing the movement between reversed multi-connection gateway and reversed multi-connection server 6
Communication connection, respectively connection management module 2 and data forwarding module 4 provide network service;Mobile network's module 3 can be used
Mobile operator moves 4G, 3G, GPRS network, and network bandwidth is smaller, for connecting backup;
Cable network module 5:For realizing wired between reversed multi-connection gateway and reversed multi-connection server 6
Communication connection, respectively connection management module 2 and data forwarding module 4 provide network service;The Netowrk tape of cable network module 5
Width is larger, primary data communication channel;
Based on a kind of above-mentioned port mapping system based on reversed multi-connection, the present invention also provides one kind to be connected more based on reversed
The specific embodiment of the port mapping method connect, includes the following steps:
Step (1), connection management module 2 establish the redundancy signaling connection of reversed multi-connection server 6, cable network module
5 establish the TCP signaling connection of reversed multi-connection server 6 with mobile network's module 3 respectively;
Step (2), connection management module 2 are preferentially believed using the TCP of cable network module 5 and reversed multi-connection server 6
Enable connecting communication;After the TCP connection is interrupted, connection management module 2 is just using mobile network's module 3 and reversed multi-connection service
The TCP signaling connection of device 6 communicates;
Step (3), connection management module 2 the port of internal unit 1 (such as:192.168.29.12:4000) mapping request
It is sent to reversed multi-connection server 6;
Step (4), reversed multi-connection server 6 receive mapping request, (such as the port of internal unit 1:
192.168.29.12:4000) it is being mapped to reversed 6 mapped port of multi-connection server (such as:10.2.3.4:, and handle 12211)
Mapping relations are saved in Hash Map h1;
Step (5), reversed 6 mapped port of multi-connection server are (such as:10.2.3.4:12211) client 7TCP is received
Connection, inquiry Hash Map h1 obtain mapping relations, send client connection request to connection management module 2;
Step (6), connection management module 2 receive connection request, and notification data forwarding module 4 establishes reverse data company
It connects;
Step (7), the selection of data forwarding module 4 establish the port of internal unit 1 (such as:192.168.29.12:4000)
TCP data connection;
Step (8), data forwarding module 4, which are established, connect process with reversed 6 reverse data of multi-connection server
(8.1), when the TCP signaling connection connected state of cable network module 5 and reversed multi-connection server 6, selection has
Line network module 5 is established TCP data with reversed multi-connection server 6 and is connect;
(8.2), when the TCP signaling connection interrupt status of cable network module 5 and reversed multi-connection server 6, selection is moved
Dynamic network module 3 is established TCP data with reversed multi-connection server 6 and is connect;
(8.3), when cable network module 5 and the TCP signaling data failure of reversed multi-connection server 6, it is switched to shifting
Dynamic network module 3 establishes TCP data connection to reversed multi-connection server (6);
(8.4), when mobile network's module 3 and the TCP signaling data also failure of reversed multi-connection server 6, notice connects
2 disconnecting of management module is connect, this TCP mapping connection business is terminated;
(8.5), because being the reversed multi-connection server 6 of 4 active TCP connection of data forwarding module, even if reversed more
Connection gateway still is able to realize that NAT is penetrated in multiple NAT;
Internally equipment 1 sends datagram process for step (9), client 7
(9.1), client 7 sends the data message of reversed multi-connection server 6;
(9.2), reversed multi-connection server 6 receive client 7 data packet text after increase by eight byte packet headers, forwarding number
According to forwarding module 4;Eight byte packet headers include nybble length and nybble serial number, and nybble length is used for data forwarding module 4
TCP subpackage, nybble serial number is incremented by serial number, takes for cable network module 5, mobile network's module 3 and reversed multi-connection
The TCP data connection switching message of business device 6 resumes;
(9.3), the data packet that reversed multi-connection server 6 is transmitted to data forwarding module 4 saves in caching of giving out a contract for a project;Reversely
Multi-connection server 6 receives serial number confirmation request, and the data for caching of giving out a contract for a project are understood according to serial number;
(9.4), data forwarding module 4 receives the data packet text of reversed multi-connection server 6, removes eight byte packet headers,
Data message forwarding to internal unit 1;Data forwarding module 4 takes out the nybble serial number of eight byte packet headers, passes through connecting tube
Reason module 2 and the TCP signaling connection of reversed multi-connection server 6 send sequence number confirmation request, are used for reversed multi-connection server 6
Clearly give out a contract for a project the data of caching;
(9.5), when the TCP signaling data failure of cable network module 5 and reversed multi-connection server 6, mobile network's mould
Block 3 re-establishes TCP data connection to reversed multi-connection server (6);The message of reversed multi-connection 6 cachings of giving out a contract for a project of server
It retransmits to data forwarding module 4, when guaranteeing connection switching, the data message that client 7 is sent to internal unit 1 is not lost
It loses;
Step (10), internal unit 1 send datagram process to client 7
(10.1), internal unit 1 sends the data message of data forwarding module 4;
(10.2), data forwarding module 4 receive internal unit 1 data packet text after increase by eight byte packet headers, forwarding number
According to forwarding module 4, eight byte packet headers include nybble length and nybble serial number;
(10.3), the data packet that data forwarding module 4 is transmitted to reversed multi-connection server 6 saves in caching of giving out a contract for a project;Instead
Serial number confirmation request is received to data forwarding module 4, the data for caching of giving out a contract for a project are understood according to serial number;
(10.4), reversed multi-connection server 6 receives the data packet text of data forwarding module 4, removes eight byte packet headers,
Data message forwarding to client 7;Reversed multi-connection server 6 takes out the nybble serial number of eight byte packet headers, passes through connection
The TCP signaling connection of management module 2 and reversed multi-connection server 6 sends sequence number confirmation request;
(10.5), when the TCP signaling data failure of cable network module 5 and reversed multi-connection server 6, mobile network's mould
Block 3 re-establishes TCP data connection to reversed multi-connection server (6);The message of 4 cachings of giving out a contract for a project of data forwarding module is again
It is sent to reversed multi-connection server 6;When guaranteeing connection switching, the data message that internal unit 1 is sent to client 7 is not lost
It loses;
Step (11), the practical connection of TCP for establishing reversed multi-connection server (6) by client 7 in this way, it is reversed to connect more
Connect the practical connection of TCP that gateway establishes internal unit 1, and reversed multi-connection gateway is to reversed multi-connection server
(6) two practical connections of the reversed TCP of redundancy backup provide similar direct-connected TCP virtual link with internal unit 1 to client 7,
The final port mapping for realizing cable network and movement (4G) network redundancy backup and multiple NAT.
It should also be noted that, herein, relational terms such as first and second and the like are used merely to one
Entity or operation are distinguished with another entity or operation, without necessarily requiring or implying between these entities or operation
There are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant are intended to contain
Lid non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those
Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment
Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that
There is also other identical elements in process, method, article or equipment including the element.
Each embodiment in this specification is described in a progressive manner, the highlights of each of the examples are with other
The difference of embodiment, the same or similar parts in each embodiment may refer to each other.
The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present invention.
Various modifications to these embodiments will be readily apparent to those skilled in the art, as defined herein
General Principle can be realized in other embodiments without departing from the spirit or scope of the present invention.Therefore, this is practical
It is novel to be not intended to be limited to the embodiments shown herein, and be to fit to principles disclosed herein and
The consistent widest scope of features of novelty.