CN105187567B - A kind of audio/video communication method based on SIP and ICE - Google Patents

A kind of audio/video communication method based on SIP and ICE Download PDF

Info

Publication number
CN105187567B
CN105187567B CN201510352773.0A CN201510352773A CN105187567B CN 105187567 B CN105187567 B CN 105187567B CN 201510352773 A CN201510352773 A CN 201510352773A CN 105187567 B CN105187567 B CN 105187567B
Authority
CN
China
Prior art keywords
port
nat
address
server
client
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.)
Active
Application number
CN201510352773.0A
Other languages
Chinese (zh)
Other versions
CN105187567A (en
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.)
Guangdong Enweishi Technology Co ltd
Original Assignee
SOUTHSTAR ELECTRONICS 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 SOUTHSTAR ELECTRONICS Ltd filed Critical SOUTHSTAR ELECTRONICS Ltd
Priority to CN201510352773.0A priority Critical patent/CN105187567B/en
Publication of CN105187567A publication Critical patent/CN105187567A/en
Application granted granted Critical
Publication of CN105187567B publication Critical patent/CN105187567B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/256NAT traversal
    • 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/2517Translation of Internet protocol [IP] addresses using port numbers

Abstract

The present invention provides a kind of audio/video communication method based on SIP and ICE, and described method includes following steps: call starts, user end to server initiating port distribution request, obtains eight Intranet port numbers of server middle port distribution module distribution;Start ICE, and detects our NAT type and collect our candidate site information;Communicating pair swaps the NAT type respectively got and candidate site information, and the NAT type of the NAT type of other side and we is merged into a NAT composite type, if other side's NAT type is Symmetric NAT or Cone NAT, calculates other side and predict port;It selects corresponding candidate site information to be matched according to NAT composite type, generates detection list;Continuity testing is carried out, channel is established.The present invention realizes the audio-video P2P under Symmetric NAT, and reduces the ICE negotiation time, improves the communication efficiency of audio-video.

Description

