CN107124478A - Network communication method, device and server - Google Patents

Network communication method, device and server Download PDF

Info

Publication number
CN107124478A
CN107124478A CN201710244488.6A CN201710244488A CN107124478A CN 107124478 A CN107124478 A CN 107124478A CN 201710244488 A CN201710244488 A CN 201710244488A CN 107124478 A CN107124478 A CN 107124478A
Authority
CN
China
Prior art keywords
terminal
source terminal
target terminal
nat
nat types
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201710244488.6A
Other languages
Chinese (zh)
Inventor
黄华
张骏峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Xiaoyi Technology Co Ltd
Original Assignee
Shanghai Xiaoyi Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Xiaoyi Technology Co Ltd filed Critical Shanghai Xiaoyi Technology Co Ltd
Priority to CN201710244488.6A priority Critical patent/CN107124478A/en
Publication of CN107124478A publication Critical patent/CN107124478A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/2521Translation architectures other than single NAT servers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/256NAT traversal
    • H04L61/2589NAT traversal over a relay server, e.g. traversal using relay for network address translation [TURN]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

A kind of network communication method, device and server, the network communication method include:Receive the connection request that source terminal is directed to target terminal;Determine the NAT types of the source terminal and the NAT types of the target terminal;Corresponding communication port is set up according to the NAT types of the NAT types of the source terminal and the target terminal.The efficiency of network service can be improved using technical solution of the present invention.

Description