A kind of audio/video communication method based on SIP and ICE
Technical field
The present invention relates to a kind of audio/video communication more particularly to a kind of audio/video communication methods based on SIP and ICE.
Background technique
Real-time network audio/video communication is developed by earliest VoIP (Voice over IP), and VoIP is to voice data It is compressed, decompression processing, then data is packaged and is unpacked with IP and other agreements, are passed to realize using IP network Can defeated voice data, real-time network audio/video communication decide that can social networks develop the new platform that march toward by application extensively Rank decides that can the communication mode of people have new breakthrough, and it is that one kind has efficacious prescriptions that instant audio/video transmission is carried out with P2P Formula, but With the fast development of internet, the exhaustion of the address IPv4, NAT (Network Address Translation, that is, net Network address conversion) equipment and technology come into being, and from the technical standpoint of realization, NAT is segmented into following 7 class: Full Cone NAT (boring NAT entirely), the restricted cone NAT of Restricted Cone NAT(), (port Port Restricted Cone NAT Restricted cone NAT), Symmetric NAT (Symmetric NAT), UDP network congestion, be located at symmetrical UDP firewall after and in public affairs On the net, general only to Full Cone NAT (boring NAT entirely), the restricted cone NAT of Restricted Cone NAT(), Port Restricted Cone NAT (the restricted cone NAT in port) and Symmetric NAT (Symmetric NAT) are studied, wherein Full Cone NAT (boring NAT entirely), the restricted cone NAT of Restricted Cone NAT() and Port Restricted Cone NAT (the restricted cone NAT in port) belongs to Cone NAT(taper NAT) this major class, the use of NAT can effectively delay The problem of solution internet fast development leads to IPv4 address shortage, and the safety of internal network is improved, but serious shadow Ring the P2P(peer-to-peer network of audio-video) it realizes, because the presence of NAT device only allows internal host, active transmission data packet is arrived External network is intended to actively access the data packet of internal host to the external equipment that internal host before did not accessed Can directly be abandoned by NAT device so that at present by the P2P technology of extensive concern, especially audio-video P2P development by Very big restriction, the client after different NAT or firewall carry out audio-video P2P and have difficulties, especially In the presence of Symmetric NAT, so that the P2P of audio-video is more difficult to realize, so that P2P success rate is not high.
ICE(Interactive Connectivity Establishment, interactive mode connection are established) it is a kind of flexible Reliable scheme comprehensively utilizes the agreements such as existing STUN and TURN and carries out extension appropriate to it and realizes what NAT was passed through, can It is passed through with the NAT being suitable under various network topologies, to the network for deploying Symmetric NAT, carries out transfer using TURN, Disclose that application No. is a kind of 201210160837.3 Chinese patent " the quick private networks based on ICE in VoIP in the prior art Traversing method ", this method carry out NAT type detection first, and testing result is symmetric NAT environment or asymmetric form NAT ring Border;For symmetric NAT environment, the method is examined just for the connectivity of host candidate site and relay candidate address It looks into;For asymmetric form NAT environment, the method is just for host candidate site and anti-body candidate site (the i.e. outer net of server Address) connectivity checked that above-mentioned this method is improved in traditional ICE agreement: i.e. in former RFC5425 On the basis of, in conjunction with its application scenarios (VoIP system for focusing on voice high efficiency), ICE is improved, is received in address Increase NAT type detection before collection, the step for increase so that: under asymmetric NAT environment, without carrying out the address TURN Generation and keep-alive reduce expense, and connectivity checks then ensure that the voice high efficiency of transmission under same private network environment;Symmetric NAT Under environment, without carrying out keep-alive of the return address STUN on NAT, connectivity checks with the address reduce expense and matchmaker Body connection is successfully established time delay, realizes that quick private network passes through, but the ICE mode of passing through after this optimization cannot be in Symmetric P2P is realized in NAT, fails largely to improve P2P success rate, and the degree of optimization in detection list is smaller, to reduction The negotiation limited time of ICE, the negotiation time of ICE refer to that list is detected from ICE forms to channel the time for forming needs, because This studies that a kind of practicability is more preferable, the stronger NAT of applicability passes through mode to realize that instant network audio/video communication P2P seems non- It is often significant.
Summary of the invention
The technical problem to be solved in the present invention is to provide a kind of audio/video communication method based on SIP and ICE, improve P2P success rate reduces ICE and negotiates the time, to improve audio/video communication efficiency.
The present invention is implemented as follows: a kind of audio/video communication method based on SIP and ICE, the method need to provide end Mouth distribution module, the Intranet port that the port assignment module is used for as client Distribution dynamics, the method includes walking as follows It is rapid:
Step 10, call start, user end to server initiating port distribution request, obtain server middle port distribution mould Eight Intranet port numbers of block distribution, eight Intranet port numbers include that 4 host candidate site port numbers and 4 Intranets are stayed Hole port numbers;
Step 20, starting ICE, and detect our NAT type and collect our candidate site information;
Step 30, communicating pair swap the NAT type respectively got and candidate site information, obtain other side's The NAT type of the NAT type of other side and we is merged into a NAT composite type by NAT type, meanwhile, judge other side NAT Whether type is Symmetric NAT or Cone NAT, if so, calculating other side predicts port, the Cone NAT includes Otherwise Full cone NAT, Port Restricted Cone NAT and Restricted Cone NAT are directly entered step 40;
Step 40 selects corresponding candidate site information to be matched according to NAT composite type, generates detection list;
Step 50 carries out continuity testing according to detection list, establishes channel.
Further, the step 10 specifically includes:
Step 11, call start, and client and server establish TCP long connection, the port assignment module into server The port resource of Intranet locating for request distribution client;
It is not used from Intranet locating for inquiring client terminal in resource pool after step 12, port assignment module receive request Port resource number, and the smallest port resource number in not used port resource number is selected to distribute to client, the port money Source number is the integer between 0 ~ 2015, corresponding 32 port numbers of each port resource number, the i.e. port that port resource num includes Range is
Step 13, client take out port resource num from the response of server0, and by port resource num0Meter Corresponding eight Intranets port numbers port1 ~ port8 is calculated, calculation is as follows: by port resource num0, obtain corresponding The range of 32 port numbers, by 32 port numbers press from greatly to Small sequence is divided into 8 group a1 ~ a8, and every group includes 4 continuous port numbers, wherein preceding 4 group a1 ~ a4 are sequentially allocated to audio RTP, audio RTCP, video RTP and video RTCP, rear 4 group a5 ~ a8 are sequentially allocated as Intranet box out port to audio RTP, audio RTCP, video RTP and video RTCP choose every group in 8 group a1 ~ a8 of maximum port and form eight Intranet ports Port1 ~ port8, when the port of selection is occupied by other programs, then from one progress of selection in remaining 3 port in the group Substitution.
Further, the specific steps of acquisition we's NAT type include: in the step 20
Step 21 carries out test 1, if test 1 has response, enters step 22, otherwise, is judged to UDP network congestion, enters Step 30;
Step 22 judges the outer net IP of the client and the master of port and the client in return message that client receives Whether machine IP is consistent with port, if so, entering step 23, otherwise enters step 24;
Step 23 carries out test 2, if test 2 has response, after being judged to being located at symmetrical UDP firewall, enters step 30, otherwise, it is judged on public network, enters step 30;
Step 24 carries out test 2, if test 2 has response, is determined as Full cone NAT, enters step 30, otherwise, Enter step 25;
Step 25 carries out test 3, judges the outer net IP of the client and port and step in return message that client receives Whether the outer net IP of the client obtained after 1 response of test in rapid 22 is consistent with port, if so, 26 are entered step, otherwise, It is judged to Symmetric NAT, enters step 30;
Step 26 carries out test 4, if test 4 has response, is judged to Restricted Cone NAT, enters step 30, Otherwise, it is judged to Port Restricted Cone NAT, enters step 30;
What above-mentioned test 1, test 2, test 3 and test 4 were defined by the sequencing of NAT type detection.
Further, the test 1 are as follows: client sends to the first IP and first port of stun server and requests, and After asking stun server to receive request, responded with the first IP and first port;
The test 2 are as follows: client sends to the first IP and first port of stun server and requests, it is desirable that stun service After device receives request, responded with the 2nd IP and second port;
The test 3 are as follows: client sends to the 2nd IP and second port of stun server and requests, it is desirable that stun service After device receives request, responded with the 2nd IP and second port;
The test 4 are as follows: client sends to the first IP and first port of stun server and requests, it is desirable that stun service After device receives request, responded with the first IP and second port.
Further, communicating pair carries out the NAT type respectively got and candidate site information in the step 30 The concrete mode of exchange are as follows: client is by our NAT type and our candidate site Information encapsulation into the message body SDP of SIP It swaps, the candidate site information includes host candidate site information, Server Relay candidate site information and server Anti- body candidate site information.
Further, the specific steps of calculating other side prediction port include: in the step 30
A1, port9 ~ port12 is set as the outer net port in the anti-body candidate site information of the other side's server got, Port13 ~ port16 is the port that maps at Symmetric NAT of other side's box out port, judge other side whether be Symmetric NAT, if so, entering step A2;Otherwise A3 is entered step;
A2, judge that port1 ~ port4 port of other side's outer net port port9 ~ port12 respectively with the distribution of other side's Intranet is No correspondence is consistent, if so, obtaining other side predicts that port is { p-16, p-20, p-24, p-28 }, wherein, and flag bit is set, 40 are entered step, otherwise, judges other side's outer net port Port9 ~ port12 whether at a tolerance be h arithmetic progression, if so, obtain other side predict port be port12+h, Port12+2h, port12+3h, port12+4h }, and flag bit is set, 40 are entered step, otherwise, random given 4 1024 are arrived Integer between 65535 predicts port as other side, enters step 40;
A3, judge whether other side is Cone NAT, if so, obtaining other side predicts that port is port9 ~ port12, and set Flag bit is set, enters step 40;Otherwise, other side port is not predicted, is directly entered step 40.
Further, judge in the step A2 other side port9 ~ port12 respectively with other side's Intranet distribution port1 ~ Whether the port port4 is consistent, and specific step is as follows:
B1, port9 ~ port12 is sequentially stored into array rem_port [4], judges i from 0 to 3, rem_port [i] is It is no to be gradually reduced, if so, calculating rem_port [i] corresponding port resource number, And first port numbers is obtained by port resource res_num, and when calculating i from 0 to 3,, enter step B2;Otherwise, the port1 that other side port9 ~ port12 is distributed with other side's Intranet respectively ~ The port port4 is inconsistent;
B2, it judges whether there is, if so, other side port9 ~ port12 distinguishes It is consistent with the port port1 ~ port4 of other side's Intranet distribution, otherwise, what other side port9 ~ port12 was distributed with other side's Intranet respectively The port port1 ~ port4 is inconsistent.
Further, the step 40 specifically:
Step 41 judges whether the outer net address of communicating pair is identical, if they are the same, then 42 is entered step, otherwise, into step Rapid 43;
Step 42 judges whether communicating pair is under same local area network, if so, only generating address to being our host Address enters step 50 to the detection list of peer address;Otherwise, address is only generated to for our host address to other side Outer net address and our Server Relay address enter step 50 to the detection list of other side's Server Relay address;
Step 43, judge NAT composite type whether be our Symmetric NAT and other side Symmetric NAT or For our Symmetric NAT and other side Cone NAT, if so, judging whether to be equipped with flag bit, if having set flag bit, only Address is generated to the detection list for net address outside our host address to other side, and our host address source port is revised as Intranet box out port in step 10, and destination address ports number are revised as the other side in step 30 and predict port, into step Rapid 50;If not setting flag bit, address is generated to for net address, our host address to other side outside our host address to other side Server Relay address, our Server Relay address to the outer net address of other side, our Server Relay address to peer Address and our Server Relay address enter step 50 to the detection list of other side's Server Relay address;Otherwise, enter Step 44;
Step 44 judges whether NAT composite type is our Cone NAT and other side Symmetric NAT, if so, sentencing It is disconnected whether to be equipped with flag bit, then flag bit has been set, then has only generated address to the inspection for net address outside our host address to other side List is surveyed, and destination address ports number are revised as the other side in step 30 and predict port, enters step 50;If not being marked with will Position, then generate address to for net address outside our host address to other side, we's host address to other side's Server Relay address, Our Server Relay address is to the outer net address of other side, our Server Relay address to peer address and we's server Relay address enters step 50 to the detection list of other side's Server Relay address;Otherwise, 45 are entered step;
Step 45 judges whether NAT composite type is our Cone NAT and other side Cone NAT, if so, judgement is It is no to be equipped with flag bit, if so, only generating address to the detection list for net address outside our host address to other side, into step Rapid 50;Otherwise, 46 are entered step;
Step 46, generation address are serviced to other side for net address, our host address outside our host address to other side Device relay address, our Server Relay address to the outer net address of other side, our Server Relay address to peer address With our Server Relay address to the detection list of other side's Server Relay address, 50 are entered step.
Further, it detects that client and server disconnect the method also includes step 60, port assignment module to connect When connecing, port resource is recovered to a resource reclaim buffer area, and timing module is recycled by Single port, in one period of timing The port resource in resource reclaim buffer area is recycled after t, when mapping of the time period t more than or equal to NAT maintains Between.
Further, when carrying out NAT type detection and candidate site information is collected, multi-level NAT, then obtained if it exists NAT type be the most stringent of NAT type of restricted type, the outer net address in candidate site information is the address outermost layer NAT, described NAT type by restricted type stringency from big to small successively are as follows: Symmetric NAT, Port Restricted Cone NAT, Restricted Cone NAT、Full Cone NAT。
The present invention has the advantage that being that client distributes regular Intranet port, then leads to by miniport service module It crosses acquisition other side NAT type and other side port is predicted, selectively generate detection list, remove unwanted address It is right, greatly reduce the ICE negotiation time, improve the communication efficiency of audio-video, while the present invention also by other side port into Row prediction, realizes the audio-video P2P under Symmetric NAT, substantially increases P2P success rate.
Detailed description of the invention
The present invention is further illustrated in conjunction with the embodiments with reference to the accompanying drawings.
Fig. 1 is the method for the present invention execution flow chart.
Fig. 2 is NAT type detection flow chart in the method for the present invention.
Fig. 3 is the method for the present invention port prediction flow chart.
Fig. 4 is that list product process figure is detected in the method for the present invention.
Fig. 5 is port mapping schematic diagram.
Fig. 6 is box out and point-to-point path schematic diagram of the communicating pair when being Symmetric NAT.
Fig. 7 is box out when a side is Symmetric NAT in communicating pair and another party is Cone NAT and point-to-point Path schematic diagram.
Specific embodiment
A kind of audio/video communication method based on SIP and ICE referring to FIG. 1 to FIG. 4, the method need to provide port point With module, the Intranet port that the port assignment module is used for as client Distribution dynamics, described method includes following steps:
Step 10, call start, user end to server initiating port distribution request, obtain server middle port distribution mould Eight Intranet port numbers of block distribution, eight Intranet port numbers include that 4 host candidate site port numbers and 4 Intranets are stayed Hole port numbers, the step 10 further comprises:
Step 11, call start, and client and server establish TCP long connection, the port assignment module into server The port resource of Intranet locating for request distribution client;
It is not used from Intranet locating for inquiring client terminal in resource pool after step 12, port assignment module receive request Port resource number, and the smallest port resource number in not used port resource number is selected to distribute to client, the port money Source number is the integer between 0 ~ 2015, corresponding 32 port numbers of each port resource number, the i.e. port that port resource num includes Range is
Step 13, client take out port resource num from the response of server0, and by port resource num0Meter Corresponding eight Intranets port numbers port1 ~ port8 is calculated, calculation is as follows: by port resource num0, obtain corresponding The range of 32 port numbers, by 32 port numbers press from greatly to Small sequence is divided into 8 group a1 ~ a8, and every group includes 4 continuous port numbers, wherein preceding 4 group a1 ~ a4 are sequentially allocated to audio RTP, audio RTCP, video RTP and video RTCP, rear 4 group a5 ~ a8 are sequentially allocated as Intranet box out port to audio RTP, audio RTCP, video RTP and video RTCP choose every group in 8 group a1 ~ a8 of maximum port and form eight Intranet ports Port1 ~ port8 takes port1 ~ port4 to be followed successively by the Intranet end of audio RTP, audio RTCP, video RTP and video RTCP Mouthful, and port5 ~ port8 is taken to be followed successively by the Intranet box out port of audio RTP, audio RTCP, video RTP and video RTCP, it is selecting It, then, can be big by port from selection one is substituted in remaining 3 port in the group when port taken is occupied by other programs Small definition priority, for example selection replacement is carried out by priority from big to small, when port is occupied, select remaining port In it is biggish be replaced, in this way to 4 ports of every group of distribution, be used for Flexible change, can be objective in the Intranet port of selection When other programs of family end occupy, elasticity selects other ports;
Step 20, starting ICE, and detect our NAT type and collect our candidate site information, wherein obtain we The specific steps of NAT type include:
Step 21 carries out test 1, if test 1 has response, enters step step 22, otherwise, is judged to UDP network congestion, Enter step step 30;
Step 22 judges the outer net IP of the client and the master of port and the client in return message that client receives Whether machine IP is consistent with port, if so, entering step 23, otherwise enters step 24;
Step 23 carries out test 2, if test 2 has response, after being judged to being located at symmetrical UDP firewall, enters step 30, otherwise, it is judged on public network, enters step 30;
Step 24 carries out test 2, if test 2 has response, is determined as Full cone NAT, enters step 30, otherwise, Enter step 25;
Step 25 carries out test 3, judges the outer net IP of the client and port and step in return message that client receives Whether the outer net IP of the client obtained after 1 response of test in rapid 22 is consistent with port, if so, 26 are entered step, otherwise, It is judged to Symmetric NAT, enters step 30;
Step 26 carries out test 4, if test 4 has response, is judged to Restricted Cone NAT, enters step 30, Otherwise, it is judged to Port Restricted Cone NAT, enters step 30;
The test 1 are as follows: client sends to the first IP and first port of stun server and requests, it is desirable that stun service After device receives request, responded with the first IP and first port;
The test 2 are as follows: client sends to the first IP and first port of stun server and requests, it is desirable that stun service After device receives request, responded with the 2nd IP and second port;
The test 3 are as follows: client sends to the 2nd IP and second port of stun server and requests, it is desirable that stun service After device receives request, responded with the 2nd IP and second port;
The test 4 are as follows: client sends to the first IP and first port of stun server and requests, it is desirable that stun service After device receives request, responded with the first IP and second port;
Step 30, communicating pair swap the NAT type respectively got and candidate site information, obtain other side's The NAT type of the NAT type of other side and we is merged into a NAT composite type by NAT type, meanwhile, judge other side NAT Whether type is Symmetric NAT or Cone NAT, if so, calculating other side predicts port, the Cone NAT includes Otherwise Full cone NAT, Port Restricted Cone NAT and Restricted Cone NAT are directly entered step 40;
Wherein, the concrete mode that communicating pair swaps the NAT type respectively got and candidate site information are as follows: Client by our NAT type and our candidate site Information encapsulation into swapping in the message body SDP of SIP, i.e., SIP's The field about NAT type, such as form of " a=NAT: types value " are added in message body SDP, so that SIP exchanges candidate site While information, NAT type information is also had exchanged, communicating pair can parse other side's from the other side SDP received NAT type, the candidate site information include that host candidate site information, Server Relay candidate site information and server are anti- Body candidate site information, the host that the port-for-port server in the host candidate site information distributes to the client are waited Selection of land location port numbers;
Wherein, calculating other side predicts that the specific steps of port include:
A1, port9 ~ port12 is set as the outer net port in the anti-body candidate site information of the other side's server got, Port13 ~ port16 is the port that other side's box out port is mapped at Symmetric NAT, i.e. port13 ~ port16 is only in NAT What type created when being Symmetric NAT, it is not created when NAT type is Cont NAT or other types, port is reflected Penetrate relationship as shown in figure 5, and port9 ~ port16 is sequentially stored into array rem_port [4], i.e. rem_port [0]=port9, Rem_port [1]=port10, rem_port [2]=port11, rem_port [3]=port12, judge other side whether be Symmetric NAT, if so, entering step A2;Otherwise A3 is entered step;
Step A2, judge port1 ~ port4 end of other side's outer net port port9 ~ port12 respectively with the distribution of other side's Intranet It is consistent whether mouth corresponds to, if so, obtaining other side predicts that port is { p-16, p-20, p-24, p-28 }, wherein, and flag bit is set, 40 are entered step, otherwise, is judged outside other side Whether net port port9 ~ port12 is the arithmetic progression of h at a tolerance, that is, whether there is rem_port [i]-rem_port [i- 1]=h (h is constant), if so, obtaining other side predicts that port is { port12+h, port12+2h, port12+3h, port12+ 4h }, and flag bit is set, 40 are entered step, otherwise, the random integer given between 4 1024 to 65535 is predicted as other side Port;Wherein, judge other side's outer net port port9 ~ port12 respectively with other side's Intranet distribution the port port1 ~ port4 whether Correspondence is consistent, and specific step is as follows: first judging i from 0 to 3, whether rem_port [i] is gradually reduced, if so, calculating rem_ The corresponding port resource number of port [i], and first is obtained by res_num A port numbers, and when calculating i from 0 to 3,;Judgement It whether there is, if so, determining that other side port9 ~ port12 divides with other side's Intranet respectively The port port1 ~ port4 matched is consistent, and otherwise, directly judgement other side port9 ~ port12 is distributed with other side's Intranet respectively The port port1 ~ port4 is inconsistent;
A3, judge whether other side is Cone NAT, if so, obtaining other side predicts that port is port9 ~ port12, and set Flag bit is set, enters step 40;Otherwise, if the NAT type of other side is other types or there is no NAT types, not to other side Port is predicted, step 40 is directly entered;
Step 40 selects corresponding candidate site information to be matched according to NAT composite type, generates detection list;Institute State step 40 specifically:
Step 41 judges whether the outer net address of communicating pair is identical, if they are the same, then 42 is entered step, otherwise, into step Rapid 43;
Step 42 judges whether communicating pair is under same local area network, if so, selecting our host address and other side Host address only generates address to being the detection list of our host address to peer address, enters step 50;Otherwise, Our host address, our Server Relay address, the outer net address of other side and other side's Server Relay address are selected, only generates ground Location is to the inspection for net address and our Server Relay address to other side's Server Relay address outside our host address to other side List is surveyed, enters step 50;
Step 43, judge NAT composite type whether be our Symmetric NAT and other side Symmetric NAT or For our Symmetric NAT and other side Cone NAT, if so, judging whether that be equipped with flag bit selects if having set flag bit Our host address and the outer net address of other side are selected, address is only generated and the detection for net address outside our host address to other side is arranged Table, and our host address source port is revised as corresponding Intranet box out port port5 ~ port8, and by destination address ports The other side number being revised as in step 30 predicts port, enters step 50;If not setting flag bit, our host address, sheet are selected Square Server Relay address, peer address, the outer net address of other side and other side's Server Relay address, generate address to for originally Square host address is to the outer net address of other side, our host address to other side's Server Relay address, we's Server Relay address Net address, our Server Relay address to peer address and our Server Relay address take to other side outside to other side The detection list of business device relay address, enters step 50;Otherwise, 44 are entered step;
Step 44 judges whether NAT composite type is our Cone NAT and other side Symmetric NAT, if so, sentencing It is disconnected whether to be equipped with flag bit, then set flag bit, then selected our host address and the outer net address of other side, only generate address to for Our host address is to the detection list of the outer net address of other side, and it is pre- that destination address ports number are revised as the other side in step 30 Port is surveyed, enters step 50;If not setting flag bit, our host address, our Server Relay address, peer are selected Address, other side outer net address, other side's Server Relay address, generate address to for net address outside we's host address to other side, Net address, our server outside our host address to other side's Server Relay address, we Server Relay address to other side Relay address enters to peer address and our Server Relay address to the detection list of other side's Server Relay address Step 50;Otherwise, 45 are entered step;
Step 45 judges whether NAT composite type is our Cone NAT and other side Cone NAT, if so, judgement is It is no to be equipped with flag bit, if so, select our host address and the outer net address of other side, address is only generated to for we's host address The detection list of net address, enters step 50 outside to other side;Otherwise, 46 are entered step;
In step 46, any other situation, our host address, our Server Relay address, peer are selected Address, the outer net address of other side and other side's Server Relay address, generate address to for net address outside we's host address to other side, Net address, our server outside our host address to other side's Server Relay address, we Server Relay address to other side Relay address enters to peer address and our Server Relay address to the detection list of other side's Server Relay address Step 50;
Step 50 carries out continuity testing according to detection list, establishes channel.
When step 60, port assignment module detect that client and server disconnect, port resource is recovered to one Resource reclaim buffer area, and timing module is recycled by Single port, it will be in resource reclaim buffer area after one time period t of timing Port resource is recycled, and mapping of the time period t more than or equal to NAT is held time.
In addition, multi-level NAT, then obtain if it exists when carrying out NAT type detection and candidate site information is collected NAT type is the most stringent of NAT type of restricted type, and the outer net address in candidate site information is the address outermost layer NAT, described NAT type by restricted type stringency from big to small successively are as follows: Symmetric NAT, Port Restricted Cone NAT, Restricted Cone NAT、Full Cone NAT。
In addition, RTP and RTCP are respectively defined as comp1(component 1 in ICE) and comp2(component 2), multimedia is logical Road includes that the respective audio RTP of communicating pair, audio RTCP, video RTP and video RTCP, i.e. voice-grade channel and video channel are equal Respectively include comp1(component 1) and comp2(component 2), in the method for the present invention under this NAT type of Symmetric NAT, Joined the concept of box out port, if the RTP in 4 channels of box out port is defined as comp3(component 3), RTCP definition For comp4(component 4), component 3 and component 4 are just only created in the case where Symmetric NAT, and the present invention is only right Symmetric NAT and Cone NAT carry out the prediction of port, are communicated according to the method for the present invention, are in communicating pair When Symmetric NAT, the box out port and point-to-point path of available such as Fig. 6, a side is in communicating pair Symmetric NAT and another party obtain the box out port and point-to-point path such as Fig. 7 when being Cone NAT.Wherein, Fig. 6 and figure Dotted line in 7 indicates original point-to-point transmission channel, in two kinds of NAT combination in figure 6 and figure 7, the biography at these dotted lines Defeated channel is that detection is obstructed in the ICE detection connection link below, in order to can be realized data flow under both combinations Point-to-point transmission, it is necessary to modify to these point-to-point transmission channels.If the distribution of Symmetric nat port is regular, Then solid line in addition to indicate that box out effect is outer or back ICE detection list in local host address to other side outside net address this Is detected to the point-to-point to be modified as by path for address.
Although specific embodiments of the present invention have been described above, those familiar with the art should be managed Solution, we are merely exemplary described specific embodiment, rather than for the restriction to the scope of the present invention, it is familiar with this The technical staff in field should be covered of the invention according to modification and variation equivalent made by spirit of the invention In scope of the claimed protection.

Claims (7)

1. a kind of audio/video communication method based on SIP and ICE, it is characterised in that: the method need to provide port assignment module, The Intranet port that the port assignment module is used for as client Distribution dynamics, described method includes following steps: step 10 is led to Words start, user end to server initiating port distribution request, obtain eight Intranets of server middle port distribution module distribution Port numbers, eight Intranet port numbers include 4 host candidate site port numbers and 4 Intranet box out port numbers;The step Rapid 10 specifically include: step 11, call start, and client and server establish TCP long connection, the port assignment into server Module request distributes the port resource of Intranet locating for client;After step 12, port assignment module receive request, from resource pool Not used port resource number in Intranet locating for inquiring client terminal, and select the smallest port money in not used port resource number Client is distributed in source number, and the port resource number is the integer between 0 ~ 2015, corresponding 32 ports of each port resource number Number, i.e., the range of port number that port resource num includes is;Step 13, client are taken out given from the response of server Port resource number, and corresponding eight Intranets port numbers port1 ~ port8 is calculated by the port resource number, calculation is such as Under: by port resource number, the range of corresponding 32 port numbers is obtained, which is divided by sequence from big to small 8 group a1 ~ a8, every group includes 4 continuous port numbers, wherein preceding 4 group a1 ~ a4 are sequentially allocated to audio RTP, audio RTCP, video RTP and video RTCP, rear 4 group a5 ~ a8 are sequentially allocated as Intranet box out port to audio RTP, audio RTCP, video RTP and video RTCP, choose every group in 8 group a1 ~ a8 maximum port form eight Intranet port port1 ~ Port8, when the port of selection is occupied by other programs, then from selection one is substituted in remaining 3 port in the group;Step Rapid 20, start ICE, and detect our NAT type and collect our candidate site information;Step 30, communicating pair will be obtained respectively The NAT type and candidate site information got swap, and obtain the NAT type of other side, by the NAT type of other side with we's NAT type is merged into a NAT composite type, meanwhile, judge whether other side NAT type is Symmetric NAT or Cone NAT, if so, calculating other side predicts port, the Cone NAT includes Full cone NAT, Port Restricted Otherwise Cone NAT and Restricted Cone NAT are directly entered step 40;Other side is calculated in the step 30 predicts end The specific steps of mouth include: A1, set port9 ~ port12 to be outer in the anti-body candidate site information of the other side's server got Net port, port13 ~ port16 is the port that maps at Symmetric NAT of other side's box out port, judge other side whether be Symmetric NAT, if so, entering step A2;Otherwise A3 is entered step;A2, judge other side's outer net port port9 ~ Whether port12 is corresponding consistent with the port port1 ~ port4 of other side's Intranet distribution respectively, if so, obtaining other side predicts port For { p-16, p-20, p-24, p-28 }, wherein, and flag bit is set, into Enter step 40, otherwise, judge other side's outer net port port9 ~ port12 whether at a tolerance for the arithmetic progression of h, if so, It predicts that port is { port12+h, port12+2h, port12+3h, port12+4h } to other side, and flag bit is set, into step Rapid 40, otherwise, the random integer given between 4 1024 to 65535 predicts port as other side, enters step 40;A3, judgement Whether other side is Cone NAT, if so, obtaining other side predicts that port is port9 ~ port12, and flag bit is arranged, into step Rapid 40;Otherwise, other side port is not predicted, is directly entered step 40;Step 40 selects accordingly according to NAT composite type Candidate site information matched, generate detection list;Step 50 carries out continuity testing according to detection list, establishes logical Road.
2. a kind of audio/video communication method based on SIP and ICE according to claim 1, it is characterised in that: the step The specific steps that we's NAT type is obtained in 20 include: step 21, carry out test 1, if test 1 has response, are entered step 22, otherwise, it is judged to UDP network congestion, enters step 30;Step 22 judges the client in return message that client receives Outer net IP and port and the host ip of the client and port it is whether consistent, if so, entering step 23, otherwise enter step 24;Step 23 carries out test 2, if test 2 has response, after being judged to being located at symmetrical UDP firewall, enters step 30, no Then, it is judged on public network, enters step 30;Step 24 carries out test 2, if test 2 has response, is determined as Full cone NAT enters step 30, otherwise, enters step 25;Step 25 carries out test 3, and judging should in return message that client receives The outer net IP of the client obtained after 1 response of test in the outer net IP of client and port and step 22 and port whether one It causes, if so, entering step 26, otherwise, is judged to Symmetric NAT, enters step 30;Step 26 carries out test 4, if surveying Examination 4 has response, then is judged to Restricted Cone NAT, enters step 30, otherwise, be judged to Port Restricted Cone NAT enters step 30;What above-mentioned test 1, test 2, test 3 and test 4 were defined by the sequencing of NAT type detection: The test 1 are as follows: client sends to the first IP and first port of stun server and requests, it is desirable that stun server, which receives, asks After asking, responded with the first IP and first port;The test 2 are as follows: client is to the first IP of stun server and first Port sends request, it is desirable that after stun server receives request, is responded with the 2nd IP and second port;The test 3 are as follows: Client sends to the 2nd IP and second port of stun server and requests, it is desirable that after stun server receives request, with second IP and second port are responded;The test 4 are as follows: client is asked to the first IP and first port of stun server transmission It asks, it is desirable that after stun server receives request, responded with the first IP and second port.
3. a kind of audio/video communication method based on SIP and ICE according to claim 1, it is characterised in that: the step The concrete mode that communicating pair swaps the NAT type respectively got and candidate site information in 30 are as follows: client will Our NAT type and our candidate site Information encapsulation are into swapping in the message body SDP of SIP, the candidate site information Including host candidate site information, Server Relay candidate site information and the anti-body candidate site information of server.
4. a kind of audio/video communication method based on SIP and ICE according to claim 1, it is characterised in that: the step Port1 ~ port4 port whether consistent specific steps of the other side port9 ~ port12 respectively with the distribution of other side's Intranet are judged in A2 It is as follows: B1, port9 ~ port12 is sequentially stored into array rem_port [4], judge i from 0 to 3, rem_port [i] whether by It is decrescence small, if so, calculating rem_port [i] corresponding port resource number , and first port numbers is obtained by port resource res_num, and when calculating i from 0 to 3, Enter step B2;Otherwise, other side port9 ~ port12 is inconsistent with the port port1 ~ port4 of other side's Intranet distribution respectively;B2, It judges whether there is, if so, other side port9 ~ port12 divides with other side's Intranet respectively The port port1 ~ port4 matched is consistent, otherwise, port1 ~ port4 that other side port9 ~ port12 is distributed with other side's Intranet respectively Port is inconsistent.
5. a kind of audio/video communication method based on SIP and ICE according to claim 1, it is characterised in that: the step 40 specifically: step 41 judges whether the outer net address of communicating pair is identical, if they are the same, then enters step 42, otherwise, enters Step 43;Step 42 judges whether communicating pair is under same local area network, if so, only generating address to being our host Address enters step 50 to the detection list of peer address;Otherwise, address is only generated to for our host address to other side Outer net address and our Server Relay address enter step 50 to the detection list of other side's Server Relay address;Step 43, Judge whether NAT composite type is our Symmetric NAT and other side Symmetric NAT or is our Symmetric NAT and other side Cone NAT if having set flag bit, only generates address to being our if so, judge whether to be equipped with flag bit Our host address source port and is revised as the Intranet in step 10 and stayed by host address to the detection list of the outer net address of other side Hole port, and destination address ports number are revised as the other side in step 30 and predict port, enter step 50;If not being marked with will Position, then generate address to for net address outside our host address to other side, we's host address to other side's Server Relay address, Our Server Relay address is serviced to the outer net address of other side, our Server Relay address to peer address and we Device relay address enters step 50 to the detection list of other side's Server Relay address;Otherwise, 44 are entered step;Step 44 is sentenced Whether disconnected NAT composite type is our Cone NAT and other side Symmetric NAT, if so, judge whether to be equipped with flag bit, Flag bit has then been set, then has only generated address to the detection list for net address outside our host address to other side, and by target Location port numbers, which are revised as the other side in step 30, predicts port, enters step 50;If not setting flag bit, address is generated to for originally Square host address is to the outer net address of other side, our host address to other side's Server Relay address, we's Server Relay address Net address, our Server Relay address to peer address and our Server Relay address are serviced to other side outside to other side The detection list of device relay address, enters step 50;Otherwise, 45 are entered step;Step 45, judge NAT composite type whether be Our Cone NAT and other side Cone NAT, if so, judging whether to be equipped with flag bit, if so, only generating address to for originally Square host address enters step 50 to the detection list of the outer net address of other side;Otherwise, 46 are entered step;Step 46 generates address To in net address outside our host address to other side, our host address to other side's Server Relay address, our server After net address outside address to other side, our Server Relay address to peer address and we Server Relay address to pair The detection list of square Server Relay address, enters step 50.
6. a kind of audio/video communication method based on SIP and ICE according to claim 1, it is characterised in that: the method When further including that step 60, port assignment module detect that client and server disconnect, port resource is recovered to a money Buffer area is recycled in source, and recycles timing module by Single port, by the end in resource reclaim buffer area after one time period t of timing Mouth resource is recycled, and mapping of the time period t more than or equal to NAT is held time.
7. a kind of audio/video communication method based on SIP and ICE according to claim 1, it is characterised in that: carrying out When NAT type detection and candidate site information are collected, multi-level NAT, then the NAT type obtained are that restricted type is most stringent if it exists NAT type, the outer net address in candidate site information is the address outermost layer NAT, and the NAT type presses the stringency of restricted type From big to small successively are as follows: Symmetric NAT, Port Restricted Cone NAT, Restricted Cone NAT, Full Cone NAT。
CN201510352773.0A 2015-06-24 2015-06-24 A kind of audio/video communication method based on SIP and ICE Active CN105187567B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510352773.0A CN105187567B (en) 2015-06-24 2015-06-24 A kind of audio/video communication method based on SIP and ICE

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510352773.0A CN105187567B (en) 2015-06-24 2015-06-24 A kind of audio/video communication method based on SIP and ICE