Network communication method, device and server
Technical field
The present invention relates to communication technical field, more particularly to a kind of network communication method, device and server.
Background technology
Network address translation (Network Address Translation, NAT) is a kind of Intranet (or private network) Technology of location (the also referred to as Lan addresses) conversion (or mapping) into outer net (or public network) address (also referred to as Wan addresses).Simply Ground says that NAT is exactly that internal address is used inside Intranet, and when Intranet internal node will be communicated with external network, just Internal address is substituted for outer net address at gateway (namely outlet of Intranet) place, so as in outer net proper communication.Technology In realization, NAT realizes address conversion by changing the source address or destination address of packet.NAT is mainly the outer entoilage of solution The problem of location is limited, while the equipment to Intranet plays certain hide and protective effect.Intranet node communicates with outer net node Must be by NAT, and if only knowing the Lan addresses of Intranet node, it is not known that its Wan address after being changed through NAT, just can not Communicate with.
At present, global network equipment is outside a few devices have independently outer net address, and other equipment is substantially all in NAT Used under environment.And in order to realize the communication of intranet and extranet node, must just realize that penetrating for NAT sets up communication port.In order to wear Saturating NAT realizes the communication at two ends, mainly there is following scheme:One kind is peer-to-peer network (Peer-to-peer, P2P), end-to-end straight Connect letter;Another is relaying (Relay) system, and transfer is carried out by intermediate node or server.Specifically, it is general to insert i.e. With (Universal Plug and Play, UPnP) network system the NAT modules of gateway or router can be made to do automatic port Mapping, and open this port to outer net;The program is in various bit streams (Bit Torrent, BT) agreement and downloads software In it is more common.Interactive mode connection is set up (Interactive Connectivity Establishment, ICE) and incorporated NAT sessions penetrate effectiveness (Session Traversal Utilities for NAT, STUN) and using relaying penetrating NAT The Integrated Solution of (Traversal Using Relays around NAT, TURN), is also that current social communication comparison leads to A kind of scheme.
But, the communication plan of penetrating NAT of the prior art respectively has weak point, is not appropriate in some scenarios. UPnP schemes need the support of router, operating system and software, and generally require to be configured manually, and have certain Potential safety hazard;On the one hand realization is more complicated for ICE schemes, and ease for use and autgmentability be not strong;On the other hand, flow is also relatively more multiple Miscellaneous, Signalling exchange is more, and according to priority all candidate communication addresses need to one by one be carried out with connectivity checks, thus efficiency compared with It is low.
The content of the invention
Present invention solves the technical problem that being the efficiency for how improving network service.
In order to solve the above technical problems, the embodiment of the present invention provides a kind of network communication method, network communication method includes:
Receive the connection request that source terminal is directed to target terminal;Determine that the NAT types and the target of the source terminal are whole The NAT types at end;Corresponding communication port is set up according to the NAT types of the NAT types of the source terminal and the target terminal.
Optionally, it is described to set up corresponding logical according to the NAT types of the source terminal and the NAT types of the target terminal Letter passage includes:If the NAT types of the source terminal and the NAT types of the target terminal are following any group:Port is limited System is tapered and symmetric form, symmetric form and port limit tapered, symmetric form and symmetric form, then is that the source terminal and the target are whole Trunking traffic passage is set up at end;Otherwise, it is that the source terminal and the target terminal set up P2P communication ports.
Optionally, described is that the source terminal and the target terminal are set up P2P communication ports and included:Notify the source whole The outer net address of the target terminal is held, and notifies the outer net address of source terminal described in the target terminal, it is described to cause Source terminal and the target terminal are according to being set up the outer net address of the target terminal and the outer net address of the source terminal P2P communication ports.
Optionally, the network communication method also includes:Notify the source terminal and the target terminal Relay Server Address, to cause the source terminal and the target terminal when the P2P communication ports set up failure, to utilize the middle following the service The trunking traffic passage is set up in business device address.
Optionally, described is that the source terminal and the target terminal are set up trunking traffic passage and included:Notify the source Terminal and the available Relay Server address of the target terminal, to cause the source terminal and the target terminal according to described The trunking traffic passage is set up in available Relay Server address.
Optionally, the NAT types for determining the source terminal and the NAT types of the target terminal include:Inquiry is pre- The NAT type historical records first stored, to determine the NAT types of the source terminal and the NAT types of the target terminal.
Optionally, the source terminal that receives before the connection request of target terminal for also including:The source is received respectively The outer net Address requests of terminal and the target terminal;Respectively corresponding outer net is fed back to the source terminal and the target terminal Address, to cause the source terminal and the target terminal to determine respective NAT types according to the outer net address of feedback respectively;Point The NAT types of the source terminal and the NAT types of the target terminal are not obtained from the source terminal and target terminal and carry out Storage, to obtain the NAT types historical record.
In order to solve the above technical problems, the embodiment of the invention also discloses a kind of network communication device, network communication device Including:Connection request receiving module, the connection request of target terminal is directed to suitable for receiving source terminal;NAT determination type modules, are fitted In it is determined that the NAT types and the NAT types of the target terminal of the source terminal;Communication port sets up module, suitable for according to institute State the NAT types of source terminal and the NAT types of the target terminal set up corresponding communication port.
Optionally, the communication port is set up module and included:Communication port sets up unit, if suitable for the source terminal NAT types and the NAT types of the target terminal are following any group:Port limits tapered and symmetric form, symmetric form and port Tapered, symmetric form and symmetric form are limited, then is that the source terminal and the target terminal set up trunking traffic passage;Otherwise, it is The source terminal and the target terminal set up P2P communication ports.
Optionally, the communication port is set up unit and included:P2P communication ports set up subelement, suitable for notifying the source The outer net address of target terminal described in terminal, and the outer net address of source terminal described in the target terminal is notified, to cause State source terminal and the target terminal and institute is set up according to the outer net address of the target terminal and the outer net address of the source terminal State P2P communication ports.
Optionally, the communication port is set up unit and also included:Relay Server address transmission sub-unit, suitable for notifying institute Source terminal and the target terminal Relay Server address are stated, to cause the source terminal and the target terminal in the P2P When communication port sets up failure, the trunking traffic passage is set up using the Relay Server address.
Optionally, the communication port is set up unit and included:Trunking traffic Path Setup subelement, suitable for notifying the source Terminal and the available Relay Server address of the target terminal, to cause the source terminal and the target terminal according to described The trunking traffic passage is set up in available Relay Server address.
Optionally, the NAT determination type modules include:Query unit, suitable for inquiring about the NAT type history prestored Record, to determine the NAT types of the source terminal and the NAT types of the target terminal.
Optionally, the network communication device also includes:Outer net Address requests receiving module, suitable for receiving the source respectively The outer net Address requests of terminal and the target terminal;Outer net address feedback module, suitable for respectively to the source terminal and described Target terminal feeds back corresponding outer net address, to cause the outer entoilage of the source terminal and the target terminal respectively according to feedback Location determines respective NAT types;NAT type reception modules, suitable for obtaining the source from the source terminal and target terminal respectively The NAT types of terminal and the NAT types of the target terminal are simultaneously stored, to obtain the NAT types historical record.
In order to solve the above technical problems, the embodiment of the invention also discloses a kind of server, the server includes storage Be stored with the computer instruction that can be run on the processor on device and processor, the memory, the processor operation The step of network communication method being performed during the computer instruction.
Compared with prior art, the technical scheme of the embodiment of the present invention has the advantages that:
Technical solution of the present invention receives the connection request that source terminal is directed to target terminal first;It is then determined that the source terminal NAT types and the target terminal NAT types;NAT types and the target terminal finally according to the source terminal NAT types set up corresponding communication port.Technical solution of the present invention is after connection request is received, according to the source terminal of determination NAT types of NAT types and the target terminal, to set up corresponding communication port, it is to avoid to source terminal and target terminal Various communication ports are set up in trial, advantageously reduce Signalling exchange, so as to quickly set up communication port, improve network The efficiency of communication.
Further, corresponding communication is set up according to the NAT types of the NAT types of the source terminal and the target terminal to lead to Road includes:If the NAT types of the source terminal and the NAT types of the target terminal are following any group:Port limitation cone Type and symmetric form, symmetric form and port limit tapered, symmetric form and symmetric form, then are that the source terminal and the target terminal are built Vertical trunking traffic passage;Otherwise, it is that the source terminal and the target terminal set up P2P communication ports.Technical solution of the present invention By determining the NAT types of communication two ends (source terminal and target terminal), and based on this directly it is selected set up P2P communication ports or Person's trunking traffic passage, realizes and sets up communication port in more efficient quick mode, and then improve the efficiency of network service.
Further, the source terminal that receives before the connection request of target terminal for also including:The source is received respectively The outer net Address requests of terminal and the target terminal;Respectively corresponding outer net is fed back to the source terminal and the target terminal Address, to cause the source terminal and the target terminal to determine respective NAT types according to the outer net address of feedback respectively;Point The NAT types of the source terminal and the NAT types of the target terminal are not obtained from the source terminal and target terminal and carry out Storage, to obtain the NAT types historical record.Technical solution of the present invention is before connection request is received, by source terminal Carry out NAT type detections to get the NAT types of source terminal and the NAT classes of the target terminal with target terminal;In addition, logical Cross and stored the NAT types at the two ends that communicate, can be used for the foundation of multiple NAT types, further increase network service Efficiency.
Brief description of the drawings
Fig. 1 is a kind of flow chart of network communication method of the embodiment of the present invention;
Fig. 2 is a kind of trunking traffic Path Setup schematic flow sheet of the embodiment of the present invention;
Fig. 3 is a kind of P2P communication ports Establishing process schematic diagram of the embodiment of the present invention;
Fig. 4 is the flow chart of another network communication method of the embodiment of the present invention;
Fig. 5 is a kind of structural representation of network communication device of the embodiment of the present invention;
Fig. 6 is the structural representation of another network communication device of the embodiment of the present invention.
Embodiment
As described in the background art, the communication plan of penetrating NAT of the prior art respectively has weak point, in some scenes Under be not appropriate for.UPnP schemes need the support of router, operating system and software, and generally require to be set manually Put, and have certain potential safety hazard;On the one hand realization is more complicated for ICE schemes, and ease for use and autgmentability be not strong;On the other hand, Flow is also more complicated, and Signalling exchange is more, and need to carry out connectivity checks one by one to all candidate communication addresses according to priority, It is thus less efficient.
Present inventor is analyzed as follows to prior art:ICE protocol procedures are more complicated, main as follows in simple terms: (1) communication two ends respectively from server obtain local terminal candidate communication address information (including local terminal Lan addresses, Wan addresses and The address of Relay Server) and determine priority (address priority of general Relay Server is minimum);(2) communication two ends pass through The respective candidate communication address information of server exchange, then two ends are according to the connective inspection of candidate communication address priority progress Look into;(3) from the candidate site by connectivity checks, the candidate site of selection highest priority starts real data and led to Letter.Present inventor has found that ICE schemes are substantially first to attempt P2P to communicate, and relaying are reattempted after P2P communication failures logical Letter, increases, and cause communication efficiency low so as to add Signalling exchange.
The embodiment of the present invention is directed to the UDP (User Datagram Protocol, UDP) under NAT environment Network service, devises the general scheme that a kind of new quick penetrating NAT realizes network service.Technical solution of the present invention is connecing Receive after connection request, it is corresponding to set up by the NAT types and the NAT types of the target terminal of the source terminal of determination Communication port;Avoid and source terminal and target terminal are attempted to set up various communication ports, Signalling exchange is reduced, so as to fast Communication port is set up promptly, improves the efficiency of network service.
It is understandable to enable the above objects, features and advantages of the present invention to become apparent, below in conjunction with the accompanying drawings to the present invention Specific embodiment be described in detail.
Fig. 1 is a kind of flow chart of network communication method of the embodiment of the present invention.
Network communication method described in the present embodiment can be used for server end.
Network communication method shown in Fig. 1 may comprise steps of:
Step S101:Receive the connection request that source terminal is directed to target terminal;
Step S102:Determine the NAT types of the source terminal and the NAT types of the target terminal;
Step S103:Corresponding communication is set up according to the NAT types of the NAT types of the source terminal and the target terminal Passage.
In specific implementation, source terminal initiates the connection request for target terminal, then in step S101, server termination Receive the connection request.So far, server end can determine specific source terminal and target terminal.Specifically, server end The internal address of source terminal and the outer net address of target terminal can be known.
In specific implementation, according to the difference of the NAT types at communication two ends, it is necessary to set up different communication ports.In order to fast Speed sets up communication port exactly, in step s 102, it may be determined that the NAT types of source terminal and the NAT types of target terminal, In order in step s 103, set up corresponding communication according to the NAT types of the NAT types of source terminal and the target terminal logical Road.Specifically, the NAT types of source terminal and the NAT types of target terminal can be stored in advance in server end, also may be used To be that source terminal and target terminal are sent to server end in real time.
The embodiment of the present invention directly sets up communication port according to the NAT types of source terminal and the NAT types of target terminal, keeps away Exempt from that source terminal and target terminal are attempted to set up various communication ports, Signalling exchange has been advantageously reduced, so as to quickly Communication port is set up, the efficiency of network service is improved.
Preferably, step S102 may comprise steps of:The NAT type historical records prestored are inquired about, to determine The NAT types of the source terminal and the NAT types of the target terminal.Specifically, it can be previously stored with server end NAT type historical records.NAT types historical record can include the NAT types of terminal internal address and terminal, then server After terminal internal address is known, the NAT types of terminal can be determined according to NAT type historical records.
Preferably, it may comprise steps of before step S101:The source terminal and the target terminal are received respectively Outer net Address requests;Corresponding outer net address is fed back to the source terminal and the target terminal respectively, to cause the source Terminal and the target terminal determine respective NAT types according to the outer net address of feedback respectively;Respectively from the source terminal and Target terminal obtains the NAT types of the source terminal and the NAT types of the target terminal and stored, described to obtain NAT type historical records.That is, source terminal and target terminal are before being communicated, more specifically, being in source terminal hair Send before connection request, source terminal and target terminal obtain respective NAT types by the interaction with server to detect.
It will be apparent to a skilled person that terminal detection, which obtains respective NAT types, can also use existing skill Other any enforceable modes of art, the embodiment of the present invention is without limitation.
In specific implementation, the NAT types of terminal can include following several:Complete tapered (Full Cone NAT), address Limit tapered (Address-Restricted Cone NAT), port and limit tapered (Port Restricted Cone NAT) With symmetric form (Symmetric NAT).Due to NAT types for symmetric form terminal from same internal address and port to difference Outer net address and port send packet when, can be by the same internal address of the terminal outer net into different with port mapping Address and port, therefore only the outer network termination of warp-wise is transmitted across packet before the terminal, can just receive the outer network termination The packet that same port is sended over.And the port tapered internal address and port numbers to source terminal of limitation is all restricted. That is, only the outer network termination of warp-wise is transmitted across packet before the terminal, the outer network termination can be just received same The packet that port is sended over.Therefore, as long as the NAT types of source terminal and target terminal are following any group:Port limitation cone Type and symmetric form, symmetric form and port limit tapered, symmetric form and symmetric form, and source terminal and target terminal cannot be carried out P2P communicates.
Preferably, step S103 may comprise steps of:If the NAT types and the target terminal of the source terminal NAT types be following any group:Port limitation is tapered and symmetric form, symmetric form and port limit tapered, symmetric form and symmetrical Type, then be that the source terminal and the target terminal set up trunking traffic passage;Otherwise, it is that the source terminal and the target are whole P2P communication ports are set up at end.Specifically, when the NAT types of source terminal and the NAT types of target terminal are following any group: Port limitation is tapered and symmetric form, symmetric form and port limit tapered, symmetric form and symmetric form, and source terminal and target terminal can not P2P communications are carried out, trunking traffic can be carried out, therefore in such a case, it is possible to be that the source terminal and the target terminal are built Vertical trunking traffic passage.
Further, it is that the source terminal and the target terminal are set up trunking traffic passage and may comprise steps of: The source terminal and the available Relay Server address of the target terminal are notified, to cause the source terminal and the target whole The trunking traffic passage is set up in end according to the available Relay Server address.
Detailed process can refer to Fig. 2, wherein, terminal (Client) 1 is source terminal, and terminal (Client) 2 is target terminal.
Terminal 1 sends connection request CONNECT_REQ to server (Server), and request connection terminal 2 is communicated;Clothes Device be engaged according to terminal 1 and the NAT types of terminal 2, signaling RELAY_TO is set up by relaying and notified in terminal 1 and the foundation of terminal 2 Terminal 1 and terminal 2 are told respectively after communication port, and by the address of currently available Relay Server (Relay Server); Terminal 1 and terminal 2 send relayed connection request RELAY_PKT to Relay Server respectively and attempt to set up trunking traffic passage;In Terminal 1 and the success of the trunking traffic Path Setup of terminal 2 are notified after server, terminal 1 and terminal 2 can start formally to receive and dispatch number According to;Terminal 1 and terminal 2 forward respective data flow (Data Stream) to opposite end by Relay Server.
It is understood that connection request CONNECT_REQ can indicate the address (ID of terminal 2) of target terminal;Fig. 2 Shown server can be public network server.
In specific implementation, if the NAT types of source terminal and the NAT types of target terminal are not following any group:End Mouth limitation is tapered and symmetric form, symmetric form and port limit tapered, symmetric form and symmetric form, and source terminal and target terminal can enter Row P2P communicates, therefore in such a case, it is possible to is that the source terminal and the target terminal set up P2P communication ports.
It is understood that in this case, source terminal and target terminal can also carry out trunking traffic, but relay Communication is high relative to P2P communications costs, communication efficiency is low, therefore preferentially carries out P2P communications.
Further, it is that the source terminal and the target terminal are set up P2P communication ports and may comprise steps of:It is logical Know the outer net address of target terminal described in the source terminal, and notify the outer net address of source terminal described in the target terminal, To cause the source terminal and the target terminal according to the outer net address of the target terminal and the outer entoilage of the source terminal The P2P communication ports are set up in location
Detailed process can refer to Fig. 3, wherein, terminal 1 is source terminal, and terminal 2 is target terminal.
Terminal 1 sends connection request CONNECT_REQ to server, and request connection terminal 2 is communicated;Server according to The NAT types of terminal 1 and terminal 2, set up response signaling P2P_TO by P2P and notify terminal 1 and terminal 2 set up P2P communications logical Road, and inform the outer net address (namely WAN Addr) of distant terminal;Terminal 1 and terminal 2 send P2P connection requests P2P_ respectively PKT attempts to set up P2P communication ports to opposite end;It is logical that terminal 1 and terminal 2 set up completion signaling P2P_READY by P2P respectively Know that opposite end P2P communication ports are successfully established, formal transceiving data can be started;Terminal 1 and terminal 2 directly transmit respective data (Data Stream) is flowed to opposite end.
It is understood that server shown in Fig. 3 can be P2P servers
Further, it is that the source terminal and the target terminal set up trunking traffic passage and can also include following step Suddenly:The source terminal and the available Relay Server address of the target terminal are notified, to cause the source terminal and the mesh Mark terminal sets up the trunking traffic passage according to the available Relay Server address.
Specifically, with continued reference to Fig. 3, set up in response signaling P2P_TO, can also be carried as in backup in P2P After server (Relay Server) address, so as to when terminal 1 and terminal 2 set up the failure of P2P communication ports, it is possible to use in Trunking traffic passage is set up after server address, so as to ensure the reliability of network service.
Fig. 4 is the flow chart of another network communication method of the embodiment of the present invention.
Network communication method shown in Fig. 4 may comprise steps of:
Step S401:Source terminal and target terminal perform NAT types and judge flow, obtain respective NAT types;
Step S402:Source terminal and target terminal are sent to server logs in bag/heartbeat packet;
Step S403:Internal address, NAT types and the outer net address of server storage source terminal and target terminal;
Step S404:Source terminal asks linking objective terminal to server;
Step S405:Server judges whether that P2P communications can be carried out according to the NAT types of source terminal and target terminal, such as Fruit is, then into step S406, otherwise into step S408;
Step S406:Set up P2P communication ports;
Step S407:Judge whether P2P communication ports are successfully established, if it is, into step S409, otherwise entering step Rapid S408;
Step S408:Set up trunking traffic passage;
Step S409:The communication port transceiving data that source terminal and target terminal pass through foundation.
In specific implementation, before source terminal and target terminal are communicated, in step S401, source terminal and target are whole End will carry out the judgement of NAT types, then source terminal and target terminal can know respective NAT types.Then in step S402, , can be with source terminal and the respective NAT classes of target terminal when source terminal and target terminal send to server and log in bag/heartbeat packet Type.Specifically, the internal address of source terminal and target terminal can also be included by logging in bag/heartbeat packet.
In specific implementation, before source terminal and target terminal are communicated, in step S403, server can be by source Terminal and the respective NAT types of target terminal and internal address are stored, to form NAT type historical records.
In step s 404, source terminal initiates the connection request to target terminal to server.Then in step S405, clothes Can business device can carry out P2P communications according to the respective NAT types judgement of the source terminal and target terminal that prestore, if Can, then P2P communication ports are set up in step S406, if it is not, setting up trunking traffic passage in step S408.Source is whole Hold the trunking traffic passage transceiving data in step S409 by foundation with target terminal.
Further, in step S 407, judge whether P2P communication ports are successfully established, if it is not, into step S408 sets up trunking traffic passage.If be successfully established, source terminal and target terminal are in step S409 by the P2P of foundation Communication port transceiving data.
It is understood that source terminal and target terminal either party when terminating data and sending, end can be sent, The communication port of foundation, and Resource recovery can then be interrupted.
It will be apparent to a skilled person that step S401 and step S403 can be only performed once, and server The NAT types of each terminal in middle storage area network.Then connection request is initiated in different source terminals to different target terminals When, server can directly determine the NAT types of source terminal and target terminal from the NAT type historical records prestored, To save resource, communication efficiency is improved.
Fig. 5 is a kind of structural representation of network communication device of the embodiment of the present invention.
Network communication device 50 shown in Fig. 5 can be used for server end, and network communication device 50 can include connection please Receiving module 501, NAT determination type modules 502 and communication port is asked to set up module 503.
Wherein, connection request receiving module 501 is suitable to receive the connection request that source terminal is directed to target terminal;NAT types Determining module 502 is adapted to determine that the NAT types of the source terminal and the NAT types of the target terminal;Communication port sets up mould Block 503 is suitable to set up corresponding communication port according to the NAT types of the source terminal and the NAT types of the target terminal.
In specific implementation, according to the difference of the NAT types at communication two ends, it is necessary to set up different communication ports.In order to fast Speed sets up communication port exactly, and NAT determination type modules 502 can determine the NAT types of source terminal and the NAT of target terminal Type, sets up module 503 in order to communication port and is set up according to the NAT types of source terminal and the NAT types of the target terminal Corresponding communication port.Specifically, the NAT types of source terminal and the NAT types of target terminal can be stored in advance in clothes Be engaged in device end or source terminal and target terminal send in real time to server end.
The embodiment of the present invention directly sets up communication port according to the NAT types of source terminal and the NAT types of target terminal, keeps away Exempt from that source terminal and target terminal are attempted to set up various communication ports, Signalling exchange has been reduced, so as to quickly set up logical Believe passage, improve the efficiency of network service.
More contents of operation principle, working method on the network communication device 50, are referred to above to Fig. 1 The associated description of network communication method into Fig. 4, is repeated no more here.
Fig. 6 is the structural representation of another network communication device of the embodiment of the present invention.
Network communication device 60 shown in Fig. 6 can include connection request receiving module 601, NAT determination type modules 602 Module 603 is set up with communication port.
In the present embodiment, connection request receiving module 601, NAT determination type modules 602 and communication port set up module 603 connection request receiving module 501, NAT determination type modules 502 and the communication ports for being referred to shown in Fig. 5 set up module 503, here is omitted.
Preferably, communication port sets up module 603 can set up unit 6031 including communication port, and communication port is set up single If it is following any group that member 6031, which is suitable to the NAT types of the source terminal and the NAT types of the target terminal,:Port is limited Tapered and symmetric form, symmetric form and port limit tapered, symmetric form and symmetric form, then are the source terminal and the target terminal Set up trunking traffic passage;Otherwise, it is that the source terminal and the target terminal set up P2P communication ports.
Preferably, communication port sets up unit 6031 can set up subelement 60311, P2P communications including P2P communication ports Path Setup subelement 60311 is suitable to the outer net address for notifying target terminal described in the source terminal, and notifies the target The outer net address of source terminal described in terminal, to cause the source terminal and the target terminal according to the outer net of the target terminal The outer net address of address and the source terminal sets up the P2P communication ports.
Further, communication port, which sets up unit 6031, can also include Relay Server address transmission sub-unit 60312, It is preferably adapted to notify the source terminal and the target terminal Relay Server address, to cause the source terminal and described Target terminal is set up the trunking traffic when the P2P communication ports set up failure, using the Relay Server address and led to Road.
Preferably, communication port, which sets up unit 6031, can include trunking traffic Path Setup subelement 60313, and relaying is logical Letter Path Setup subelement 60313 is suitable to notify the source terminal and the available Relay Server address of the target terminal, with So that the source terminal and the target terminal set up the trunking traffic passage according to the available Relay Server address.
The embodiment of the present invention is by the NAT types of two ends (source terminal and target terminal) of determining to communicate, and based on this is direct It is selected to set up P2P communication ports or trunking traffic passage, realize and communication port is set up in more efficient quick mode, and then Improve the efficiency of network service.
Preferably, NAT determination type modules 602 can include query unit 6021, and it is pre- that query unit 6021 is suitable to inquiry The NAT type historical records first stored, to determine the NAT types of the source terminal and the NAT types of the target terminal.
Preferably, the network communication device 60 shown in Fig. 6 can also include outer net Address requests receiving module 604, outer net Address feedback module 605 and NAT type receptions module 606, outer net Address requests receiving module 604 are suitable to receive the source respectively The outer net Address requests of terminal and the target terminal;Outer net address feedback module 605 is suitable to respectively to the source terminal and institute State target terminal and feed back corresponding outer net address, to cause the source terminal and the target terminal respectively according to the outer net of feedback Address determines respective NAT types;NAT type receptions module 606 is suitable to obtain institute from the source terminal and target terminal respectively State the NAT types of source terminal and the NAT types of the target terminal and stored, to obtain the NAT types historical record.
The embodiment of the present invention is before connection request is received, by carrying out NAT type detections to source terminal and target terminal To get the NAT types of source terminal and the NAT classes of the target terminal;In addition, by the way that the NAT types at the two ends that communicate are carried out Storage, can be used for the foundation of multiple NAT types, further increases the efficiency of network service.
More contents of operation principle, working method on the synchronous display apparatus 60, are referred to Fig. 1 to Fig. 5 In associated description, repeat no more here.
The embodiment of the invention also discloses a kind of server, the server can include memory and processor, described Be stored with the computer instruction that can be run on the processor on memory.When the processor runs the computer instruction The step of network communication method shown in Fig. 1, Fig. 2, Fig. 3 or Fig. 4 being performed.Specifically, the computer instruction can refer to Make the step of related hardware is to perform network communication method shown in Fig. 1, Fig. 2, Fig. 3 or Fig. 4.
Although present disclosure is as above, the present invention is not limited to this.Any those skilled in the art, are not departing from this In the spirit and scope of invention, it can make various changes or modifications, therefore protection scope of the present invention should be with claim institute The scope of restriction is defined.

Claims (15)

1. a kind of network communication method, it is characterised in that including:
Receive the connection request that source terminal is directed to target terminal;
Determine the NAT types of the source terminal and the NAT types of the target terminal;
Corresponding communication port is set up according to the NAT types of the NAT types of the source terminal and the target terminal.
2. network communication method according to claim 1, it is characterised in that the NAT types according to the source terminal Setting up corresponding communication port with the NAT types of the target terminal includes:
If the NAT types of the source terminal and the NAT types of the target terminal are following any group:
The tapered and symmetric form of port limitation, symmetric form and port limit tapered, symmetric form and symmetric form, then for the source terminal and The target terminal sets up trunking traffic passage;Otherwise, it is that the source terminal and the target terminal set up P2P communication ports.
3. network communication method according to claim 2, it is characterised in that described is that the source terminal and the target are whole P2P communication ports are set up at end to be included:
The outer net address of target terminal described in the source terminal is notified, and notifies the outer net of source terminal described in the target terminal Address, to cause the source terminal and the target terminal according to the outer of the outer net address of the target terminal and the source terminal Net address sets up the P2P communication ports.
4. network communication method according to claim 3, it is characterised in that also include:
The source terminal and the target terminal Relay Server address are notified, to cause the source terminal and the target terminal When the P2P communication ports set up failure, the trunking traffic passage is set up using the Relay Server address.
5. network communication method according to claim 2, it is characterised in that described is that the source terminal and the target are whole Trunking traffic passage is set up at end to be included:
The source terminal and the available Relay Server address of the target terminal are notified, to cause the source terminal and the mesh Mark terminal sets up the trunking traffic passage according to the available Relay Server address.
6. network communication method according to claim 1, it is characterised in that the NAT types of the determination source terminal Include with the NAT types of the target terminal:
The NAT type historical records that prestore are inquired about, to determine the NAT types and the target terminal of the source terminal NAT types.
7. network communication method according to claim 6, it is characterised in that the reception source terminal is for target terminal Also include before connection request:
The outer net Address requests of the source terminal and the target terminal are received respectively;
Corresponding outer net address is fed back to the source terminal and the target terminal respectively, to cause the source terminal and the mesh Mark terminal determines respective NAT types according to the outer net address of feedback respectively;
Respectively the NAT types of the source terminal and the NAT types of the target terminal are obtained from the source terminal and target terminal And stored, to obtain the NAT types historical record.
8. a kind of network communication device, it is characterised in that including:
Connection request receiving module, the connection request of target terminal is directed to suitable for receiving source terminal;
NAT determination type modules, are adapted to determine that the NAT types of the source terminal and the NAT types of the target terminal;
Communication port sets up module, suitable for the NAT types according to the source terminal and the foundation pair of the NAT types of the target terminal The communication port answered.
9. network communication device according to claim 8, it is characterised in that the communication port, which sets up module, to be included:
Communication port sets up unit, if being following suitable for the NAT types of the source terminal and the NAT types of the target terminal Any group:Port limitation is tapered and symmetric form, symmetric form and port limit tapered, symmetric form and symmetric form, then whole for the source End and the target terminal set up trunking traffic passage;Otherwise, it is that the source terminal and the target terminal set up P2P and communicate logical Road.
10. network communication device according to claim 9, it is characterised in that the communication port, which sets up unit, to be included:
P2P communication ports set up subelement, the outer net address suitable for notifying target terminal described in the source terminal, and notify institute The outer net address of source terminal described in target terminal is stated, to cause the source terminal and the target terminal according to the target terminal Outer net address and the outer net address of the source terminal set up the P2P communication ports.
11. network communication device according to claim 10, it is characterised in that the communication port is set up unit and also wrapped Include:
Relay Server address transmission sub-unit, suitable for notifying the source terminal and the target terminal Relay Server address, To cause the source terminal and the target terminal when the P2P communication ports set up failure, to utilize the Relay Server The trunking traffic passage is set up in address.
12. network communication device according to claim 9, it is characterised in that the communication port, which sets up unit, to be included:
Trunking traffic Path Setup subelement, suitable for notifying the source terminal and the available Relay Server of the target terminal Location, to cause the source terminal and the target terminal to set up the trunking traffic according to the available Relay Server address Passage.
13. network communication device according to claim 8, it is characterised in that the NAT determination type modules include:
Query unit, suitable for inquiring about the NAT type historical records prestored, to determine NAT types and the institute of the source terminal State the NAT types of target terminal.
14. network communication device according to claim 13, it is characterised in that also include:
Outer net Address requests receiving module, the outer net Address requests suitable for receiving the source terminal and the target terminal respectively;
Outer net address feedback module, suitable for feeding back corresponding outer net address to the source terminal and the target terminal respectively, with So that the source terminal and the target terminal determine respective NAT types according to the outer net address of feedback respectively;
NAT type reception modules, NAT types and institute suitable for obtaining the source terminal from the source terminal and target terminal respectively State the NAT types of target terminal and stored, to obtain the NAT types historical record.
Can be at the place 15. being stored with a kind of server, it is characterised in that including memory and processor, the memory The computer instruction run on reason device, it is characterised in that perform claim requirement 1 when the processor runs the computer instruction To any one of 7 the step of network communication method.
CN201710244488.6A 2017-04-14 2017-04-14 Network communication method, device and server Pending CN107124478A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710244488.6A CN107124478A (en) 2017-04-14 2017-04-14 Network communication method, device and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710244488.6A CN107124478A (en) 2017-04-14 2017-04-14 Network communication method, device and server