Publications (2)

Publication Number Publication Date
CN105187567A CN105187567A (en) 2015-12-23
CN105187567B true CN105187567B (en) 2019-01-08

Family

ID=54909406

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510352773.0A Active CN105187567B (en) 2015-06-24 2015-06-24 A kind of audio/video communication method based on SIP and ICE

Country Status (1)

Country Link
CN (1) CN105187567B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105721570B (en) * 2016-02-04 2019-06-25 福建星网锐捷通讯股份有限公司 Data peer-to-peer transmission method and device
CN105847343B (en) * 2016-03-21 2019-01-25 福建星网锐捷通讯股份有限公司 Public network information detection method, apparatus and system for point-to-point transmission
CN105827748B (en) * 2016-05-12 2019-03-15 东莞市南星电子有限公司 A method of the SIP based on ICE passes through Symmetric NAT device
CN106411836B (en) * 2016-05-30 2017-09-19 深圳市鼎盛智能科技有限公司 Call connection method and client
CN108390784B (en) * 2018-02-13 2019-10-08 中国联合网络通信集团有限公司 A kind of method and device of resource reclaim
CN111385250B (en) * 2018-12-28 2022-07-19 浙江宇视科技有限公司 Safe access method and system for equipment port
CN110730203A (en) * 2019-09-04 2020-01-24 华为技术有限公司 P2P communication method and device
CN111935333B (en) * 2020-08-12 2022-09-27 杭州萤石软件有限公司 NAT type determination method, device, system and storage medium
CN115225646A (en) * 2021-04-21 2022-10-21 武汉斗鱼鱼乐网络科技有限公司 P2P node recommendation method, terminal, medium and computer equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101179581A (en) * 2007-12-13 2008-05-14 北京邮电大学 Method for performing media transmission using ICE relay candidate address
CN101431511A (en) * 2007-11-09 2009-05-13 友讯科技股份有限公司 Method for penetrating fire wall and establishing on-line channel between network terminal apparatus
CN102685268A (en) * 2012-05-22 2012-09-19 北京邮电大学 Fast private network traversal method based on ICE (Information and Content Exchange) protocol in VoIP (Voice over Internet Protocol)
CN102685141A (en) * 2012-05-22 2012-09-19 北京邮电大学 Fusion traversing method based on voice accessibility in VoIP (Voice over Internet Protocol)
CN103916382A (en) * 2013-12-25 2014-07-09 三亚中兴软件有限责任公司 NAT through method based on SIP media capacity re-negotiation, proxy server and system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9083587B2 (en) * 2009-08-21 2015-07-14 Cisco Technology, Inc. Port chunk allocation in network address translation
US9826044B2 (en) * 2013-10-23 2017-11-21 Qualcomm Incorporated Peer-to-peer communication for symmetric NAT

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101431511A (en) * 2007-11-09 2009-05-13 友讯科技股份有限公司 Method for penetrating fire wall and establishing on-line channel between network terminal apparatus
CN101179581A (en) * 2007-12-13 2008-05-14 北京邮电大学 Method for performing media transmission using ICE relay candidate address
CN102685268A (en) * 2012-05-22 2012-09-19 北京邮电大学 Fast private network traversal method based on ICE (Information and Content Exchange) protocol in VoIP (Voice over Internet Protocol)
CN102685141A (en) * 2012-05-22 2012-09-19 北京邮电大学 Fusion traversing method based on voice accessibility in VoIP (Voice over Internet Protocol)
CN103916382A (en) * 2013-12-25 2014-07-09 三亚中兴软件有限责任公司 NAT through method based on SIP media capacity re-negotiation, proxy server and system