Publications (1)

Publication Number Publication Date
CN107124478A true CN107124478A (en) 2017-09-01

Family

ID=59725412

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710244488.6A Pending CN107124478A (en) 2017-04-14 2017-04-14 Network communication method, device and server

Country Status (1)

Country Link
CN (1) CN107124478A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110611692A (en) * 2018-06-15 2019-12-24 上海宽翼通信科技股份有限公司 WEB access method, system and client based on point-to-point traversal
CN110730203A (en) * 2019-09-04 2020-01-24 华为技术有限公司 P2P communication method and device
CN115225646A (en) * 2021-04-21 2022-10-21 武汉斗鱼鱼乐网络科技有限公司 P2P node recommendation method, terminal, medium and computer equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1863157A (en) * 2005-10-28 2006-11-15 华为技术有限公司 Method and apparatus for implementing network communication through NAT
CN103795819A (en) * 2014-01-27 2014-05-14 杭州顺浪信息技术有限公司 Inter-terminal data transmission method based on NAT in P2P application

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1863157A (en) * 2005-10-28 2006-11-15 华为技术有限公司 Method and apparatus for implementing network communication through NAT
CN103795819A (en) * 2014-01-27 2014-05-14 杭州顺浪信息技术有限公司 Inter-terminal data transmission method based on NAT in P2P application

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110611692A (en) * 2018-06-15 2019-12-24 上海宽翼通信科技股份有限公司 WEB access method, system and client based on point-to-point traversal
CN110730203A (en) * 2019-09-04 2020-01-24 华为技术有限公司 P2P communication method and device
CN115225646A (en) * 2021-04-21 2022-10-21 武汉斗鱼鱼乐网络科技有限公司 P2P node recommendation method, terminal, medium and computer equipment

Similar Documents

Publication Publication Date Title
EP2645679B1 (en) Method and apparatus for message transmission
CN101141420B (en) Method and system for performing data communication between private network and public network
CN106210092B (en) A kind of P2P traversing method and its system merging UPNP and STUN
KR20080050973A (en) Control tunnel and direct tunnel configuration method in ipv6 service provide system based ipv4 network
US20030048780A1 (en) Supporting real-time multimedia applications via a network address translator
US10367893B1 (en) Method and apparatus of performing peer-to-peer communication establishment
CN110266828A (en) A kind of method, apparatus and network system for establishing end to end network connection
CN104980528A (en) Method, system and apparatus for realizing communication between nodes
WO2021008591A1 (en) Data transmission method, device, and system
CN107124478A (en) Network communication method, device and server
CN108429682A (en) A kind of optimization method and system of network transmission link
CN103986638A (en) Method and device for binding multiple public network links for ADVPN tunnel
US10178015B2 (en) Methods, systems, and computer readable media for testing network equipment devices using connectionless protocols
CN111510365A (en) Wi-Fi data packet-based device bridging cloud method, device and medium
CN111800341B (en) Cross-router terminal communication method and device
CN105681445A (en) Method and device for selecting point-to-point transmission path of data
CN106878481B (en) Method, device and system for acquiring Internet Protocol (IP) address
US20230291706A1 (en) Method for accessing network, media gateway, electronic device and storage medium
CN113300871B (en) Networking method and device of simulation network
US10812383B2 (en) Communication apparatus and communication method
TWI504213B (en) Method for address translator traversal in 3gpp networks
CN111064814B (en) VxLAN NAT traversal method, system and gateway based on PCP
CN113542395B (en) Message processing method and message processing system
CN108616962B (en) Data network information processing method and device and terminal
CN112910791B (en) Diversion system and method thereof

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20170901