Also Published As

Publication number Publication date
CN105187567A (en) 2015-12-23

Similar Documents

Publication Publication Date Title
CN105187567B (en) A kind of audio/video communication method based on SIP and ICE
US8560607B2 (en) Method based on the combination of the UPnP and STUN for NAT traversal
CN105827748B (en) A method of the SIP based on ICE passes through Symmetric NAT device
CN104104742B (en) It is manipulated using the user-plane traffic that network address translation and request redirect
CN110301126A (en) Conference server
US10419544B2 (en) Methods and apparatus for managing the use of IP addresses
CN102685268B (en) Fast private network traversal method based on ICE (Information and Content Exchange) protocol in VoIP (Voice over Internet Protocol)
CN100521663C (en) Method for crossing network address conversion in point-to-point communication
JP2014511089A (en) Private address and public address mapping
CN101822026B (en) Method and device for establishing connection between packet-oriented communication terminals through network address translation unit
RU2011128874A (en) ARCHITECTURE OF THE POLICY SERVICE SYSTEM FOR SESSIONS CREATED USING STUN
CN101895590A (en) UDT-based system and method for realizing network address translator traversal
CN111435922B (en) Bandwidth sharing method
CN101047548A (en) Communication in multiple NAT private network
CN108293076A (en) Media session between network endpoint
US8601140B2 (en) Method for acquiring traversal resource, peer to peer node and peer to peer system
US10178015B2 (en) Methods, systems, and computer readable media for testing network equipment devices using connectionless protocols
KR101506307B1 (en) Method and system for controlling quality of service to private network terminal in IMS network environment
CN111800341B (en) Cross-router terminal communication method and device
US9042376B2 (en) Traversal method for ICMP-sensitive NAT
CN101674297B (en) Distributed business network, core service device and protocol message processing method
Tseng et al. Can: A context-aware NAT traversal scheme
US20100208734A1 (en) Communications relay device, program and method, and network system
CN114598532B (en) Connection establishment method, device, electronic equipment and storage medium
Lai et al. A novel NAT-based approach for resource load balancing in fog computing architecture

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20230824

Address after: Room 501, Building 15, No. 7, Keji Avenue, Houjie, Dongguan, Guangdong 523000

Patentee after: Guangdong Enweishi Technology Co.,Ltd.

Address before: Dongguan Nanxing Electronics Co., Ltd., Building B, No. 3 Chengtian Road, Mintian Village, Shatian Town, Dongguan City, Guangdong Province, 523000

Patentee before: DONGGUAN SOUTHSTAR ELECTRONICS Ltd.

TR01 Transfer of patent right