WO2016169015A1 - Method and apparatus for switching network communication and direct communication - Google Patents
Method and apparatus for switching network communication and direct communication Download PDFInfo
- Publication number
- WO2016169015A1 WO2016169015A1 PCT/CN2015/077263 CN2015077263W WO2016169015A1 WO 2016169015 A1 WO2016169015 A1 WO 2016169015A1 CN 2015077263 W CN2015077263 W CN 2015077263W WO 2016169015 A1 WO2016169015 A1 WO 2016169015A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- address
- port number
- public network
- network
- communication path
- 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.)
- Ceased
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W36/00—Hand-off or reselection arrangements
- H04W36/0005—Control or signalling for completing the hand-off
- H04W36/0055—Transmission or use of information for re-establishing the radio link
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W76/00—Connection management
Definitions
- the embodiments of the present invention relate to communication technologies, and in particular, to a method and an apparatus for switching between network communication and direct communication.
- LTE Long Term Evolution
- UEs user equipments
- eNB evolved base station
- P-GW Packet Data Network Gateway
- D2D Device to Device
- the embodiment of the invention provides a method and a device for switching between network communication and direct communication, which can ensure that the user's service is not interrupted when the user's session is switched between network communication and direct communication.
- a first aspect of the present invention provides a method for switching between network communication and direct communication, including:
- the first UE sends the handover indication information to the second UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path;
- the first UE acquires a first public network IP address and a first public network port number, where the first public network IP address is used by the first UE to communicate with the second UE in the network communication path.
- Public network IP address, the first public network port number is the network communication path of the first UE a public network port number used for communicating with the second UE;
- the first UE establishes the direct communication path by using the first public network IP address and the first public network port number;
- the first UE communicates with the second UE on the direct communication path.
- the sending, by the first UE, the handover indication information to the second UE includes:
- the first request message is used to request to acquire the first public network IP address and the first public network port number, the first request The message includes the handover indication information;
- the first public network IP address and the first public network port number including:
- the first UE receives the first response message returned by the second UE, where the first response message includes: the first public network IP address and the first public network port number.
- the first request message further includes application identifier information, where the application identifier information is used to indicate the first The two UEs switch the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- the first UE uses the first public network IP address and the first Before the public network port number establishes the direct communication path, the method further includes:
- the second request message is used to request the first UE to acquire a second public network IP address and a second public network port, where the The second public network IP address is the public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the second UE in the a public network port number used by the network communication path to communicate with the first UE;
- the first UE sends a second response message to the second UE, where the second response message includes: the second public network IP address and port number and the second public network port number.
- the acquiring, by the first UE, the first public network IP address and the first public network port number includes:
- the first UE sends a first direct communication request message to the second UE, where the first direct communication request message further includes: a second public network IP address and a second public network port number,
- the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the second UE a public network port number used by the network communication path to communicate with the first UE;
- the first UE receives the first direct communication response message returned by the second UE, where the first direct communication response message includes: the first public network IP address and the first public network port number.
- the handover indication information is carried in the first direct communication request message.
- the sending, by the first UE, the handover indication information to the second UE includes:
- the first UE sends a second direct communication request message to the second UE, where the second direct communication request message includes the handover indication information;
- the first public network IP address and the first public network port number including:
- the first UE sends a third request message to the application server, where the third request message is used to request to acquire the first public network IP address and the first public network port number;
- the first UE receives the third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number.
- the first direct communication request message or the second direct communication The request message further includes application identification information, where the application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- the first UE that communicates with the second UE on the direct communication path includes:
- the first UE uses the first public network IP address as a source IP address of a data packet sent to the second UE, and uses the first public network port number as a source port number of the data packet, and The second public network IP address is used as the destination IP address of the data packet, and the second public network port number is used as the destination port number of the data packet, and the data packet is sent to the second through the direct communication path.
- a UE where the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path.
- a second aspect of the present invention provides a method for switching between network communication and direct communication, including:
- the second UE receives the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path;
- the second UE acquires a second public network IP address and a second public network port number, where the second public network IP address is used by the second UE to communicate with the first UE in the network communication path.
- a public network IP address where the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path;
- the second UE establishes the direct communication path by using the second public network IP address and the second public network port number;
- the second UE communicates with the first UE on the direct communication path.
- the acquiring, by the second UE, the second public network IP address and the second public network port number includes:
- the second UE sends a second request message to the first UE, where the second request message is used to request the first UE to acquire the second public network IP address and the second public network port number. ;
- the second UE receives the second response message that is returned by the first UE, where the second response message includes: the second public network IP address and the second public network port number.
- the method before the second UE acquires the second public network IP address and the second public network port number, the method also includes:
- the first request message sent by the first UE, where the first request message includes the handover indication information, where the first request message is used to request to acquire a first public network IP address and a first a public network port number, where the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, and the first public network port number a public network port number used by the first UE to communicate with the second UE in the network communication path;
- the second UE sends the first public network IP address and the first public network port number in the first response message to the first UE.
- the first request message further includes application identifier information, where the application identifier information is used to indicate the The second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- the acquiring, by the second UE, the second public network IP address and the second public network port number includes:
- the second UE receives the first direct communication request message sent by the first UE, where the first direct communication request message includes the second public network IP address and the second public network port number.
- the handover indication information is carried in the first direct communication request message.
- the second UE receives the first direct communication request message sent by the first UE Thereafter, the method further includes:
- the first direct communication response message to the first UE, where the first direct communication response message includes: a first public network IP address and a first public network port number, the first public network
- the IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path
- the first public network port number is the first UE in the network communication path.
- the receiving, by the second UE, the handover indication information that is sent by the first UE includes:
- the second UE receives the second direct communication request message sent by the first UE, where the second direct communication request message includes the handover indication information;
- the second public network IP address and the second public network port number including:
- the second UE sends a fourth request message to the application server, where the fourth request message is used to request to acquire the second public network IP address and the second public network port number;
- the second UE receives the fourth response message returned by the application server, where the fourth response message includes: the second public network IP address and the second public network port number.
- the first direct communication request message or the second direct The communication request message further includes application identification information, where the application identification information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path. .
- the second UE that communicates with the first UE on the direct communication path includes:
- the second UE uses the second public network IP address as the source IP address of the data packet sent to the first UE, and the second public network port number as the source port number of the data packet,
- the first public network IP address is used as the destination IP address of the data packet
- the first public network port number is used as the destination port number of the data packet
- the data packet is sent to the first through the direct communication path.
- a third aspect of the present invention provides a method for switching between network communication and direct communication, including:
- the first UE sends the handover indication information to the second UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path;
- the first UE acquires a first public network IP address and a first public network port number, where the first public network IP address is used by the first UE to communicate with the second UE in the network communication path.
- a public network IP address where the first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path;
- the first UE acquires a second private network IP address and a second private network port number, where the second private network IP address is used by the second UE to communicate with the first UE in the network communication path.
- a private network IP address where the second private network port number is a private network port number used by the second UE to communicate with the first UE in the network communication path;
- the first UE establishes the direct communication path by using the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number;
- the first UE communicates with the second UE on the direct communication path.
- the first UE uses the first public network IP address, the first public network port number, and the second private network IP Establishing the direct communication path by the address and the second private network port number, including:
- the first UE establishes a first correspondence between the first public network IP address, the first public network port number, the first private network IP address, and the first private network port number, and the second public network IP address. And a second corresponding relationship between the second public network port number and the second private network IP address and the second private network port number, where the first private network IP address is the first UE in the a private network IP address used in communication with the second UE in the network communication path, where the first private network port number is used by the first UE to communicate with the second UE in the network communication path a private network port number, where the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path.
- the first UE that communicates with the second UE on the direct communication path includes:
- the first UE replaces the source IP address of the data packet sent to the second UE with the first public network IP address according to the first correspondence, and replaces the source port number of the data packet with the The first public network port number, the destination IP address of the data packet is replaced with the second private network IP address according to the second correspondence, and the destination port number of the data packet is replaced by the second a private network port number, where the source port number of the data packet is the first private network port number, the source port number of the data packet is the first private network port number, and the destination IP address of the data packet The address is the second public network IP address, the destination port number of the data packet is the second public network port number, and the first UE sends the data packet to the first Two UE;
- the first UE receives the data packet sent by the second UE by using the direct communication path.
- the first The UE sends the handover indication information to the second UE, including:
- the first UE sends a third direct communication request message to the second UE, where the third direct communication request message includes: the handover indication information;
- the first public network IP address and the first public network port number including:
- the third direct communication response message that is returned by the second UE, where the third direct communication response message includes: the first public network IP address and the first public network port number;
- the first UE acquires the second private network IP address and the second private network port number, including:
- the third direct communication response message further includes: the second private network IP address and the second private network port number, where the first UE acquires the second from the third direct communication response message The private network IP address and the second private network port number.
- the sending, by the first UE, the handover indication information to the second UE includes:
- the first UE sends a fourth direct communication request message to the second UE, where the fourth direct communication request message includes: the handover indication information;
- the first public network IP address and the first public network port number including:
- the first UE sends a third request message to the application server, where the third request message is used to request to acquire the first public network IP address and the first public network port number;
- the first UE receives the third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number;
- the first UE acquires the second private network IP address and the second private network port number, including:
- the first UE receives the fourth direct communication response message returned by the second UE, where the fourth direct communication response message includes: the second private network IP address and the second private network port number.
- the third direct communication request message further includes: a first private network IP address and a first private network a port number, a second public network IP address, and a second public network port number, where the first private network IP address is a private network used by the first UE to communicate with the second UE in the network communication path.
- An IP address where the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path, and the second public network IP address is the First a public network IP address used by the two UEs to communicate with the first UE in the network communication path, and the second public network port number is the first UE in the network communication path of the second UE The public network port number used for communication.
- the fourth direct communication request message further includes: a first private network IP address and a first private network a port number, where the first private network IP address is a private network IP address used by the first UE to communicate with the second UE in the network communication path, where the first private network port number is A private network port number used by the first UE to communicate with the second UE in the network communication path.
- the third direct communication request message or the fourth direct communication request message is further The application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- a fourth aspect of the present invention provides a method for switching between network communication and direct communication, including:
- the second UE receives the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path;
- the second UE acquires a second public network IP address and a second public network port number, where the second public network IP address is used by the second UE to communicate with the first UE in the network communication path.
- a public network IP address where the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path;
- the second UE acquires a first private network IP address and a first private network port number, where the first private network IP address is used by the first UE to communicate with the second UE in the network communication path.
- a private network IP address where the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path;
- the second UE establishes the direct communication path by using the second public network IP address, the second public network port number, the first private network IP address, and the first private network port;
- the second UE communicates with the first UE on the direct communication path.
- the second UE uses the second public network IP address, the second public network port number, and the first private network IP Establishing the direct communication path with the address and the first private network port, including:
- the second UE establishes a first correspondence between the second public network IP address, the second public network port number, the second private network IP address, and the second private network port number, and the first public network IP address. a second corresponding relationship between the first public network port number and the first private network IP address and the first private network port number, where the second private network IP address is the second UE in the a private network IP address used in communication with the first UE in a network communication path, where the second private network port number is used by the second UE to communicate with the first UE in the network communication path a private network port number, where the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, where the first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path.
- the second UE that communicates with the first UE on the direct communication path includes:
- the second UE replaces the source IP address of the data packet sent to the first UE with the second public network IP address according to the first correspondence, and replaces the source port number of the data packet with the a second public network port number, the destination IP address of the data packet is replaced with the first private network IP address according to the second correspondence, and the destination port number of the data packet is replaced by the first a private network port number, where the source port number of the data packet is the second private network port number, the source port number of the data packet is the second private network port number, and the destination IP address of the data packet The address is the first public network IP address, the destination port number of the data packet is the first public network port number, and the second UE sends the replaced data packet to the First UE;
- the second UE receives the data packet sent by the first UE by using the direct communication path.
- the receiving, by the second UE, the handover indication information that is sent by the first UE includes:
- the second UE receives the third direct communication request message sent by the first UE, where the third direct communication request message includes: the handover indication information;
- the second public network IP address and the second public network port number including:
- the second direct communication request message further includes the second public network IP address and the second public network port number, and the second UE acquires the second public from the third direct communication request message a network IP address and the second public network port number;
- the second UE obtains, by the second UE, the first private network IP address and the first private network port number, including:
- the third direct communication request message further includes the first private network IP address and the first private network port number, and the second UE acquires the first private information from the third direct communication request message.
- the network IP address and the first private network port number are included in the third direct communication request message.
- the receiving, by the second UE, the handover indication information that is sent by the first UE includes:
- the second UE receives the fourth direct communication request message sent by the first UE, where the fourth direct communication request message includes: the handover indication information;
- the second public network IP address and the second public network port number including:
- the second UE sends a fourth request message to the application server, where the fourth request message is used to request to acquire the second public network IP address and the second public network port number;
- the second UE receives the fourth response message returned by the application server, where the fourth response message includes the second public network IP address and the second public network port number;
- the second UE obtains, by the second UE, the first private network IP address and the first private network port number, including:
- the fourth direct communication request message further includes the first private network IP address and the first private network port number, and the second UE acquires the first private information from the fourth direct communication request message.
- the network IP address and the first private network port number are included in the fourth direct communication request message.
- the method further includes:
- a third direct communication response message to the first UE includes a first public network IP address, a first public network port number, a second private network IP address, and a second private network port number
- the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path
- the first public network port a number of the public network port used by the first UE to communicate with the second UE in the network communication path
- the second private network IP address is the second UE in the network communication path a private network IP address used for communication with the first UE
- the second private network port number is a private network port used by the second UE to communicate with the first UE in the network communication path number.
- the second UE receives the fourth direct communication request message sent by the first UE Thereafter, the method further includes:
- the second UE returns a fourth direct communication response message to the first UE, where the fourth direct communication response message includes a second private network IP address and a second private network port number, and the second private network IP address
- the address is a private network IP address used by the second UE to communicate with the first UE in the network communication path
- the second private network port number is the second UE in the network communication path.
- the third direct communication request message or the fourth direct communication request message is further The application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- a fifth aspect of the present invention provides a first UE, including:
- a sending module configured to send, to the second UE, the handover indication information, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from a network communication path to a direct communication path;
- An acquiring module configured to obtain a first public network IP address and a first public network port number, where the first public network IP address is used by the first UE to communicate with the second UE in the network communication path.
- a public network IP address where the first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path;
- a path establishing module configured to establish the direct communication path by using the first public network IP address and the first public network port number
- a communication module configured to communicate with the second UE on the direct communication path.
- the sending module is specifically configured to:
- the obtaining module is specifically configured to:
- the second UE And receiving, by the second UE, the first response message, where the first response message includes: the first public network IP address and the first public network port number.
- the first request message further includes application identifier information, where the application identifier information is used to indicate the first The two UEs switch the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- the first UE further includes:
- a receiving module configured to receive a second request message sent by the second UE, where the second request message is used to request, by the first UE, to acquire a second public network IP address and a second public network port, where The second public network IP address is the public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the second UE in the a public network port number used by the network communication path to communicate with the first UE;
- the sending module is further configured to send a second response message to the second UE, where the second response message includes: the second public network IP address and port number and the second public network port number.
- the acquiring module is specifically configured to:
- the first direct communication request message further includes: a second public network IP address and a second public network port number, where the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, where the second public network port number is the second UE in the network communication path and the a public network port number used by the first UE communication;
- the second UE And receiving, by the second UE, the first direct communication response message, where the first direct communication response message includes: the first public network IP address and the first public network port number.
- the handover indication information is carried in the first direct communication request message.
- the sending module is specifically configured to:
- the obtaining module is specifically configured to:
- the first direct communication request message or the second direct communication The request message further includes application identification information, where the application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- the communications module is specifically configured to:
- the address is used as the destination IP address of the data packet
- the second public network port number is used as the destination port number of the data packet
- the data packet is sent to the second UE by using the direct communication path
- the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path
- the second public network port number is the second UE a public network port number used by the network communication path to communicate with the first UE.
- a sixth aspect of the present invention provides a second UE, including:
- a receiving module configured to receive, by the first UE, handover indication information, where the handover indication information is used to indicate that the second UE switches a communication path with the first UE from a network communication path to a direct communication path;
- An obtaining module configured to obtain a second public network IP address and a second public network port number, where the second public network IP address is used by the second UE to communicate with the first UE in the network communication path a public network IP address, where the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path;
- a path establishing module configured to use the second public network IP address and the second public network port Number establishing the direct communication path
- a communication module configured to communicate with the first UE on the direct communication path.
- the acquiring module is specifically configured to:
- the receiving module is further configured to:
- the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path
- the first public network port number is the first a public network port number used by the UE to communicate with the second UE in the network communication path
- the second UE further includes: a sending module, configured to send the first public network IP address and the first public network port number to the first UE in a first response message.
- the first request message further includes application identifier information, where the application identifier information is used to indicate the The second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- the acquiring module is specifically configured to:
- the first UE Receiving, by the first UE, a first direct communication request message, where the first direct communication request message includes the second public network IP address and the second public network port number.
- the handover indication information is carried in the first direct communication request message.
- the sixth aspect of the sixth aspect in a possible implementation manner, further includes:
- a sending module configured to return a first direct communication response message to the first UE, where the first direct communication response message includes: a first public network IP address and a first public network port number, the first public network
- the IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path
- the first public network port number is the first UE in the network communication path.
- the receiving module is specifically configured to:
- the obtaining module is specifically configured to:
- the first direct communication request message or the second direct The communication request message further includes application identification information, where the application identification information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path. .
- the second UE is in communication with the first UE on the direct communication path, and the communications module is specifically configured to:
- the second public network IP address is used as a source IP address of the data packet sent to the first UE, and the second public network port number is used as a source port number of the data packet, and the first public network IP is used.
- the address is used as the destination IP address of the data packet, and the first public network port number is used as the destination port number of the data packet, and the data packet is sent to the first UE by using the direct communication path, where
- the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, where the first public network port number is the first UE A public network port number used by the network communication path to communicate with the second UE.
- a seventh aspect of the present invention provides a first UE, including:
- a sending module configured to send, to the second UE, the handover indication information, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from a network communication path to a direct communication path;
- An acquiring module configured to obtain a first public network IP address and a first public network port number, where the first public network IP address is used by the first UE to communicate with the second UE in the network communication path.
- a public network IP address where the first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path;
- the acquiring module is further configured to obtain a second private network IP address and a second private network port number, where the second private network IP address is the second UE in the network communication path and the first UE a private network IP address used by the communication, where the second private network port number is a private network port number used by the second UE to communicate with the first UE in the network communication path;
- a path establishing module configured to establish the direct communication path by using the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number;
- a communication module configured to communicate with the second UE on the direct communication path.
- the path establishing module is specifically configured to:
- first private network IP address is the first UE in the network communication path a private network IP address used by the second UE to communicate
- first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path
- the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path
- the second public network port number is the second UE A public network port number used to communicate with the first UE in the network communication path.
- the communications module is specifically configured to:
- the second private network IP address, the destination port number of the data packet is replaced with the second private network port number, where the source port number of the data packet is the first private network port number,
- the source port number of the data packet is the first private network port number
- the destination IP address of the data packet is the second public network IP address
- the destination port number of the data packet is the second public network port No.
- the sending module is specifically configured to:
- the first UE sends a third direct communication request message to the second UE, where the third direct communication request message includes: the handover indication information;
- the obtaining module is specifically configured to:
- the second UE And receiving, by the second UE, a third direct communication response message, where the third direct communication response message includes: the first public network IP address and the first public network port number;
- the third direct communication response message further includes: the second private network IP address and the second private network port number, obtaining the second private network IP address from the third direct communication response message, and The second private network port number.
- the sending module is specifically configured to:
- the acquiring module acquires the first public network IP address and the first public network port number, including:
- the acquiring module acquires the second private network IP address and the second private network port number, including:
- the third direct communication request message further includes: a first private network IP address and a first private network a port number, a second public network IP address, and a second public network port number, where the first private network IP address is a private network used by the first UE to communicate with the second UE in the network communication path.
- An IP address where the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path, and the second public network IP address is the a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the first UE in the network communication path.
- the fourth direct communication request message further includes: a first private network IP address and a first private network a port number, where the first private network IP address is a private network IP address used by the first UE to communicate with the second UE in the network communication path, where the first private network port number is A private network port number used by the first UE to communicate with the second UE in the network communication path.
- the third direct communication request message or the fourth direct communication request message is further The application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- An eighth aspect of the present invention provides a second UE, including:
- a receiving module configured to receive, by the first UE, handover indication information, where the handover indication information is used to indicate that the second UE switches a communication path with the first UE from a network communication path to a direct communication path;
- An obtaining module configured to obtain a second public network IP address and a second public network port number, where the second public network IP address is used by the second UE to communicate with the first UE in the network communication path a public network IP address, where the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path;
- the acquiring module is further configured to obtain a first private network IP address and a first private network port number, where the first private network IP address is the first UE in the network communication path and the second UE a private network IP address used by the communication, where the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path;
- a path establishing module configured to establish the direct communication path by using the second public network IP address, the second public network port number, the first private network IP address, and the first private network port;
- a communication module configured to communicate with the first UE on the direct communication path.
- the path establishing module is specifically configured to:
- the private network IP address used by the first UE to communicate, and the second private network port number is a private network port number used by the second UE to communicate with the first UE in the network communication path
- the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path
- the first public network port number is the first UE A public network port number used to communicate with the second UE in the network communication path.
- the communications module is specifically configured to:
- the source port number of the data packet is the second private network port number
- the source port number of the data packet is the second private network port number
- the destination IP address of the data packet is the first a public network IP address
- the destination port number of the data packet is the first public network port number
- the second UE sends the replaced data packet to the first UE by using the direct communication path;
- the receiving module is specifically configured to:
- the third direct communication The request message includes: the switching indication information
- the obtaining module is specifically configured to:
- the third direct communication request message further includes the second public network IP address and the second public network port number, and the second public network IP address and the location are obtained from the third direct communication request message. Said second public network port number;
- the third direct communication request message further includes the first private network IP address and the first private network port number, and the first private network IP address and the location are obtained from the third direct communication request message.
- the first private network port number is the first private network port number.
- the receiving module is specifically configured to:
- the obtaining module acquires the second public network IP address and the second public network port number, including:
- the acquiring module acquires the first private network IP address and the first private network port number, including:
- the fourth direct communication request message further includes the first private network IP address and the first private network port number, and the obtaining module acquires the first private network from the fourth direct communication request message.
- the IP address and the first private network port number are included in the fourth direct communication request message.
- the second UE further includes:
- a sending module configured to return a third direct communication response message to the first UE, where the third direct communication response message includes a first public network IP address, a first public network port number, and a second private network IP address, and a second private network port number, where the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, and the first public network port Number that the first UE communicates with the second UE in the network communication path a public network port number used, the second private network IP address being a private network IP address used by the second UE to communicate with the first UE in the network communication path, and the second private network port The number is a private network port number used by the second UE to communicate with the first UE in the network communication path.
- the second UE further includes:
- a sending module configured to return a fourth direct communication response message to the first UE, where the fourth direct communication response message includes a second private network IP address and a second private network port number, and the second private network IP address
- the address is a private network IP address used by the second UE to communicate with the first UE in the network communication path
- the second private network port number is the second UE in the network communication path.
- the third direct communication request message or the fourth direct communication request message is further The application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- a ninth aspect of the present invention provides a first UE, where the first UE includes: a processor, a memory, a communication interface, and a system bus, where the memory and the communication interface are connected to the processor through the system bus Communication
- the memory is configured to store a computer execution instruction
- the processor configured to execute the computer to execute instructions, to perform the method of any one of the first to eighth aspects of the first aspect of the invention.
- a tenth aspect of the present invention provides a second UE, where the second UE includes: a processor, a memory, a communication interface, and a system bus, where the memory and the communication interface are connected to the processor through the system bus Communication
- the memory is configured to store a computer execution instruction
- the processor configured to execute the computer-executed instructions, to perform the method of any one of the first to ninth aspects of the second aspect of the present invention.
- An eleventh aspect of the present invention provides a first UE, where the first UE includes: a processor, a memory, a communication interface, and a system bus, and the memory and the communication interface pass the system a bus is connected to and communicates with the processor;
- the memory is configured to store a computer execution instruction
- the processor configured to execute the computer-executed instructions, to perform the method of any one of the first to seventh aspects of the third aspect and the third aspect of the present invention.
- a twelfth aspect of the present invention provides a second UE, where the second UE includes: a processor, a memory, a communication interface, and a system bus, where the memory and the communication interface are connected to the processor through the system bus And communicate;
- the memory is configured to store a computer execution instruction
- the processor configured to execute the computer-executed instructions, to perform the method of any one of the first to seventh aspects of the fourth aspect of the present invention and the second aspect.
- the first UE sends the handover indication information to the second UE to indicate that the second UE communicates with the communication path of the first UE from the network.
- the path is switched to the direct communication path, and the first public network IP address and the first public network port number are obtained, and the first public network IP address and the first public network port number are used to establish a direct communication path.
- the data packet sent by the first UE received by the second UE does not change, and the IP address and the port number of the first UE do not change in the second UE, thereby ensuring the user's Business is not interrupted.
- FIG. 1 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 1 of the present invention
- FIG. 2 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 2 of the present invention
- Embodiment 3 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 3 of the present invention
- Embodiment 4 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 4 of the present invention
- FIG. 5 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 5 of the present invention
- FIG. 6 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 6 of the present invention
- FIG. 7 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 7 of the present invention.
- Embodiment 8 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 8 of the present invention.
- Embodiment 9 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 9 of the present invention.
- FIG. 10 is a schematic structural diagram of a first UE according to Embodiment 10 of the present invention.
- FIG. 11 is a schematic structural diagram of a second UE according to Embodiment 11 of the present invention.
- FIG. 12 is a schematic structural diagram of a first UE according to Embodiment 12 of the present invention.
- FIG. 13 is a schematic structural diagram of a second UE according to Embodiment 13 of the present invention.
- FIG. 14 is a schematic structural diagram of a first UE according to Embodiment 14 of the present invention.
- FIG. 15 is a schematic structural diagram of a second UE according to Embodiment 15 of the present invention.
- FIG. 16 is a schematic structural diagram of a first UE according to Embodiment 16 of the present invention.
- FIG. 17 is a schematic structural diagram of a second UE according to Embodiment 17 of the present invention.
- the UE transmits data through the network communication path, taking the communication between the first UE and the second UE as an example.
- the source IP address of the data packet sent by the first UE is its own private IP address
- the source port number is its own private port number.
- the destination IP address is the public network IP address of UE2 and the destination port number is the public network port number of UE2.
- the IP address of the private network cannot be routed over the Internet. Therefore, the network address translation (NAT) of the UE is required to be translated into the public IP address of the UE1.
- the private network port number of UE1 is converted to the public network port number.
- the router that performs NAT is also called a NAT server.
- the NAT server can be a single router or integrated on the P-GW.
- the data packet converted by the NAT server is sent to the Internet for transmission.
- the receiving terminal's NAT server converts the destination IP address of the data packet into the private network IP address of UE2, and the data packet is The destination port number is converted to the private network port number of the UE2, and then the converted data packet is sent to the UE2.
- the source IP address of the data packet received by the UE2 is the public network IP address of the UE1, and the source port number is the public address of the UE1.
- the network port number, the destination IP address is the private network IP address of UE2, and the destination port number is the private network port number of UE2.
- the direct communication path is a path directly connected between UE1 and UE2.
- UE1 and UE2 communicate using a direct communication path, the data packet does not need to pass through any network entity, thereby reducing the number of packets.
- the delay of packet transmission improves the transmission efficiency.
- UE1 and UE2 when UE1 and UE2 want to switch the transmission path from the network communication path to the direct communication path, UE1 and UE2 need to interrupt the network direct communication path first, and then establish a direct communication path, and UE1 and UE2 are in direct communication.
- the IP address used on the path is different from the IP address used on the network communication path. As the IP address is changed, the service is not continuous.
- FIG. 1 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 1 of the present invention. As shown in FIG. 1 , the method in this embodiment may include the following steps:
- Step 101 The first UE sends handover indication information to the second UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path.
- the network communication path is a network communication path between the first UE and the second UE, and the first UE is to be switched from the network communication path to the direct communication path, and the premise of the embodiment is the first UE and the second UE.
- a network communication path has been established, where the network communication path can be LTE
- the network communication path, the first UE and the second UE establish a network communication path as the prior art is not described too much here.
- a direct communication path may be established between the first UE and the second UE, and when the first UE and the second UE communicate through the direct communication path, the data packet does not need to pass through the LTE.
- the delivery of the core network can save network resources and can reduce the communication delay between the first UE and the second UE.
- Step 102 The first UE acquires a first public network (Internet Protocol, IP address) address and a first public network port number.
- IP address Internet Protocol
- the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path
- the first public network port number is the first UE in the network communication.
- a public network port number used by the second UE to communicate with the second UE in the path where the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path
- the second public network port number is The public network port number used by the second UE to communicate with the first UE in the network communication path.
- the first UE and the second UE each know their own private network IP address and private network port number, as well as the public network IP address and public network port number of the other party.
- the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path
- the second public network port number is the second UE in the network communication.
- a public network port number used by the first UE to communicate with the first UE in the path where the first private network IP address is a private network IP address used by the first UE to communicate with the second UE in the network communication path
- the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path
- the second private network IP address is a private network IP address used by the second UE to communicate with the first UE in the network communication path
- the second private network port number is a private network port number used by the second UE to communicate with the first UE in the network communication path.
- the first UE establishes a direct communication path, and needs to obtain the first public network IP address and the first public network port number.
- the first UE may obtain the first public network IP address and the first manner by using the following three manners.
- Public network port number :
- the first UE sends a first request message to the second UE, where the first request message is used to request to acquire the first public network IP address and the first public network port number, and the second UE sends the first request message to the first UE according to the first request message. Returns the first response message.
- the first UE receives the first response message returned by the second UE, where the first response message includes: a first public network IP address and a first public network port number.
- the first request message may further carry the handover indication information.
- the first handover indication information may also be carried in other messages, which is not limited in this embodiment.
- the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE switches the communication path of the application corresponding to the application identifier from the network communication path to the direct communication path.
- the application identifier information may be an application identifier (APP ID).
- APP ID application identifier
- the first UE may establish a direct communication path for each application. In order to distinguish the direct communication path of each application, each application needs to be carried in the first request message.
- Application identification information to indicate to the second UE which application the direct communication path belongs to. When there is only one application between the first UE and the second UE, optionally, the application identifier information of the application may not be carried in the first request message.
- the first UE sends a first direct communication request message to the second UE, where the first direct communication request message further includes: a second public network IP address and a second public network port number.
- the second UE returns a first direct communication response message to the first UE according to the first direct communication request message, and the first UE receives the first direct communication response message returned by the second UE, where the first direct communication response message includes: Public network IP address and first public network port number.
- the first UE may send the handover indication information in the first direct communication request message to the first UE.
- the second UE of course, the handover indication information can also be carried in other messages.
- the first UE sends a third request message to the application server, where the third request message is used to request to acquire the first public network IP address and the first public network port number.
- the application server is a server that serves communication between the first UE and the second UE.
- the application server stores the first public network IP address, the first public network port number, the second public network IP address, and the second public network port number.
- the application server After receiving the third request message sent by the first UE, the application server returns a third response message to the first UE according to the third request message, where the first UE receives the third response message returned by the application server, where the third response message includes: The first public network IP address and the first public network port number.
- the first UE When the first UE acquires the first public network IP address and the first public network port number through the application server, optionally, the first UE sends the handover indication information to the second UE by using the second direct communication request message, where the second direct communication is performed.
- the request message includes handover indication information, of course, the first UE also
- the switching indication information can be carried by other messages.
- the first direct communication request message or the second direct communication request message may further include application identification information.
- step 101 and step 102 are executed in the same order, or may be performed simultaneously.
- Step 103 The first UE establishes a direct communication path by using the first public network IP address and the first public network port number.
- the first UE establishes an underlying connection by using the first public network IP address and the first public network port number.
- the first UE may also generate a traffic flow template (TFT) corresponding to the direct communication path, where the matching information of the TFT corresponding to the direct communication path is: the source IP address is the first public network IP address, and the source port number is It is the first public network port number, the destination IP address is the second public network IP address, and the destination port number is the second public network port number.
- TFT traffic flow template
- the first UE Before the first UE establishes a direct communication path by using the first public network IP address and the first public network port number, the first UE further receives a second request message sent by the second UE, where the second request message is used to request acquisition from the first UE. a second public network IP address and a second public network port; the first UE sends a second response message to the second UE, where the second response message includes: a second public network IP address and a port number, and a second public network port number.
- Step 104 The first UE communicates with the second UE on a direct communication path.
- the first UE uses the first public network IP address as the source IP address of the data packet sent to the second UE, the first public network port number as the source port number of the data packet, and the second public network IP address.
- the second public network port number is used as the destination port number of the data packet, and the data packet is sent to the second UE through the direct communication path. If the first UE generates the TFT, the first UE matches the data packet sent to the second UE to the corresponding direct communication path according to the TFT.
- the TFT corresponding to the direct communication path is different from the TFT corresponding to the network communication path, and the source IP address of the TFT corresponding to the network communication path is the first private network IP address, and the source port number is the first private network.
- Port number, the source IP address of the TFT corresponding to the direct communication path is the first public network IP address, the source port number is the first public network port number, and the destination IP address of the TFT used by the first UE to transmit data on the two communication paths The destination port number does not change. Both are the second public network IP address and the second public network port number.
- the source IP address of the data packet sent by the first UE through the direct communication path is the public network IP address of the first UE, and the source port number is the public network port number of the first UE.
- the IP address is the public network IP address of the second UE, and the destination IP address is the public network port number of the second UE. It can be seen that the source address and the source port number of the data packet sent by the first UE through the two communication paths are the same. Therefore, the IP address and the port number of the first UE do not change in the second UE. Thereby ensuring that the user's business is not interrupted.
- the first UE sends the handover indication information to the second UE, to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path, and obtains the first public network IP address. And the first public network port number, using the first public network IP address and the first public network port number to establish a direct communication path.
- the data packet sent by the first UE received by the second UE does not change, and the IP address and the port number of the first UE do not change in the second UE, thereby ensuring the user's Business is not interrupted.
- FIG. 2 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 2 of the present invention. As shown in FIG. 2, the method provided in this embodiment may include the following steps:
- Step 201 The second UE receives the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path.
- Step 202 The second UE acquires a second public network IP address and a second public network port number.
- the second UE may obtain the second public network IP address and the second public network port number by:
- the second UE sends a second request message to the first UE, where the second request message is used to request the first UE to obtain the second public network IP address and the second public network port number.
- the first UE After receiving the second request message, the first UE returns a second response message to the second UE according to the second request message, and the second UE receives the second response message returned by the first UE, where the second response message includes: The network IP address and the second public network port number.
- the second UE Before the second UE acquires the second public network IP address and the second public network port number, the second UE further receives the first request message sent by the first UE, where the handover indication information is carried in the first request message.
- the first request message is used to request to obtain the first public network IP address and the first public network port number, and the second UE determines, according to the handover indication information, the first public network IP used by the first UE and the second UE in the network communication path. Address and the first public network port number; the second UE will be the first public network IP address and the first public The network port number is carried in the first response message and sent to the first UE.
- the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- the application identification information and the handover indication information may also be included in the second request message.
- the second UE receives the first direct communication request message sent by the first UE, where the first direct communication request message includes a second public network IP address and a second public network port number.
- the handover indication information may also be carried in the first direct communication request message.
- the handover indication information may also be carried in other messages.
- the second UE After the second UE receives the first direct communication request message sent by the first UE, the second UE returns a first direct communication response message to the first UE according to the first direct communication request message, where the first direct communication response message includes: Public network IP address and first public network port number.
- the second UE sends a fourth request message to the application server, where the fourth request message is used to request to obtain the second public network IP address and the second public network port number, and the application server returns to the second UE according to the fourth request message.
- the fourth response message is sent by the second UE to the second UE.
- the fourth response message includes: a second public network IP address and a second public network port number.
- the handover indication information is carried in the second direct communication request message, and the second UE receives the first
- the second direct communication request message includes the handover indication information.
- the handover indication information may also be carried in other messages.
- the first direct communication request message or the second direct communication request message further includes application identification information.
- the second UE After the second UE receives the first direct communication request message sent by the first UE, the second UE also returns a first direct communication response message to the first UE, where the first direct communication response message includes: a first public network IP address and a first A public network port number.
- the second UE After the second UE receives the second direct communication request message sent by the first UE, the second UE returns a second direct communication response message to the first UE, where the second direct communication response message includes: application identifier information.
- step 201 and step 202 are not executed in sequence, and may be performed simultaneously.
- Step 203 The second UE establishes a direct use of the second public network IP address and the second public network port number. Communication path.
- the second UE establishes an underlying connection by using the second public network IP address and the second public network port number.
- the second UE may also generate a TFT of the direct communication path, where the source IP address of the TFT of the direct communication path is the second public network IP address, the source port number is the second public network port number, and the destination IP address is the first public network. IP address, the destination port number is the first public network port number.
- Step 204 The second UE communicates with the first UE on a direct communication path.
- the second UE uses the second public network IP address as the source IP address of the data packet sent to the first UE, and the second public network port number as the source port number of the data packet, and the first public network IP address.
- the first public network port number is used as the destination port number of the data packet, and the data packet is sent to the first UE through the direct communication path. If the second UE generates the TFT corresponding to the direct communication path, the second UE matches the data packet sent to the first UE to the direct communication path according to the TFT corresponding to the direct communication path.
- the source IP address of the second UE sending the data packet is the second private network IP address
- the source port number is the second private network port number
- the source IP address of the data packet is NAT.
- the server is converted into the second public network IP address
- the source port number is converted into the second public network port number by the NAT server
- the NAT server sends the data packet according to the converted second public network IP address and the second public network port number.
- the source address and the source port number of the data packet sent by the second UE through the two communication paths are the same, and therefore, the IP address of the second UE is seen by the first UE.
- the port number does not change, thus ensuring that the user's business is not interrupted.
- the second UE receives the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path, and obtains The second public network IP address and the second public network port number establish a direct communication path by using the second public network IP address and the second public network port number.
- the data packet sent by the second UE received by the first UE does not change, and the IP address and the port number of the second UE do not change in the first UE, thereby ensuring the user's Business is not interrupted.
- Embodiment 1 and Embodiment 2 will be described in detail below through several specific embodiments.
- FIG. 3 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 3 of the present invention. As shown in FIG. 3, the method provided in this embodiment may include the following steps:
- Step 301 The first UE and the second UE establish a network communication path.
- the network communication path is a path for establishing a PDN connection and a bearer to transmit data
- the first UE is used as an example, and the first UE establishes a PDN connection with the first core network by using the first eNB
- An eNB is an access device of the first UE
- the first core network is an access core network of the first UE
- the first core network includes multiple nodes: a mobility management entity (Mobility Management Entity, MME for short), and a service gateway. (Serving Gateway, SGW for short) and PGW.
- MME Mobility Management Entity
- SGW Serving Gateway
- the first UE sends a PDN connectivity request or an attach request to the MME by using the first eNB, and after receiving the PDN connection request or the attach request, the MME sends a create session request to the SGW, and the SGW will The create session request is sent to the PGW, and the PGW allocates the first private network IP address and the first private network port number to the first UE. Then, the PGW creates a session response message, and the session response message includes not only the first private network IP address and the first private network port number allocated by the PGW for the first UE, but also the first private network IP address and The first public network IP address and the second public network port number corresponding to the first private network port number.
- the second public network IP address and the second public network port number may also be sent to the first UE through the PDN connection establishment process or other messages of the attatch process, where the first UE saves the first private network IP address, the first private network port number, The second public network IP address and the second public network port number, the second UE establishes a PND connection with the second core network, and the process of establishing a PDN connection by the second UE is similar to that of the first UE.
- Step 302 The first UE and the second UE communicate through a network communication path.
- Step 303 The first UE initiates a discovery process, and determines whether it is closer to the second UE.
- the first UE finds that it is closer to the second UE, the first UE determines to switch from the network communication path to the direct communication path, and how the first UE finds the second UE is a prior art, which is not described too much here.
- Step 304 The first UE and the second UE exchange their respective Layer 2 IDs (layer2ID) in the discovery process.
- layer2ID Layer 2 IDs
- the first UE may also acquire the layer 2 identifier of the second UE, but the second UE does not acquire the layer 2 identifier of the first UE. If the first UE and the second UE are transmitting The first UE and the second UE can also exchange the Layer 2 identifiers through the application layer message, and the Layer 2 identifiers are used for the second layer to identify the Layer 2 identifiers of the second UE. Establish a Layer 2 connection on the direct communication path.
- Step 305 The first UE and the second UE authenticate each other to establish a secure Layer 2 connection on the direct communication path.
- Step 306 The first UE sends a first request message to the second UE, where the first request message includes the handover indication information and the APP ID.
- the first request message is used to request to obtain the first public network IP address and the first public network port number.
- the first request message carries the identifier of the first UE, and the identifier of the first UE may be an application layer. ), or (Mobile Subscriber International ISDN/PSTN number, MSISDN for short).
- whether the identifier of the first UE is carried in the first request message includes:
- the first request message may or may not carry the identifier of the first UE.
- the first request message needs to carry the identifier of the first UE.
- the first UE and the second UE do not need to carry the identifier of the first UE in the first request message if the second layer identifier of the first UE is exchanged by the application layer message.
- Step 307 The second UE matches the handover indication information and the APP ID to the communication session with the first UE, and acquires the first public network IP and the first public network port number used by the first UE in the communication session.
- Step 308 The second UE sends a first request response message to the first UE, where the first request response message includes a first public network IP and a first public network port number.
- Step 309 The second UE sends a second request message to the first UE, where the second request message includes an APP ID.
- the second request message is used to request the first UE to acquire the second public network IP address and the second public network port number.
- the second request message includes an APP ID.
- the second request message further includes the handover indication information, the handover indication information included in the second request message, the APP ID, and the handover indication information included in the first request message, and the APP.
- the ID is the same, optional, and the second request message is also The identifier of the second UE is included.
- Step 310 The first UE matches the handover indication information and the APP ID to the communication session with the second UE, and acquires the second public network IP and the second public network port number used by the second UE in the communication session.
- Step 311 The first UE sends a second request response message to the second UE, where the second request response message includes a second public network IP and a second public network port number.
- Step 312 The first UE and the second UE establish a direct communication path.
- the first UE establishes a direct communication path by using the first public network IP and the first public network port number
- the second UE establishes a direct communication path by using the second public network IP and the second public network port number.
- a TFT may also be generated.
- Step 313 The first UE and the second UE communicate on a direct communication path.
- FIG. 4 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 4 of the present invention. As shown in FIG. 4, the method provided in this embodiment may include the following steps:
- Step 401 The first UE and the second UE establish a network communication path.
- Step 402 The first UE and the second UE communicate through a network communication path.
- Step 403 The first UE initiates a discovery process, and determines whether it is closer to the second UE.
- Step 404 The first UE and the second UE exchange their respective Layer 2 identifiers in the discovery process.
- Step 405 The first UE and the second UE authenticate each other to establish a secure Layer 2 connection on the direct communication path.
- Step 406 The first UE sends a first direct communication request message to the second UE, where the first direct communication request message includes the handover indication information, the APP ID, the second public network IP address, and the second public network port number.
- the first direct communication request message may further include an identifier of the first UE.
- Step 407 The second UE returns a first direct communication request response message to the first UE, where the first direct communication request response message includes an APP ID, a first public network IP address, and a first public network port number.
- the second UE After receiving the first direct communication request message sent by the first UE, the second UE saves the second public network IP address and the second public network port number, and matches the communication session with the first UE according to the handover indication information and the APP ID. Obtaining a first public network IP address and a first public network port number used by the first UE in the communication session, and generating a first direct communication request response message.
- the first direct communication response message may further include The identity of the second UE.
- step 407 and step 408 are not sequential in execution, and may be performed in parallel.
- Step 408 The first UE and the second UE establish a direct communication path.
- the first UE establishes a direct communication path by using the first public network IP and the first public network port number
- the second UE establishes a direct communication path by using the second public network IP and the second public network port number.
- a TFT may also be generated.
- the second UE establishes a direct communication path according to the second public network IP address and the second public network port number.
- Step 409 The first UE returns a direct communication path establishment complete message to the second UE.
- the first UE After the first UE successfully establishes the direct communication path, the first UE returns a direct communication path setup complete message to the second UE, and notifies the second UE that the direct communication path is successfully established.
- Step 410 The first UE and the second UE communicate by using a direct communication path.
- FIG. 5 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 5 of the present invention. As shown in FIG. 5, the method provided in this embodiment may include the following steps:
- Step 501 The first UE and the second UE establish a network communication path.
- Step 502 The first UE and the second UE communicate by using a network communication path.
- Step 503 The first UE initiates a discovery process, and determines whether it is closer to the second UE.
- Step 504 The first UE and the second UE exchange their respective Layer 2 identifiers in the discovery process.
- Step 505 The first UE and the second UE authenticate each other to establish a secure Layer 2 connection on the direct communication path.
- Step 506 The first UE sends a third request message to the application server.
- the third request message is used to request to obtain the first public network IP address and the first public network port number.
- the third request message includes the identifier information of the second UE, so that the application server returns the first public network IP address and the first public network port number of the session with the second UE.
- Step 507 The application server returns a third response message to the first UE, where the third response message includes the first public network IP address and the first public network port number.
- Step 508 The first UE sends a second direct communication request message to the second UE, where the second direct communication request message includes the handover indication information and the APP ID.
- Step 509 The second UE sends a fourth request message to the application server.
- the fourth request message is used to request to obtain the second public network IP address and the second public network port number.
- the fourth request message includes the identifier information of the first UE, so that the application server returns a second public network IP address and a second public network port number of the session with the first UE.
- Step 510 The application server returns a fourth response message to the second UE, where the fourth response message includes a second public network IP address and a second public network port number.
- Step 511 The second UE returns a second direct communication response message to the first UE.
- the second direct communication response message may include identification information of the second UE.
- Step 512 The first UE and the second UE establish a direct communication path.
- the first UE establishes a direct communication path by using the first public network IP and the first public network port number
- the second UE establishes a direct communication path by using the second public network IP and the second public network port number.
- a TFT may also be generated.
- Step 513 The first UE and the second UE communicate by using a direct communication path.
- first direct communication request message and the second direct communication request message mentioned in the first embodiment to the fifth embodiment may be implemented by using the same message type, or may be different.
- the message type is implemented.
- the first direct communication response message and the second direct communication response message are also implemented by the same message type.
- the first request message and the second request message may be implemented by using the same message type, or may be implemented by using different message types.
- the third request message and the fourth request message may be implemented by using the same message type, or may be different.
- the message type is implemented.
- the first response message and the second response message also adopt the same message type
- the third request message and the fourth request message adopt the same
- the third response message and the fourth response message also use the same message type when the message type is used.
- the first UE may further carry a public safety indication in the process of establishing a direct communication path, where the public security indication is used to indicate the P- serving for the first UE.
- the GW saves the private network IP address of the first UE, so that the first UE needs to allocate the private network IP address of the first UE to the first UE when the communication path needs to be switched from the direct communication path to the network communication path. The address, so as to ensure that the user's business is not interrupted.
- the public safety indication can be implemented by a PDN connection request message or a Protocol Configuration Options (PCO) field or a request type field of the attach request message.
- PCO Protocol Configuration Options
- the eNB sends the public security indication to the MME.
- the MME's subscription data is configured with the private IP address of the public safty UE
- the MME sends the private network IP address to the PGW
- the PGW saves and allocates the private network IP address to the UE, so that after the first UE switches to the direct communication path and returns to the network communication path, the PGW can allocate the first UE.
- the public security indication may be saved in the MME and not sent to the PGW.
- the public security indication is included in the delete session request, so that the PGW saves the private The IP address of the network, so that after the first UE switches to the direct communication path and returns to the network communication path, the PGW can allocate the same private network IP address to the first UE.
- the first UE does not need to switch the communication path from the direct communication path to the network communication path, there is no need to carry a public safety indication in the process of establishing the network communication path.
- the second UE may also carry a public security indication in the process of establishing a direct communication path. The following will be explained by a specific embodiment:
- FIG. 6 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 6 of the present invention. As shown in FIG. 6, the method provided in this embodiment may include the following steps:
- Step 601 The first UE and the second UE communicate by using a direct communication path.
- the premise of this embodiment is that the first UE and the second UE have switched the communication path switching from the network communication path to the direct communication path, and communicated using the direct communication path.
- Step 602 In the communication process, the first UE determines that the communication quality of the direct communication path is lower than a preset threshold.
- the communication quality of the direct communication path is detected.
- the first UE may switch the communication path from the direct communication path to the network communication path.
- Step 603 The first UE establishes a PDN connection with the first core network, and carries public security indication information during the establishment process.
- the first UE determines to switch from the direct communication path to the network communication path, if the first network communication path is not released, the first UE directly switches the communication path from the direct communication path to the first network communication path, in this embodiment.
- the first network communication path is a network communication path used before the first UE switches to the direct communication path. If the first network communication path has been released, the second network communication path needs to be established, and the private network IP address used for communication in the second network communication path allocated for the first UE and the first UE are in the first network.
- the private network IP address used for communication on the communication path is the same, so that the service of the user after the handover is not interrupted.
- the first UE may include public security indication information in the PCO of the attach request or the PDN connection request, and the PGW may be the first UE according to the saved private network IP address used by the first UE to communicate on the first network communication path.
- the private network IP address used for communication on the first network communication path is allocated to the first UE as the private network IP address used by the first UE on the second network communication path.
- Step 604 The first core network sends the allocated private network IP address to the first UE.
- Step 605 The first UE establishes a second network communication path according to the private network IP address allocated by the first core network.
- the first UE establishes a bearer of the communication session with the second UE according to the private network IP address allocated by the first core network, and the first UE may further generate the second network according to the private network IP address allocated by the first core network.
- TFT corresponding to the communication path and the TFT corresponding to the second network communication path
- the source IP address is the private network IP address assigned by the first core network
- the source port number is the private network port number used by the second UE to communicate with the second UE
- the destination IP address is the second public network IP address.
- Address, destination port number is the second public network port number.
- Step 606 The first UE sends a direct communication cancellation request message to the second UE.
- the direct communication cancellation request message includes handover indication information, and the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the direct communication path to the second network communication path.
- Step 607 The second UE and the second core network establish a PDN connection, and carry the public security indication information in the establishing process.
- Step 608 The second core network sends the allocated private network IP address to the second UE.
- the PGW in the second core network includes a private network IP address used by the second UE to communicate on the first network communication path, and the second core network uses the private network IP used by the second UE to communicate on the first network communication path.
- the address is the private network IP address used by the second UE to communicate on the second network communication path.
- Step 609 The second UE establishes a second network communication path according to the private network IP address allocated by the second core network.
- the second UE establishes a bearer of the communication session with the first UE according to the private network IP address allocated by the second core network, and the second UE may further generate a second according to the private network IP address allocated by the second core network.
- the TFT corresponding to the network communication path and the matching information of the TFT corresponding to the second network communication path the source address is a private network IP address allocated by the second core network, and the source port number is used by the second UE for use with the first UE.
- the destination IP address is the first public network IP address, and the destination port number is the first public network port number.
- Step 610 The second UE sends a direct communication cancellation response message to the first UE.
- the first UE and the second UE may further connect the communication path. Switching from the direct communication path to the network communication path, and ensuring that the user's service is not interrupted during the handover.
- FIG. 7 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 7 of the present invention. As shown in FIG. 7, the method provided in this embodiment may include the following steps:
- Step 701 The first UE sends handover indication information to the second UE, where the indication information is used for handover. And indicating that the communication path between the second UE and the first UE is switched from the network communication path to the direct communication path.
- the first UE sends the handover indication information to the second UE, where the first UE sends a third direct communication request message or a fourth direct communication request message to the second UE, where the third direct communication request message or the first
- the four direct communication request message includes the handover indication information.
- the first UE may also send the handover indication information by using other messages.
- the third direct communication request message further includes a first private network IP address, a first private network port number, a second public network IP address, and a second public network port number; and the fourth direct communication request message is further The method may include: a first private network IP address and a first private network port number.
- the third direct communication request message or the fourth direct communication request message further includes application identification information.
- Step 702 The first UE acquires a first public network IP address and a first public network port number.
- Step 703 The first UE acquires a second private network IP address and a second private network port number.
- the first UE acquires the first public network IP address and the first public network port number, specifically: the first UE receives the third direct communication response message returned by the second UE, and the third direct communication response message is The second UE is returned according to the third direct communication request message, where the third direct communication response message includes: a first public network IP address and a first public network port number.
- the third direct communication response message may further include: a second private network IP address and a second private network port number, where the first UE obtains the second private network IP address and the second private network port number from the third direct communication response message. .
- the first UE acquires the first public network IP address and the first public network port number, where the first UE sends a third request message to the application server, and the third request message is used to request to obtain the first a public network IP address and a first public network port number.
- the third request message includes the identifier information of the second UE, so that the application server returns the first public IP address of the session with the second UE.
- the first public network port number The application server returns a third response message to the first UE according to the third request message, where the first UE receives the third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number.
- the first UE acquires the second private network IP address and the second private network port number, specifically: the first UE receives the fourth direct communication response message returned by the second UE according to the fourth direct communication request message, and the fourth direct The communication response message includes: a second private network IP address and a second private network port number.
- the steps 701-703 are not in the order of execution. And can be executed at the same time; and the third request message and the third direct communication request message in the step 703 are not in the order of execution, and can be executed simultaneously.
- Step 704 The first UE establishes a direct communication path by using the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number.
- the first UE after acquiring the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number, the first UE does not need to establish a direct communication path through signaling interaction.
- the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number are established according to the first public network IP address, the first public network IP address, and the first public network port number.
- the first correspondence between the first private network IP address and the first private network port number, and the second public network IP address, the second public network port number, the second private network IP address, and the second private network port number The second correspondence.
- the first UE may also generate a TFT corresponding to the direct communication path.
- the TFT corresponding to the direct communication path is the same as the TFT corresponding to the network communication path, and the source IP of the TFT corresponding to the direct communication path.
- the address is the first private network IP address
- the source port number is the first private network port number
- the destination IP address is the second public network IP address
- the destination port number is the second public network port number, but the TFT of the direct communication path takes precedence.
- the level is higher than the priority of the network communication path, thereby ensuring that the TFT of the direct communication path is preferentially used when the first UE sends a data packet to the second UE.
- Step 705 The first UE communicates with the second UE on the direct communication path.
- the application layer of the first UE uses the first private network IP address as the source IP address of the data packet when encapsulating the data packet sent to the second UE.
- a private network port number is used as the source port number of the data packet
- the second public network IP address is used as the destination IP address of the data packet
- the second public network port number is used as the destination port number of the data packet.
- the encapsulated data packet is the same as the data packet transmitted on the network communication path, and therefore, the application layer of the first UE sees that the network communication path and the data packet on the direct communication path are the same.
- a proximity service layer may be added to the first UE, and the proximity service layer is used according to the first correspondence.
- the source IP address, the source port number, the destination IP address, and the destination port number of the data packet are modified by the second correspondence.
- the proximity service layer of the first UE replaces the source IP address of the data packet sent to the second UE with the first public network IP address according to the first correspondence, and replaces the source port number of the data packet with the first public Network port number, according to the second correspondence
- the destination IP address of the data packet is replaced with the second private network IP address, and the destination port number of the data packet is replaced with the second private network port number, and the first UE sends the data packet to the second UE by using the direct communication path.
- the data packet sent by the first UE through the direct communication path is the same as the data packet sent by the first UE through the network communication path, that is, the source IP address of the first UE before and after the communication path is switched by the second UE.
- the source port number, the destination IP address, and the destination port number are unchanged, so that the service on the second UE is not interrupted.
- the first UE may also receive the data packet sent by the second UE by using a direct communication path.
- the difference between this embodiment and the first embodiment is that, in the first embodiment, the source IP address and the source port number of the data packet sent by the first UE through the direct communication path and the network communication path are the same, but the destination IP address. The address and destination port number are different. In this embodiment, the source IP address and the source port number of the data packet sent by the first UE through the direct communication path and the network communication path are the same, and the destination IP address and the destination port number are also the same.
- the first UE sends the handover indication information to the second UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path, and obtains the first The public network IP address, the first public network port number, the second private network IP address, and the second private network port number are based on the first public network IP address, the first public network port number, the second private network IP address, and the second The private network port number establishes a direct communication path, and the direct communication path is used to communicate with the second UE.
- the method ensures that the service of the user is not interrupted before and after the communication path is switched by the first UE.
- FIG. 8 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 8 of the present invention. As shown in FIG. 8, the method provided in this embodiment may include the following steps:
- Step 801 The second UE receives the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path.
- the handover indication information is carried in the third direct communication request message or the fourth direct communication request message, and the second UE receives the third direct communication request message or the fourth direct communication request message sent by the first UE, from the third The handover indication information is obtained in the direct communication request message or the fourth direct communication request message.
- the handover indication information may also be carried in other messages.
- the third direct communication request message or the fourth direct communication request message may further include application identification information.
- Step 802 The second UE acquires a second public network IP address and a second public network port number.
- Step 803 The second UE acquires the first private network IP address and the first private network port number.
- the third direct communication request message further includes a second public network IP address, a second public network port number, a first private network IP address, and a first private network port number, where the second UE is directly from the third The second public network IP address, the second public network port number, the first private network IP address, and the first private network port number are obtained in the communication request message.
- the second UE sends a fourth request message to the application server, where the fourth request message is used to request to obtain the second public network IP address and the second public network port number, optionally, in the fourth request message.
- the identifier information of the first UE is included, so that the application server returns a second public network IP address and a second public network port number of the session with the first UE.
- the application server After receiving the fourth request message, the application server returns a fourth response message to the second UE according to the fourth request message, where the fourth response message includes the second public network IP address and the second public network port number.
- the second UE obtains the first private network IP address and the first private network port number from the fourth direct communication request message, where the fourth direct communication request message includes the first private network IP address and the first private network port number.
- the second UE After the second UE receives the third direct communication request message sent by the first UE, the second UE also returns a third direct communication response message to the first UE, where the third direct communication response message includes the first public network IP address, A public network port number, a second private network IP address, and a second private network port number.
- the second UE After the second UE receives the fourth direct communication request message sent by the first UE, the second UE also returns a fourth direct communication response message to the first UE, where the fourth direct communication response message includes the second private network IP address and the first Second private network port number.
- steps 801-803 are not executed in sequence, and may be performed simultaneously; and the fourth request message and the fourth direct communication request message in the step 803 are not in the order of execution. And can be executed simultaneously
- Step 804 The second UE establishes a direct communication path by using the second public network IP address, the second public network port number, the first private network IP address, and the first private network port.
- the second UE establishes an underlying connection according to the second public network IP address, the second public network port number, the first private network IP address, and the first private network port, and establishes a second public network IP address and a second public network.
- the first correspondence between the port number and the second private network IP address and the second private network port number, and the first public network IP address, the first public network port number, the first private network IP address, and the first private network port number The second correspondence.
- the second UE may also generate a direct communication path corresponding to
- the TFT corresponding to the direct communication path is the same as the TFT corresponding to the network communication path
- the source IP address of the TFT corresponding to the direct communication path is the second private network IP address
- the source port number is the second private network port number.
- the destination IP address is the first public network IP address
- the destination port number is the first public network port number, but the priority of the TFT of the direct communication path is higher than the priority of the network communication path, thereby ensuring that the second UE is to the first UE.
- the TFT of the direct communication path is preferred when sending a packet.
- Step 805 The second UE communicates with the first UE on a direct communication path.
- the second UE replaces the source IP address of the data packet sent to the first UE with the second public network IP address according to the first correspondence, and replaces the source port number of the data packet with the second public network port number.
- the second UE sends the replaced data packet to the first UE by using a direct communication path.
- the second UE may also receive the data packet sent by the first UE by using a direct communication path.
- the application layer of the second UE uses the second private network IP address as the source IP address of the data packet when encapsulating the data packet sent to the first UE.
- the second private network port number is used as the source port number of the data packet
- the first public network IP address is used as the destination IP address of the data packet
- the first public network port number is used as the destination port number of the data packet.
- the encapsulated packet is the same as the packet sent on the network communication path.
- the data packets transmitted in the network communication path need to undergo address translation by the NAT server on the first UE side and the second UE side.
- the first UE needs to replace the source and destination IP addresses of the data packet with the source and destination port numbers, so that the source IP address and source port of the second UE before and after the first UE seems to be switched.
- the number and the destination IP address and the destination port number are unchanged, so that the service on the first UE is not interrupted.
- FIG. 9 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 9 of the present invention. As shown in FIG. 9, the method provided in this embodiment may include Including the following steps:
- Step 901 The first UE and the second UE respectively establish a network communication path.
- Step 902 The first UE and the second UE communicate through a network communication path.
- Step 903 The first UE initiates a discovery process, and determines whether it is closer to the second UE.
- Step 904 The first UE and the second UE exchange their respective Layer 2 identifiers in the discovery process.
- Step 905 The first UE and the second UE authenticate each other to establish a secure Layer 2 connection on the direct communication path.
- Step 906 The first UE sends a third request message to the application server.
- Step 907 The application server returns a third response message, where the third response message includes a first public network IP address and a first public network port number.
- Step 908 The first UE sends a fourth direct communication request message to the second UE, where the fourth direct communication request message includes the handover indication information, the APP ID, the first private network IP address, and the first private network port number.
- the identifier of the first UE may also be included in the fourth direct communication request message.
- Step 909 The second UE sends a fourth request message to the application server according to the handover indication information and the APP ID.
- Step 910 The application server returns a fourth response message to the second UE, where the second public network IP address and the second public network port number are in the fourth response message.
- Step 911 The second UE establishes and saves a first correspondence between the second public network IP address, the second public network port number, the second private network IP address, and the second private network port number, and the first public network IP address, The second correspondence between the first public network port number and the first private network IP address and the first private network port number.
- Step 912 The second UE returns a fourth direct communication response message to the first UE, where the fourth direct communication response message includes a second private network IP address and a second private network port number.
- Step 913 The second UE establishes and saves a first public network IP address, a first public network port number, a first private network IP address, a first private network port number, and a second public network IP address.
- Step 914 The first UE and the second UE communicate on a direct communication path.
- the third direct communication request message and the fourth direct communication request message mentioned in the seventh embodiment to the ninth embodiment may be implemented by using the same message type, or may be implemented by using different message types.
- the third direct communication response message and the fourth direct communication response message are also implemented by the same message type of the same message type.
- the third request message and the fourth request message may be implemented by using the same message type, or may be implemented by using different message types.
- the third response message and The fourth response message also uses the same message type.
- the first UE is a schematic structural diagram of a first UE according to Embodiment 10 of the present invention.
- the first UE provided in this embodiment includes: a sending module 11, an obtaining module 12, a path establishing module 13, and a communication module 14.
- the sending module 11 is configured to send, to the second UE, handover indication information, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from a network communication path to a direct communication path;
- the obtaining module 12 is configured to obtain a first public network IP address and a first public network port number
- the path establishing module 13 is configured to establish the direct communication path by using the first public network IP address and the first public network port number;
- the communication module 14 is configured to communicate with the second UE on the direct communication path.
- the sending module 11 is specifically configured to: send a first request message to the second UE, where the first request message is used to request to obtain the first public network IP address and the first a public network port number, where the first request message includes the handover indication information.
- the acquiring module 12 is specifically configured to: receive the first response message returned by the second UE, where the first response message includes: the first public network IP address and the first public network port number.
- the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE sends the communication path under the application corresponding to the application identifier from the The network communication path is switched to the direct communication path.
- the first UE further includes: a receiving module, configured to receive a second request message sent by the second UE, where the second request message is used to request the first UE to acquire a second public network The IP address and the second public network port; correspondingly, the sending 11 module is further configured to send a second response message to the second UE, where the second response message includes: the second public network IP address And a port number and the second public network port number.
- a receiving module configured to receive a second request message sent by the second UE, where the second request message is used to request the first UE to acquire a second public network The IP address and the second public network port
- the sending 11 module is further configured to send a second response message to the second UE, where the second response message includes: the second public network IP address And a port number and the second public network port number.
- the acquiring module 12 is specifically configured to: send a first direct communication request message to the second UE, where the first direct communication request message further includes: a second public network IP address and a Receiving, by the second public network port number, the first direct communication response message returned by the second UE, where the first direct communication response message includes: the first public network IP address and the first public network port number.
- the handover indication information may be carried in the first direct communication request message.
- the sending module 11 is specifically configured to: send a second direct communication request message to the second UE, where the second direct communication request message includes the switching indication information;
- the obtaining module 12 is specifically configured to: send a third request message to the application server, where the third request message is used to request to obtain the first public network IP address and the first public network port number; and then receive the The third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number.
- the first direct communication request message or the second direct communication request message further includes application identification information.
- the communication module 14 is specifically configured to:
- the first public network IP address as the source IP address of the data packet sent to the second UE
- the address is used as the destination IP address of the data packet
- the second public network port number is used as the destination port number of the data packet
- the data packet is sent to the second UE by using the direct communication path.
- the first UE provided in this embodiment may be used to perform the methods in the first embodiment and the third embodiment to the sixth embodiment.
- the specific implementation manners and technical effects are similar, and details are not described herein again.
- FIG. 11 is a schematic structural diagram of a second UE according to Embodiment 11 of the present invention.
- the second UE provided in this embodiment includes: a receiving module 21, an obtaining module 22, a path establishing module 23, and a communication module 24. .
- the receiving module 21 is configured to receive the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from a network communication path to a direct communication path. ;
- the obtaining module 22 is configured to obtain a second public network IP address and a second public network port number.
- the path establishing module 23 is configured to establish the direct communication path by using the second public network IP address and the second public network port number;
- the communication module 24 is configured to communicate with the first UE on the direct communication path.
- the acquiring module 22 is specifically configured to: send a second request message to the first UE, where the second request message is used to request the first UE to acquire the second public network.
- the receiving module 21 is further configured to: receive the first request message sent by the first UE, where the first request message includes the handover indication information, where the first request message is used to request acquisition a first public network IP address and a first public network port number, where the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, The first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path; determining, according to the handover indication information, the first UE and The first public network IP address and the first public network port number used by the second UE in the network communication path.
- the second UE further includes: a sending module, configured to send the first public network IP address and the first public network port number to the first UE in a first response message.
- the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE sends the communication path under the application corresponding to the application identifier from the network communication path. Switch to the direct communication path.
- the acquiring module 22 is specifically configured to: receive a first direct communication request message sent by the first UE, where the first direct communication request message includes the second public network IP address and The second public network port number.
- the handover indication information may be carried in the first direct communication request message.
- the second UE further includes: a sending module, configured to return a first direct communication response message to the first UE, where the first direct communication response is cancelled
- the information includes: the first public network IP address and the first public network port number.
- the receiving module 21 is specifically configured to: receive a second direct communication request message sent by the first UE, where the second direct communication request message includes the switching indication information.
- the obtaining module 22 is specifically configured to: send a fourth request message to the application server, where the fourth request message is used to request to acquire the second public network IP address and the second public network port number; The fourth response message returned by the application server, where the fourth response message includes: the second public network IP address and the second public network port number.
- the first direct communication request message or the second direct communication request message further includes application identification information, where the application identification information is used to indicate that the second UE uses the application corresponding to the application identifier.
- the communication path is switched from the network communication path to the direct communication path.
- the communication module is specifically configured to: use the second public network IP address as a source IP address of a data packet sent to the first UE, and use the second public network port number as the The source port number of the data packet, the first public network IP address is used as the destination IP address of the data packet, and the first public network port number is used as the destination port number of the data packet, and the data packet is directly A communication path is sent to the first UE.
- the second UE provided in this embodiment may be used to perform the methods in the second embodiment to the sixth embodiment.
- the specific implementation manners and technical effects are similar, and details are not described herein again.
- FIG. 12 is a schematic structural diagram of a first UE according to Embodiment 12 of the present invention.
- the first UE provided in this embodiment includes: a sending module 31, an obtaining module 32, a path establishing module 33, and a communication module 34. .
- the sending module 31 is configured to send, to the second UE, handover indication information, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from a network communication path to a direct communication path;
- the obtaining module 32 is configured to obtain the first public network IP address and the first public network port number;
- the obtaining module 32 is further configured to obtain a second private network IP address and a second private network port number.
- the path establishing module 33 is configured to establish the direct communication path by using the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number;
- the communication module 34 is configured to communicate with the second UE on the direct communication path.
- the path establishing module 33 is specifically configured to: establish the first public network IP address, the first public network port number, the first private network IP address, and the first private network port number. Corresponding relationship, and a second correspondence between the second public network IP address, the second public network port number, the second private network IP address, and the second private network port number.
- the communication module 34 is specifically configured to: replace, according to the first correspondence, a source IP address of a data packet sent to the second UE with the first public network IP address, and a source port of the data packet.
- the number is replaced by the first public network port number
- the destination IP address of the data packet is replaced with the second private network IP address according to the second correspondence
- the destination port number of the data packet is replaced with The second private network port number, wherein the source port number of the data packet is the first private network port number, and the source port number of the data packet is the first private network port number, the data
- the destination IP address of the packet is the second public network IP address, the destination port number of the data packet is the second public network port number, and the first UE sends the data packet through the direct communication path. Giving the second UE; or receiving, by the direct communication path, a data packet sent by the second UE.
- the sending module 31 is specifically configured to: send a third direct communication request message to the second UE, where the third direct communication request message includes: the switching indication information; the acquiring module The specific one is: receiving the third direct communication response message that is returned by the second UE, where the third direct communication response message includes: the first public network IP address and the first public network port number; The third direct communication response message further includes: the second private network IP address and the second private network port number, and the obtaining module 32 acquires the second private from the third direct communication response message The network IP address and the second private network port number.
- the sending module 31 is specifically configured to: send a fourth direct communication request message to the second UE, where the fourth direct communication request message includes: the handover indication information.
- the obtaining, by the obtaining module 32, the second private network IP address and the second private network port number, includes: receiving a fourth direct communication response message returned by the second UE, where the fourth direct communication response message is
- the method includes: the second private network IP address and the first Second private network port number.
- the third direct communication request message further includes: a first private network IP address and a first private network port number, a second public network IP address, and a second public network port number.
- the fourth direct communication request message further includes: a first private network IP address and a first private network port number.
- the third direct communication request message or the fourth direct communication request message further includes application identification information, where the application identification information is used to indicate that the second UE uses the application corresponding to the application identifier.
- the communication path is switched from the network communication path to the direct communication path.
- the first UE provided in this embodiment may be used to perform the solution provided in the seventh embodiment and the eighth embodiment.
- the specific implementation manners and technical effects are similar, and details are not described herein again.
- FIG. 13 is a schematic structural diagram of a second UE according to Embodiment 13 of the present invention.
- the second UE provided in this embodiment includes: a receiving module 41, an obtaining module 42, a path establishing module 43, and a communication module 44. .
- the receiving module 41 is configured to receive the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from a network communication path to a direct communication path. ;
- the obtaining module 42 is configured to obtain a second public network IP address and a second public network port number.
- the obtaining module 42 is further configured to obtain the first private network IP address and the first private network port number;
- the path establishing module 43 is configured to establish the direct communication path by using the second public network IP address, the second public network port number, the first private network IP address, and the first private network port;
- the communication module 44 is configured to communicate with the first UE on the direct communication path.
- the path establishing module 43 is specifically configured to: establish the first public network IP address, the second public network port number, the second private network IP address, and the second private network port number. Corresponding relationship, and a second correspondence between the first public network IP address, the first public network port number, the first private network IP address, and the first private network port number.
- the communication module 44 is specifically configured to: replace, according to the first correspondence, a source IP address of a data packet sent to the first UE with the second public network IP address, where the data is The source port number of the packet is replaced by the second public network port number, and the destination IP address of the data packet is replaced with the first private network IP address according to the second correspondence, and the data packet is The destination port number is replaced by the first private network port number, where the source port number of the data packet is the second private network port number, and the source port number of the data packet is the second private network a port number, the destination IP address of the data packet is the first public network IP address, the destination port number of the data packet is the first public network port number, and the second UE replaces the data packet Transmitting to the first UE by using the direct communication path; or receiving, by the direct communication path, a data packet sent by the first UE.
- the receiving module 41 is specifically configured to: receive a third direct communication request message sent by the first UE, where the third direct communication request message includes: the handover indication information.
- the third direct communication request message further includes the second public network IP address and the second public network port number, and the obtaining module 42 is specifically configured to: obtain the location from the third direct communication request message The second public network IP address and the second public network port number are described.
- the third direct communication request message further includes the first private network IP address and the first private network port number, and the obtaining module 42 is specifically configured to: obtain the location from the third direct communication request message.
- the first private network IP address and the first private network port number are described.
- the receiving module 41 is specifically configured to: receive a fourth direct communication request message sent by the first UE, where the fourth direct communication request message includes: the handover indication information.
- the obtaining module 42 includes: sending a fourth request message to the application server, where the fourth request message is used to request to acquire the second public And receiving the fourth response message returned by the application server, where the fourth response message includes the second public network IP address and the second public network port number .
- the acquiring module acquires the first private network IP address and the first private network port number, and the method includes: the fourth direct communication request message further includes the first private network IP address and the first private The network port number, the obtaining module 42 acquires the first private network IP address and the first private network port number from the fourth direct communication request message.
- the second UE further includes: a sending module, configured to return a third direct communication response message to the first UE, where the third direct communication response message includes a first public network IP address, and a first a public network port number, a second private network IP address, and a second private network port number, or returning a fourth direct communication response message to the first UE, where the fourth direct communication response message includes a second private network IP address. Address and second private network port number.
- the application identifier information is further used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
- the second UE provided in this embodiment may be used to implement the solutions in the eighth embodiment and the ninth embodiment.
- the specific implementation manners and the technical effects are similar.
- FIG. 14 is a schematic structural diagram of a first UE according to Embodiment 14 of the present invention.
- the first UE 500 provided in this embodiment includes: a processor 51, a memory 52, a communication interface 53, and a system bus 54, The memory 51 and the communication interface 53 are connected and communicated with the processor 51 through the system bus; the memory 51 is configured to store computer execution instructions; the communication interface 53 is configured to communicate with other devices.
- first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path
- the first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path
- the processor 51 sends the handover indication information to the second UE, where the processor 51 sends a first request message to the second UE, where the first request message is used to request to obtain the The first public network IP address and the first public network port number, and the first request message includes the handover indication information.
- the processor 51 obtains the first public network IP address and the first public network port number, specifically: receiving the first response message returned by the second UE, where the first response message includes: the first public The network IP address and the first public network port number.
- the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path. To the direct communication path.
- the processor 51 Before the processor 51 establishes the direct communication path by using the first public network IP address and the first public network port number, the processor 51 is further configured to: receive the second a request message, the second request message is used to request the first UE to acquire a second public network IP address and a second public network port, and send a second response message to the second UE, where the second response is The message includes: the second public network IP address and port number and the second public network port number.
- the processor 51 obtains the first public network IP address and the first public network port number, where the processor 51 sends a first direct communication request message to the second UE, where the first The direct communication request message further includes: a second public network IP address and a second public network port number; receiving the first direct communication response message returned by the second UE, where the first direct communication response message includes: The first public network IP address and the first public network port number.
- the handover indication information is carried in the first direct communication request message.
- the processor 51 sends the handover indication information to the second UE, where the second direct communication request message is sent to the second UE, where the second direct communication request message includes the handover indication information.
- the processor 51 obtains the first public network IP address and the first public network port number, specifically: sending a third request message to the application server, where the third request message is used to request to obtain the first public network IP address. And receiving, by the first public network port number, a third response message that is returned by the application server, where the third response message includes: the first public network IP address and the first public network port number.
- the first direct communication request message or the second direct communication request message further includes application identification information, where the application identification information is used to indicate that the second UE uses the application corresponding to the application identifier.
- the communication path is switched from the network communication path to the direct communication path.
- the processor 51 communicates with the second UE on the direct communication path, where the processor 51 uses the first public network IP address as a source of data packets sent to the second UE.
- the IP address, the first public network port number is used as the source port number of the data packet
- the second public network IP address is used as the destination IP address of the data packet
- the second public network port number is used as the data.
- a destination port number of the packet where the data packet is sent to the second UE by using the direct communication path.
- the first UE provided in this embodiment may be used to implement the solutions in the first embodiment and the third embodiment to the sixth embodiment.
- the specific implementation manners and technical effects are similar, and details are not described herein again.
- FIG. 15 is a schematic structural diagram of a second UE according to Embodiment 15 of the present invention.
- the second UE 600 provided in this embodiment includes: a processor 61, a memory 62, a communication interface 63, and a system bus 64.
- the memory 62 and the communication interface 63 are connected and communicated with the processor 61 via the system bus 64; the memory 62 is for storing computer execution instructions; the communication interface 63 is for communicating with other devices for communication
- the processor 61 is configured to execute the computer to execute an instruction, and execute the method as follows:
- the processor 61 obtains the second public network IP address and the second public network port number, specifically: sending a second request message to the first UE, where the second request message is used to Receiving, by the first UE, the second public network IP address and the second public network port number; receiving a second response message that is returned by the first UE, where the second response message includes: the second public The network IP address and the second public network port number.
- the processor 61 is further configured to: receive the first request message sent by the first UE, where the first request message includes And the first indication message is used to request to obtain the first public network IP address and the first public network port number; and determining, according to the handover indication information, that the first UE and the second UE are The first public network IP address and the first public network port number used in the network communication path; carrying the first public network IP address and the first public network port number in a first response message Transmitting to the first UE.
- the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE sends the communication path under the application corresponding to the application identifier from the network communication path. Switch to the direct communication path.
- the processor 61 obtains the second public network IP address and the second public network port number, specifically: receiving the first direct communication request message sent by the first UE, where the first direct communication
- the request message includes the second public network IP address and the second public network port number.
- the handover indication information is carried in the first direct communication request message.
- the processor 61 After receiving the first direct communication request message sent by the first UE, the processor 61 is further configured to: return a first direct communication response message to the first UE, where the first direct communication response message includes: The first public network IP address and the first public network port number.
- the processor 61 receives the handover indication information sent by the first UE, specifically: receiving a second direct communication request message sent by the first UE, where the second direct communication request message includes the handover Instructing the information that the second public network IP address and the second public network port number are obtained by the processor 61, specifically: sending a fourth request message to the application server, where the fourth request message is used to request to acquire the second public Receiving a fourth response message returned by the application server, where the fourth response message includes: the second public network IP address and the second public network port number.
- the first direct communication request message or the second direct communication request message further includes application identification information.
- the processor 61 communicates with the first UE on the direct communication path, specifically: using the second public network IP address as a source IP address of a data packet sent to the first UE.
- the second public network port number is used as the source port number of the data packet
- the first public network IP address is used as the destination IP address of the data packet
- the first public network port number is used as the data packet.
- the destination port number, the data packet is sent to the first UE by using the direct communication path.
- the second UE provided in this embodiment may be used to perform the solution provided in the second embodiment to the sixth embodiment.
- the specific implementation manners and technical effects are similar, and details are not described herein again.
- FIG. 16 is a schematic structural diagram of a first UE according to Embodiment 16 of the present invention.
- the first UE 700 provided in this embodiment includes: a processor 71, a memory 72, a communication interface 73, and a system bus 74.
- the memory 72 and the communication interface 73 are connected and communicated with the processor 71 via the system bus 74; the memory 72 is configured to store computer execution instructions; the communication interface 73 is configured to communicate with other devices,
- the processor 71 is configured to run the computer to execute an instruction, and execute the method as follows:
- the processor 71 establishes the direct communication path by using the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number, specifically The processor 71 establishes a first correspondence between the first public network IP address, the first public network port number, the first private network IP address, and the first private network port number, and the second public network IP address. The second correspondence between the address, the second public network port number, the second private network IP address, and the second private network port number.
- the processor 71 communicates with the second UE on the direct communication path, specifically: the source IP address of the data packet that the processor 71 sends to the second UE according to the first correspondence. And replacing with the first public network IP address, replacing the source port number of the data packet with the first public network port number, and replacing the destination IP address of the data packet with the second corresponding relationship.
- the second private network IP address, the destination port number of the data packet is replaced with the second private network port number, where the source port number of the data packet is the first private network port number, The source port number of the data packet is the first private network port number, the destination IP address of the data packet is the second public network IP address, and the destination port number of the data packet is the second public network port.
- the first UE sends the data packet to the second UE by using the direct communication path; or the first UE receives the data packet sent by the second UE by using the direct communication path.
- the processor 71 sends the handover indication information to the second UE, where the third direct communication request message is sent to the second UE, where the third direct communication request message includes: the handover indication information.
- the processor 71 obtains the first public network IP address and the first public network port number, specifically: receiving the third direct communication response message returned by the second UE, where the third direct communication response message includes: The first public network IP address and the first public network port number are described.
- the third direct communication response message further includes: the second private network IP address and the second private network port number, and the processor 71 acquires the second private network IP address and the second private network port number. Specifically, the second private network IP address is obtained from the third direct communication response message. And the second private network port number.
- the processor 71 sends the handover indication information to the second UE, where the fourth direct communication request message is sent to the second UE, where the fourth direct communication request message includes: the handover indication information.
- the processor 71 obtains the first public network IP address and the first public network port number, specifically: sending a third request message to the application server, where the third request message is used to request to acquire the first public network. An IP address and the first public network port number; receiving a third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number .
- the processor 71 obtains the second private network IP address and the second private network port number, specifically: receiving the fourth direct communication response message returned by the second UE, where the fourth direct communication response message includes: The second private network IP address and the second private network port number are described.
- the third direct communication request message further includes: a first private network IP address and a first private network port number, a second public network IP address, and a second public network port number.
- the fourth direct communication request message further includes: a first private network IP address and a first private network port number.
- the third direct communication request message or the fourth direct communication request message further includes application identification information, where the application identification information is used to indicate that the second UE uses the application corresponding to the application identifier.
- the communication path is switched from the network communication path to the direct communication path.
- the first UE provided in this embodiment may be used to perform the solution provided in the seventh embodiment and the eighth embodiment.
- the specific implementation manners and technical effects are similar, and details are not described herein again.
- FIG. 17 is a schematic structural diagram of a second UE according to Embodiment 17 of the present invention.
- the second UE 800 provided in this embodiment includes: a processor 81, a memory 82, a communication interface 83, and a system bus 84.
- the memory 82 and the communication interface 83 are connected and communicated with the processor 81 through the system bus 84; the memory 82 is configured to store computer execution instructions; the communication interface 83 is used for performing with other devices.
- Communication, the processor 81 configured to run the computer to execute an instruction, and execute the method described below:
- the processor 81 establishes the direct communication path by using the second public network IP address, the second public network port number, the first private network IP address, and the first private network port. Specifically, the processor 81 establishes a first correspondence between the second public network IP address, the second public network port number, the second private network IP address, and the second private network port number, and the first The second corresponding relationship between the public network IP address, the first public network port number, the first private network IP address, and the first private network port number.
- the processor 81 is configured to communicate with the first UE on the direct communication path, where the source IP address of the data packet sent to the first UE is replaced according to the first correspondence. And replacing, by the second public network IP address, the source port number of the data packet with the second public network port number, and replacing the destination IP address of the data packet with the second correspondence relationship.
- the first private network IP address, the destination port number of the data packet is replaced with the first private network port number; or the data packet sent by the first UE is received through the direct communication path.
- the processor 81 receives the handover indication information that is sent by the first UE, specifically: receiving a third direct communication request message sent by the first UE, where the third direct communication request message includes: Switch the indication information.
- the processor 81 obtains the second public network IP address and the second public network port number, where the third direct communication request message further includes the second public network IP address and the second public network port.
- the processor 81 obtains the second public network IP address and the second public network port number from the third direct communication request message.
- the third direct communication request message further includes the first private network IP address and the first private network port number, and the processor 81 obtains the first private network IP address and the first private network port number, specifically The processor 81 obtains the first private network IP address and the first private network port number from the third direct communication request message.
- the processor 81 receives the handover indication information that is sent by the first UE, specifically: receiving a fourth direct communication request message sent by the first UE, where the fourth direct communication request message includes: Switch the indication information.
- the processor 81 acquires a second public network IP address and The second public network port number is specifically configured to: send a fourth request message to the application server, where the fourth request message is used to request to obtain the second public network IP address and the second public network port number; The fourth response message returned by the application server, where the fourth response message includes the second public network IP address and the second public network port number.
- the processor 81 obtains the first private network IP address and the first private network port number, where the fourth direct communication request message further includes the first private network IP address and the first private network port.
- the processor 81 obtains the first private network IP address and the first private network port number from the fourth direct communication request message.
- the processor 81 After receiving the third direct communication request message sent by the first UE, the processor 81 is further configured to: return a third direct communication response message, the third direct communication response message, to the first UE.
- the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number are included.
- the processor 81 After receiving the fourth direct communication request message sent by the first UE, the processor 81 is further configured to: return, to the first UE, a fourth direct communication response message, where the fourth direct communication response The message includes a second private network IP address and a second private network port number.
- the third direct communication request message or the fourth direct communication request message further includes application identification information, where the application identification information is used to indicate that the second UE uses the application corresponding to the application identifier.
- the communication path is switched from the network communication path to the direct communication path.
- the second UE provided in this embodiment may be used to implement the solution provided in the eighth embodiment and the ninth embodiment.
- the specific implementation manners and technical effects are similar, and details are not described herein again.
- the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
- the foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
Description
本发明实施例涉及通信技术,尤其涉及一种网络通信和直接通信之间的切换方法和装置。The embodiments of the present invention relate to communication technologies, and in particular, to a method and an apparatus for switching between network communication and direct communication.
在长期演进(Long Term Evolution,简称,LTE)网络中,用户设备(User Equipment,简称UE)间的数据通信路径要经过接入网实体:演进型基站(evolved Node Basestation,简称eNB),以及核心网实体:服务网关(Serving Gateway,简称S-GW)或分组数据网络网关(Packet Data Network Gateway,简称P-GW),因此,即使两个UE距离非常近,传递数据时也需要经过网络通信路径进行数据传输,网络通信路径中包括上述接入网实体和核心网实体。这样会对LTE网络的传输带宽有较大的需求量,并且传输效率较低。In a Long Term Evolution (LTE) network, a data communication path between user equipments (UEs) passes through an access network entity: an evolved base station (eNB), and a core. Network entity: Serving Gateway (S-GW) or Packet Data Network Gateway (P-GW). Therefore, even if the two UEs are very close, the data communication path needs to be passed when the data is transmitted. Data transmission is performed, and the network communication path includes the foregoing access network entity and core network entity. This will have a large demand for the transmission bandwidth of the LTE network, and the transmission efficiency is low.
为了解决该问题,业界提出了设备到设备的(Device to Device,简称D2D)的通信方式,即距离较近的UE之间可以通过直接通信路径传输数据,而无需经过接入网实体和核心网实体。但是,现有技术中,当用户的会话从网络通信路径切换到直接通信路径时,用户的业务会中断。In order to solve this problem, the industry proposes a Device to Device (D2D) communication method, that is, a relatively close UE can transmit data through a direct communication path without going through an access network entity and a core network. entity. However, in the prior art, when a user's session is switched from a network communication path to a direct communication path, the user's service is interrupted.
发明内容Summary of the invention
本发明实施例提供一种网络通信和直接通信之间的切换方法和装置,能够保证用户的会话在网络通信和直接通信之间切换时,用户的业务不中断。The embodiment of the invention provides a method and a device for switching between network communication and direct communication, which can ensure that the user's service is not interrupted when the user's session is switched between network communication and direct communication.
本发明第一方面提供一种网络通信和直接通信之间的切换方法,包括:A first aspect of the present invention provides a method for switching between network communication and direct communication, including:
第一UE向第二UE发送切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;The first UE sends the handover indication information to the second UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path;
所述第一UE获取第一公网IP地址和第一公网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径 中与所述第二UE通信所使用的公网端口号;The first UE acquires a first public network IP address and a first public network port number, where the first public network IP address is used by the first UE to communicate with the second UE in the network communication path. Public network IP address, the first public network port number is the network communication path of the first UE a public network port number used for communicating with the second UE;
所述第一UE使用所述第一公网IP地址和所述第一公网端口号建立所述直接通信路径;The first UE establishes the direct communication path by using the first public network IP address and the first public network port number;
所述第一UE在所述直接通信路径上与所述第二UE通信。The first UE communicates with the second UE on the direct communication path.
结合第一方面,在第一方面的第一种可能的实现方式中,所述第一UE向第二UE发送切换指示信息,包括:With reference to the first aspect, in a first possible implementation manner of the first aspect, the sending, by the first UE, the handover indication information to the second UE includes:
所述第一UE向所述第二UE发送第一请求消息,所述第一请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号,所述第一请求消息中包括所述切换指示信息;Sending, by the first UE, a first request message to the second UE, where the first request message is used to request to acquire the first public network IP address and the first public network port number, the first request The message includes the handover indication information;
所述第一UE获取第一公网IP地址和第一公网端口号,包括:Obtaining, by the first UE, the first public network IP address and the first public network port number, including:
所述第一UE接收所述第二UE返回的第一响应消息,所述第一响应消息中包括:所述第一公网IP地址和所述第一公网端口号。The first UE receives the first response message returned by the second UE, where the first response message includes: the first public network IP address and the first public network port number.
结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述第一请求消息还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the first request message further includes application identifier information, where the application identifier information is used to indicate the first The two UEs switch the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
结合第一方面的第一种或第二种可能的实现方式,在第一方面的第三种可能的实现方式中,所述第一UE使用所述第一公网IP地址和所述第一公网端口号建立所述直接通信路径之前,所述方法还包括:In conjunction with the first or second possible implementation of the first aspect, in a third possible implementation manner of the first aspect, the first UE uses the first public network IP address and the first Before the public network port number establishes the direct communication path, the method further includes:
所述第一UE接收所述第二UE发送的第二请求消息,所述第二请求消息用于向所述第一UE请求获取第二公网IP地址和第二公网端口,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址,所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号;Receiving, by the first UE, a second request message sent by the second UE, where the second request message is used to request the first UE to acquire a second public network IP address and a second public network port, where the The second public network IP address is the public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the second UE in the a public network port number used by the network communication path to communicate with the first UE;
所述第一UE向所述第二UE发送第二响应消息,所述第二响应消息中包括:所述第二公网IP地址及端口号和所述第二公网端口号。The first UE sends a second response message to the second UE, where the second response message includes: the second public network IP address and port number and the second public network port number.
结合第一方面,在第一方面的第四种可能的实现方式中,所述第一UE获取第一公网IP地址和第一公网端口号,包括:With reference to the first aspect, in a fourth possible implementation manner of the first aspect, the acquiring, by the first UE, the first public network IP address and the first public network port number includes:
所述第一UE向所述第二UE发送第一直接通信请求消息,所述第一直接通信请求消息中还包括:第二公网IP地址和第二公网端口号,所述 第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址,所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号;The first UE sends a first direct communication request message to the second UE, where the first direct communication request message further includes: a second public network IP address and a second public network port number, The second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the second UE a public network port number used by the network communication path to communicate with the first UE;
所述第一UE接收所述第二UE返回的第一直接通信响应消息,所述第一直接通信响应消息中包括:所述第一公网IP地址和所述第一公网端口号。The first UE receives the first direct communication response message returned by the second UE, where the first direct communication response message includes: the first public network IP address and the first public network port number.
结合第一方面第四种可能的实现方式,在第一方面的第五种可能的实现方式中,所述切换指示信息携带在所述第一直接通信请求消息中。In conjunction with the fourth possible implementation of the first aspect, in a fifth possible implementation manner of the first aspect, the handover indication information is carried in the first direct communication request message.
结合第一方面,在第一方面的第六种可能的实现方式中,所述第一UE向第二UE发送切换指示信息,包括:With reference to the first aspect, in a sixth possible implementation manner of the first aspect, the sending, by the first UE, the handover indication information to the second UE includes:
所述第一UE向所述第二UE发送第二直接通信请求消息,所述第二直接通信请求消息中包括所述切换指示信息;The first UE sends a second direct communication request message to the second UE, where the second direct communication request message includes the handover indication information;
所述第一UE获取第一公网IP地址和第一公网端口号,包括:Obtaining, by the first UE, the first public network IP address and the first public network port number, including:
所述第一UE向应用服务器发送第三请求消息,所述第三请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号;The first UE sends a third request message to the application server, where the third request message is used to request to acquire the first public network IP address and the first public network port number;
所述第一UE接收所述应用服务器返回的第三响应消息,所述第三响应消息中包括:所述第一公网IP地址和所述第一公网端口号。The first UE receives the third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number.
结合第一方面第四种至第六种可能的实现方式中的任意一种,在第一方面的第七种可能的实现方式中,所述第一直接通信请求消息或所述第二直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to any one of the fourth to sixth possible implementation manners of the first aspect, in a seventh possible implementation manner of the first aspect, the first direct communication request message or the second direct communication The request message further includes application identification information, where the application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
结合第一方面,在第一方面的第八种可能的实现方式中,所述第一UE在所述直接通信路径上与所述第二UE通信,包括:With reference to the first aspect, in an eighth possible implementation manner of the first aspect, the first UE that communicates with the second UE on the direct communication path includes:
所述第一UE将所述第一公网IP地址作为发送给所述第二UE的数据包的源IP地址,将所述第一公网端口号作为所述数据包的源端口号,将第二公网IP地址作为所述数据包的目的IP地址,将第二公网端口号作为所述数据包的目的端口号,将所述数据包通过所述直接通信路径发送给所述第二UE,其中,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址,所述第二公网端口号为 所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号。The first UE uses the first public network IP address as a source IP address of a data packet sent to the second UE, and uses the first public network port number as a source port number of the data packet, and The second public network IP address is used as the destination IP address of the data packet, and the second public network port number is used as the destination port number of the data packet, and the data packet is sent to the second through the direct communication path. a UE, where the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path.
本发明第二方面提供一种网络通信和直接通信之间的切换方法,包括:A second aspect of the present invention provides a method for switching between network communication and direct communication, including:
第二UE接收第一UE发送的切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;The second UE receives the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path;
所述第二UE获取第二公网IP地址和第二公网端口号,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址,所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号;The second UE acquires a second public network IP address and a second public network port number, where the second public network IP address is used by the second UE to communicate with the first UE in the network communication path. a public network IP address, where the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path;
所述第二UE使用所述第二公网IP地址和所述第二公网端口号建立所述直接通信路径;The second UE establishes the direct communication path by using the second public network IP address and the second public network port number;
所述第二UE在所述直接通信路径上与所述第一UE通信。The second UE communicates with the first UE on the direct communication path.
结合第二方面,在第二方面的第一种可能的实现方式中,所述第二UE获取第二公网IP地址和第二公网端口号,包括:With reference to the second aspect, in a first possible implementation manner of the second aspect, the acquiring, by the second UE, the second public network IP address and the second public network port number includes:
所述第二UE向所述第一UE发送第二请求消息,所述第二请求消息用于向所述第一UE请求获取所述第二公网IP地址和所述第二公网端口号;The second UE sends a second request message to the first UE, where the second request message is used to request the first UE to acquire the second public network IP address and the second public network port number. ;
所述第二UE接收所述第一UE返回的第二响应消息,所述第二响应消息中包括:所述第二公网IP地址和所述第二公网端口号。The second UE receives the second response message that is returned by the first UE, where the second response message includes: the second public network IP address and the second public network port number.
结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述第二UE获取第二公网IP地址和第二公网端口号之前,所述方法还包括:With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, before the second UE acquires the second public network IP address and the second public network port number, The method also includes:
所述第二UE接收所述第一UE发送的第一请求消息,所述第一请求消息中包括所述切换指示信息,所述第一请求消息用于请求获取第一公网IP地址和第一公网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号; Receiving, by the second UE, the first request message sent by the first UE, where the first request message includes the handover indication information, where the first request message is used to request to acquire a first public network IP address and a first a public network port number, where the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, and the first public network port number a public network port number used by the first UE to communicate with the second UE in the network communication path;
所述第二UE根据所述切换指示信息,确定所述第一UE与所述第二UE在所述网络通信路径中使用的所述第一公网IP地址和所述第一公网端口号;Determining, by the second UE, the first public network IP address and the first public network port number used by the first UE and the second UE in the network communication path according to the handover indication information ;
所述第二UE将所述第一公网IP地址和所述第一公网端口号携带在第一响应消息中发送给所述第一UE。The second UE sends the first public network IP address and the first public network port number in the first response message to the first UE.
结合第二方面的第二种可能的实现方式,在第二方面的第三种可能的实现方式中,所述第一请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to the second possible implementation of the second aspect, in a third possible implementation manner of the second aspect, the first request message further includes application identifier information, where the application identifier information is used to indicate the The second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
结合第二方面,在第二方面的第四种可能的实现方式中,所述第二UE获取第二公网IP地址和第二公网端口号,包括:With reference to the second aspect, in a fourth possible implementation manner of the second aspect, the acquiring, by the second UE, the second public network IP address and the second public network port number includes:
所述第二UE接收所述第一UE发送的第一直接通信请求消息,所述第一直接通信请求消息包括所述第二公网IP地址和所述第二公网端口号。The second UE receives the first direct communication request message sent by the first UE, where the first direct communication request message includes the second public network IP address and the second public network port number.
结合第二方面的第四种可能的实现方式,在第二方面的第五种可能的实现方式中,所述切换指示信息携带在所述第一直接通信请求消息中。In conjunction with the fourth possible implementation of the second aspect, in a fifth possible implementation manner of the second aspect, the handover indication information is carried in the first direct communication request message.
结合第二方面的第四种或第五种可能的实现方式,在第二方面的第六种可能的实现方式中,所述第二UE接收所述第一UE发送的第一直接通信请求消息之后,所述方法还包括:In conjunction with the fourth or fifth possible implementation of the second aspect, in a sixth possible implementation manner of the second aspect, the second UE receives the first direct communication request message sent by the first UE Thereafter, the method further includes:
所述第二UE向所述第一UE返回第一直接通信响应消息,所述第一直接通信响应消息中包括:第一公网IP地址和第一公网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号。Returning, by the second UE, the first direct communication response message to the first UE, where the first direct communication response message includes: a first public network IP address and a first public network port number, the first public network The IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, and the first public network port number is the first UE in the network communication path. A public network port number used for communicating with the second UE.
结合第二方面,在第二方面的第七种可能的实现方式中,所述第二UE接收第一UE发送的切换指示信息,包括:With reference to the second aspect, in a seventh possible implementation manner of the second aspect, the receiving, by the second UE, the handover indication information that is sent by the first UE includes:
所述第二UE接收所述第一UE发送的第二直接通信请求消息,所述第二直接通信请求消息中包括所述切换指示信息;The second UE receives the second direct communication request message sent by the first UE, where the second direct communication request message includes the handover indication information;
所述第二UE获取第二公网IP地址和第二公网端口号,包括:Obtaining, by the second UE, the second public network IP address and the second public network port number, including:
所述第二UE向应用服务器发送第四请求消息,所述第四请求消息用于请求获取所述第二公网IP地址和所述第二公网端口号; The second UE sends a fourth request message to the application server, where the fourth request message is used to request to acquire the second public network IP address and the second public network port number;
所述第二UE接收所述应用服务器返回的第四响应消息,所述第四响应消息中包括:所述第二公网IP地址和所述第二公网端口号。The second UE receives the fourth response message returned by the application server, where the fourth response message includes: the second public network IP address and the second public network port number.
结合第二方面的第四种至第七种可能的实现方式中的任意一种,在第二方面的第八种可能的实现方式中,所述第一直接通信请求消息或所述第二直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to any one of the fourth to seventh possible implementation manners of the second aspect, in the eighth possible implementation manner of the second aspect, the first direct communication request message or the second direct The communication request message further includes application identification information, where the application identification information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path. .
结合第二方面,在第二方面的第九种可能的实现方式中,所述第二UE在所述直接通信路径上与所述第一UE通信,包括:With reference to the second aspect, in a ninth possible implementation manner of the second aspect, the second UE that communicates with the first UE on the direct communication path includes:
所述第二UE将所述第二公网IP地址作为发送给所述第一UE的数据包的源IP地址,将所述第二公网端口号作为所述数据包的源端口号,将第一公网IP地址作为所述数据包的目的IP地址,将第一公网端口号作为所述数据包的目的端口号,将所述数据包通过所述直接通信路径发送给所述第一UE,其中,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号。The second UE uses the second public network IP address as the source IP address of the data packet sent to the first UE, and the second public network port number as the source port number of the data packet, The first public network IP address is used as the destination IP address of the data packet, and the first public network port number is used as the destination port number of the data packet, and the data packet is sent to the first through the direct communication path. a UE, where the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, where the first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path.
本发明第三方面提供一种网络通信和直接通信之间的切换方法,包括:A third aspect of the present invention provides a method for switching between network communication and direct communication, including:
第一UE向第二UE发送切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;The first UE sends the handover indication information to the second UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path;
所述第一UE获取第一公网IP地址和第一公网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号;The first UE acquires a first public network IP address and a first public network port number, where the first public network IP address is used by the first UE to communicate with the second UE in the network communication path. a public network IP address, where the first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path;
所述第一UE获取第二私网IP地址和第二私网端口号,所述第二私网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网IP地址,所述第二私网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网端口号; The first UE acquires a second private network IP address and a second private network port number, where the second private network IP address is used by the second UE to communicate with the first UE in the network communication path. a private network IP address, where the second private network port number is a private network port number used by the second UE to communicate with the first UE in the network communication path;
所述第一UE使用所述第一公网IP地址、所述第一公网端口号、所述第二私网IP地址和所述第二私网端口号建立所述直接通信路径;The first UE establishes the direct communication path by using the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number;
所述第一UE在所述直接通信路径上与所述第二UE通信。The first UE communicates with the second UE on the direct communication path.
结合第三方面,在第三方面的第一种可能的实现方式中,所述第一UE使用所述第一公网IP地址、所述第一公网端口号、所述第二私网IP地址和所述第二私网端口号建立所述直接通信路径,包括:With reference to the third aspect, in a first possible implementation manner of the third aspect, the first UE uses the first public network IP address, the first public network port number, and the second private network IP Establishing the direct communication path by the address and the second private network port number, including:
所述第一UE建立所述第一公网IP地址、所述第一公网端口号与第一私网IP地址、第一私网端口号的第一对应关系,以及第二公网IP地址、第二公网端口号与所述第二私网IP地址、所述第二私网端口号的第二对应关系,其中,所述第一私网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网IP地址,所述第一私网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网端口号,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址、所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号。The first UE establishes a first correspondence between the first public network IP address, the first public network port number, the first private network IP address, and the first private network port number, and the second public network IP address. And a second corresponding relationship between the second public network port number and the second private network IP address and the second private network port number, where the first private network IP address is the first UE in the a private network IP address used in communication with the second UE in the network communication path, where the first private network port number is used by the first UE to communicate with the second UE in the network communication path a private network port number, where the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path.
结合第三方面的第一种可能的实现方式,在第三方面的第二种可能的实现方式中,所述第一UE在所述直接通信路径上与所述第二UE通信,包括:In conjunction with the first possible implementation of the third aspect, in a second possible implementation manner of the third aspect, the first UE that communicates with the second UE on the direct communication path includes:
所述第一UE根据所述第一对应关系将发送给所述第二UE的数据包的源IP地址替换为所述第一公网IP地址,将所述数据包的源端口号替换为所述第一公网端口号,根据所述第二对应关系将所述数据包的目的IP地址替换为所述第二私网IP地址,将所述数据包的目的端口号替换为所述第二私网端口号,其中,所述数据包的源端口号为所述第一私网端口号,所述数据包的源端口号为所述第一私网端口号,所述数据包的目的IP地址为所述第二公网IP地址,所述数据包的目的端口号为所述第二公网端口号,所述第一UE将所述数据包通过所述直接通信路径发送给所述第二UE;The first UE replaces the source IP address of the data packet sent to the second UE with the first public network IP address according to the first correspondence, and replaces the source port number of the data packet with the The first public network port number, the destination IP address of the data packet is replaced with the second private network IP address according to the second correspondence, and the destination port number of the data packet is replaced by the second a private network port number, where the source port number of the data packet is the first private network port number, the source port number of the data packet is the first private network port number, and the destination IP address of the data packet The address is the second public network IP address, the destination port number of the data packet is the second public network port number, and the first UE sends the data packet to the first Two UE;
或者,所述第一UE通过所述直接通信路径接收所述第二UE发送的数据包。Or the first UE receives the data packet sent by the second UE by using the direct communication path.
结合第三方面,在第三方面的第三种可能的实现方式中,所述第一 UE向第二UE发送切换指示信息,包括:In conjunction with the third aspect, in a third possible implementation of the third aspect, the first The UE sends the handover indication information to the second UE, including:
所述第一UE向所述第二UE发送第三直接通信请求消息,所述第三直接通信请求消息中包括:所述切换指示信息;The first UE sends a third direct communication request message to the second UE, where the third direct communication request message includes: the handover indication information;
所述第一UE获取第一公网IP地址和第一公网端口号,包括:Obtaining, by the first UE, the first public network IP address and the first public network port number, including:
所述第一UE接收所述第二UE返回的第三直接通信响应消息,所述第三直接通信响应消息中包括:所述第一公网IP地址和所述第一公网端口号;Receiving, by the first UE, the third direct communication response message that is returned by the second UE, where the third direct communication response message includes: the first public network IP address and the first public network port number;
所述第一UE获取第二私网IP地址和第二私网端口号,包括:The first UE acquires the second private network IP address and the second private network port number, including:
所述第三直接通信响应消息中还包括:所述第二私网IP地址和所述第二私网端口号,所述第一UE从所述第三直接通信响应消息中获取所述第二私网IP地址和所述第二私网端口号。The third direct communication response message further includes: the second private network IP address and the second private network port number, where the first UE acquires the second from the third direct communication response message The private network IP address and the second private network port number.
结合第三方面,在第三方面的第四种可能的实现方式中,所述第一UE向第二UE发送切换指示信息,包括:With reference to the third aspect, in a fourth possible implementation manner of the third aspect, the sending, by the first UE, the handover indication information to the second UE includes:
所述第一UE向所述第二UE发送第四直接通信请求消息,所述第四直接通信请求消息中包括:所述切换指示信息;The first UE sends a fourth direct communication request message to the second UE, where the fourth direct communication request message includes: the handover indication information;
所述第一UE获取第一公网IP地址和所述第一公网端口号,包括:Obtaining, by the first UE, the first public network IP address and the first public network port number, including:
所述第一UE向应用服务器发送第三请求消息,所述第三请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号;The first UE sends a third request message to the application server, where the third request message is used to request to acquire the first public network IP address and the first public network port number;
所述第一UE接收所述应用服务器返回的第三响应消息,所述第三响应消息中包括:所述第一公网IP地址和所述第一公网端口号;The first UE receives the third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number;
所述第一UE获取第二私网IP地址和第二私网端口号,包括:The first UE acquires the second private network IP address and the second private network port number, including:
所述第一UE接收所述第二UE返回的第四直接通信响应消息,所述第四直接通信响应消息中包括:所述第二私网IP地址和所述第二私网端口号。The first UE receives the fourth direct communication response message returned by the second UE, where the fourth direct communication response message includes: the second private network IP address and the second private network port number.
结合第三方面的第三种可能的实现方式,在第三方面的第五种可能的实现方式中,所述第三直接通信请求消息中还包括:第一私网IP地址和第一私网端口号、第二公网IP地址和第二公网端口号,所述第一私网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网IP地址,所述第一私网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网端口号,所述第二公网IP地址为所述第 二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址、所述第二公网端口号为所述第二UE在所述网络通信路径中所述第一UE通信所使用的公网端口号。With the third possible implementation of the third aspect, in a fifth possible implementation manner of the third aspect, the third direct communication request message further includes: a first private network IP address and a first private network a port number, a second public network IP address, and a second public network port number, where the first private network IP address is a private network used by the first UE to communicate with the second UE in the network communication path. An IP address, where the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path, and the second public network IP address is the First a public network IP address used by the two UEs to communicate with the first UE in the network communication path, and the second public network port number is the first UE in the network communication path of the second UE The public network port number used for communication.
结合第三方面的第四种可能的实现方式,在第三方面的第六种可能的实现方式中,所述第四直接通信请求消息中还包括:第一私网IP地址和第一私网端口号,所述第一私网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网IP地址,所述第一私网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网端口号。With the fourth possible implementation of the third aspect, in a sixth possible implementation manner of the third aspect, the fourth direct communication request message further includes: a first private network IP address and a first private network a port number, where the first private network IP address is a private network IP address used by the first UE to communicate with the second UE in the network communication path, where the first private network port number is A private network port number used by the first UE to communicate with the second UE in the network communication path.
结合第三方面的第五种或第六种可能的实现方式,在第三方面的第七种可能的实现方式中,所述第三直接通信请求消息或所述第四直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to the fifth or the sixth possible implementation manner of the third aspect, in a seventh possible implementation manner of the third aspect, the third direct communication request message or the fourth direct communication request message is further The application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
本发明第四方面提供一种网络通信和直接通信之间的切换方法,包括:A fourth aspect of the present invention provides a method for switching between network communication and direct communication, including:
第二UE接收第一UE发送的切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;The second UE receives the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path;
所述第二UE获取第二公网IP地址和第二公网端口号,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址,所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号;The second UE acquires a second public network IP address and a second public network port number, where the second public network IP address is used by the second UE to communicate with the first UE in the network communication path. a public network IP address, where the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path;
所述第二UE获取第一私网IP地址和第一私网端口号,所述第一私网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网IP地址,所述第一私网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网端口号;The second UE acquires a first private network IP address and a first private network port number, where the first private network IP address is used by the first UE to communicate with the second UE in the network communication path. a private network IP address, where the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path;
所述第二UE使用所述第二公网IP地址、所述第二公网端口号、所述第一私网IP地址和所述第一私网端口建立所述直接通信路径;The second UE establishes the direct communication path by using the second public network IP address, the second public network port number, the first private network IP address, and the first private network port;
所述第二UE在所述直接通信路径上与所述第一UE通信。 The second UE communicates with the first UE on the direct communication path.
结合第四方面,在第四方面的第一种可能的实现方式中,所述第二UE使用所述第二公网IP地址、所述第二公网端口号、所述第一私网IP地址和所述第一私网端口建立所述直接通信路径,包括:With reference to the fourth aspect, in a first possible implementation manner of the fourth aspect, the second UE uses the second public network IP address, the second public network port number, and the first private network IP Establishing the direct communication path with the address and the first private network port, including:
所述第二UE建立所述第二公网IP地址、所述第二公网端口号与第二私网IP地址、第二私网端口号的第一对应关系,以及第一公网IP地址、第一公网端口号与所述第一私网IP地址、所述第一私网端口号的第二对应关系,其中,所述第二私网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网IP地址,所述第二私网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号。The second UE establishes a first correspondence between the second public network IP address, the second public network port number, the second private network IP address, and the second private network port number, and the first public network IP address. a second corresponding relationship between the first public network port number and the first private network IP address and the first private network port number, where the second private network IP address is the second UE in the a private network IP address used in communication with the first UE in a network communication path, where the second private network port number is used by the second UE to communicate with the first UE in the network communication path a private network port number, where the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, where the first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path.
结合第四方面的第一种可能的实现方式,在第四方面的第二种可能的实现方式中,所述第二UE在所述直接通信路径上与所述第一UE通信,包括:With the first possible implementation of the fourth aspect, in a second possible implementation manner of the fourth aspect, the second UE that communicates with the first UE on the direct communication path includes:
所述第二UE根据所述第一对应关系将发送给所述第一UE的数据包的源IP地址替换为所述第二公网IP地址,将所述数据包的源端口号替换为所述第二公网端口号,根据所述第二对应关系将所述数据包的目的IP地址替换为所述第一私网IP地址,将所述数据包的目的端口号替换为所述第一私网端口号,其中,所述数据包的源端口号为所述第二私网端口号,所述数据包的源端口号为所述第二私网端口号,所述数据包的目的IP地址为所述第一公网IP地址,所述数据包的目的端口号为所述第一公网端口号,所述第二UE将替换后的数据包通过所述直接通信路径发送给所述第一UE;The second UE replaces the source IP address of the data packet sent to the first UE with the second public network IP address according to the first correspondence, and replaces the source port number of the data packet with the a second public network port number, the destination IP address of the data packet is replaced with the first private network IP address according to the second correspondence, and the destination port number of the data packet is replaced by the first a private network port number, where the source port number of the data packet is the second private network port number, the source port number of the data packet is the second private network port number, and the destination IP address of the data packet The address is the first public network IP address, the destination port number of the data packet is the first public network port number, and the second UE sends the replaced data packet to the First UE;
或者,所述第二UE通过所述直接通信路径接收所述第一UE发送的数据包。Or the second UE receives the data packet sent by the first UE by using the direct communication path.
结合第四方面的第一种可能的实现方式,在第四方面的第三种可能的实现方式中,所述第二UE接收第一UE发送的切换指示信息,包括:With reference to the first possible implementation manner of the fourth aspect, in a third possible implementation manner of the fourth aspect, the receiving, by the second UE, the handover indication information that is sent by the first UE includes:
所述第二UE接收所述第一UE发送的第三直接通信请求消息,所述第三直接通信请求消息中包括:所述切换指示信息; The second UE receives the third direct communication request message sent by the first UE, where the third direct communication request message includes: the handover indication information;
所述第二UE获取第二公网IP地址和第二公网端口号,包括:Obtaining, by the second UE, the second public network IP address and the second public network port number, including:
所述第三直接通信请求消息中还包括所述第二公网IP地址和所述第二公网端口号,所述第二UE从所述第三直接通信请求消息中获取所述第二公网IP地址和所述第二公网端口号;The second direct communication request message further includes the second public network IP address and the second public network port number, and the second UE acquires the second public from the third direct communication request message a network IP address and the second public network port number;
所述第二UE获取第一私网IP地址和第一私网端口号,包括:Obtaining, by the second UE, the first private network IP address and the first private network port number, including:
所述第三直接通信请求消息中还包括所述第一私网IP地址和所述第一私网端口号,所述第二UE从所述第三直接通信请求消息中获取所述第一私网IP地址和所述第一私网端口号。The third direct communication request message further includes the first private network IP address and the first private network port number, and the second UE acquires the first private information from the third direct communication request message. The network IP address and the first private network port number.
结合第四方面的第一种可能的实现方式,在第四方面的第四种可能的实现方式中,所述第二UE接收第一UE发送的切换指示信息,包括:With reference to the first possible implementation manner of the foregoing aspect, in a fourth possible implementation manner of the fourth aspect, the receiving, by the second UE, the handover indication information that is sent by the first UE includes:
所述第二UE接收所述第一UE发送的第四直接通信请求消息,所述第四直接通信请求消息中包括:所述切换指示信息;The second UE receives the fourth direct communication request message sent by the first UE, where the fourth direct communication request message includes: the handover indication information;
所述第二UE获取第二公网IP地址和第二公网端口号,包括:Obtaining, by the second UE, the second public network IP address and the second public network port number, including:
所述第二UE向应用服务器发送第四请求消息,所述第四请求消息用于请求获取所述第二公网IP地址和所述第二公网端口号;The second UE sends a fourth request message to the application server, where the fourth request message is used to request to acquire the second public network IP address and the second public network port number;
所述第二UE接收所述应用服务器返回的第四响应消息,所述第四响应消息中包括所述第二公网IP地址和所述第二公网端口号;The second UE receives the fourth response message returned by the application server, where the fourth response message includes the second public network IP address and the second public network port number;
所述第二UE获取第一私网IP地址和第一私网端口号,包括:Obtaining, by the second UE, the first private network IP address and the first private network port number, including:
所述第四直接通信请求消息中还包括所述第一私网IP地址和所述第一私网端口号,所述第二UE从所述第四直接通信请求消息中获取所述第一私网IP地址和所述第一私网端口号。The fourth direct communication request message further includes the first private network IP address and the first private network port number, and the second UE acquires the first private information from the fourth direct communication request message. The network IP address and the first private network port number.
结合第四方面的第三种可能的实现方式,在第四方面的第五种可能的实现方式中,所述第二UE接收到所述第一UE发送的所述第三直接通信请求消息之后,所述方法还包括:With the third possible implementation of the fourth aspect, in a fifth possible implementation manner of the fourth aspect, after the second UE receives the third direct communication request message sent by the first UE, The method further includes:
所述第二UE向所述第一UE返回第三直接通信响应消息,所述第三直接通信响应消息中包括第一公网IP地址、第一公网端口号、第二私网IP地址和第二私网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号,所述第二私网IP地址为所述第二UE在所述网络通信路径 中与所述第一UE通信所使用的私网IP地址,所述第二私网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网端口号。Returning, by the second UE, a third direct communication response message to the first UE, where the third direct communication response message includes a first public network IP address, a first public network port number, a second private network IP address, and a second private network port number, where the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, and the first public network port a number of the public network port used by the first UE to communicate with the second UE in the network communication path, where the second private network IP address is the second UE in the network communication path a private network IP address used for communication with the first UE, where the second private network port number is a private network port used by the second UE to communicate with the first UE in the network communication path number.
结合第四方面的第四种可能的实现方式,在第四方面的第六种可能的实现方式中,所述第二UE接收到所述第一UE发送的所述第第四直接通信请求消息之后,所述方法还包括:With the fourth possible implementation of the fourth aspect, in a sixth possible implementation manner of the fourth aspect, the second UE receives the fourth direct communication request message sent by the first UE Thereafter, the method further includes:
所述第二UE向所述第一UE返回第四直接通信响应消息,所述第四直接通信响应消息中包括第二私网IP地址和第二私网端口号,所述第二私网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网IP地址,所述第二私网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网端口号。The second UE returns a fourth direct communication response message to the first UE, where the fourth direct communication response message includes a second private network IP address and a second private network port number, and the second private network IP address The address is a private network IP address used by the second UE to communicate with the first UE in the network communication path, and the second private network port number is the second UE in the network communication path. The private network port number used to communicate with the first UE.
结合第四方面的第五种或第六种可能的实现方式,在第四方面的第七种可能的实现方式中,所述第三直接通信请求消息或所述第四直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to the fifth or the sixth possible implementation manner of the foregoing aspect, in a seventh possible implementation manner of the fourth aspect, the third direct communication request message or the fourth direct communication request message is further The application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
本发明第五方面提供一种第一UE,包括:A fifth aspect of the present invention provides a first UE, including:
发送模块,用于向第二UE发送切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;a sending module, configured to send, to the second UE, the handover indication information, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from a network communication path to a direct communication path;
获取模块,用于获取第一公网IP地址和第一公网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号;An acquiring module, configured to obtain a first public network IP address and a first public network port number, where the first public network IP address is used by the first UE to communicate with the second UE in the network communication path. a public network IP address, where the first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path;
路径建立模块,用于使用所述第一公网IP地址和所述第一公网端口号建立所述直接通信路径;a path establishing module, configured to establish the direct communication path by using the first public network IP address and the first public network port number;
通信模块,用于在所述直接通信路径上与所述第二UE通信。And a communication module, configured to communicate with the second UE on the direct communication path.
结合第五方面,在第五方面的第一种可能的实现方式中,所述发送模块具体用于:With reference to the fifth aspect, in a first possible implementation manner of the fifth aspect, the sending module is specifically configured to:
向所述第二UE发送第一请求消息,所述第一请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号,所述第一请求消息中包括 所述切换指示信息;Sending a first request message to the second UE, where the first request message is used to request to acquire the first public network IP address and the first public network port number, where the first request message includes The switching indication information;
所述获取模块具体用于:The obtaining module is specifically configured to:
接收所述第二UE返回的第一响应消息,所述第一响应消息中包括:所述第一公网IP地址和所述第一公网端口号。And receiving, by the second UE, the first response message, where the first response message includes: the first public network IP address and the first public network port number.
结合第五方面的第一种可能的实现方式,在第五方面的第二种可能的实现方式中,所述第一请求消息还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to the first possible implementation manner of the fifth aspect, in a second possible implementation manner of the fifth aspect, the first request message further includes application identifier information, where the application identifier information is used to indicate the first The two UEs switch the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
结合第五方面的第一种或第二种可能的实现方式,在第五方面的第三种可能的实现方式中,所述第一UE还包括:In conjunction with the first or second possible implementation of the fifth aspect, in a third possible implementation manner of the fifth aspect, the first UE further includes:
接收模块,用于接收所述第二UE发送的第二请求消息,所述第二请求消息用于向所述第一UE请求获取第二公网IP地址和第二公网端口,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址,所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号;a receiving module, configured to receive a second request message sent by the second UE, where the second request message is used to request, by the first UE, to acquire a second public network IP address and a second public network port, where The second public network IP address is the public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the second UE in the a public network port number used by the network communication path to communicate with the first UE;
所述发送模块,还用于向所述第二UE发送第二响应消息,所述第二响应消息中包括:所述第二公网IP地址及端口号和所述第二公网端口号。The sending module is further configured to send a second response message to the second UE, where the second response message includes: the second public network IP address and port number and the second public network port number.
结合第五方面,在第五方面的第四种可能的实现方式中,所述获取模块具体用于:With reference to the fifth aspect, in a fourth possible implementation manner of the fifth aspect, the acquiring module is specifically configured to:
向所述第二UE发送第一直接通信请求消息,所述第一直接通信请求消息中还包括:第二公网IP地址和第二公网端口号,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址,所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号;Sending a first direct communication request message to the second UE, where the first direct communication request message further includes: a second public network IP address and a second public network port number, where the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, where the second public network port number is the second UE in the network communication path and the a public network port number used by the first UE communication;
接收所述第二UE返回的第一直接通信响应消息,所述第一直接通信响应消息中包括:所述第一公网IP地址和所述第一公网端口号。And receiving, by the second UE, the first direct communication response message, where the first direct communication response message includes: the first public network IP address and the first public network port number.
结合第五方面第四种可能的实现方式,在第五方面的第五种可能的实现方式中,所述切换指示信息携带在所述第一直接通信请求消息中。With reference to the fourth possible implementation manner of the fifth aspect, in a fifth possible implementation manner of the fifth aspect, the handover indication information is carried in the first direct communication request message.
结合第五方面,在第五方面的第六种可能的实现方式中,所述发送模块具体用于: With reference to the fifth aspect, in a sixth possible implementation manner of the fifth aspect, the sending module is specifically configured to:
向所述第二UE发送第二直接通信请求消息,所述第二直接通信请求消息中包括所述切换指示信息;Sending, to the second UE, a second direct communication request message, where the second direct communication request message includes the handover indication information;
所述获取模块具体用于:The obtaining module is specifically configured to:
向应用服务器发送第三请求消息,所述第三请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号;Sending a third request message to the application server, where the third request message is used to request to obtain the first public network IP address and the first public network port number;
接收所述应用服务器返回的第三响应消息,所述第三响应消息中包括:所述第一公网IP地址和所述第一公网端口号。Receiving a third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number.
结合第五方面第四种至第六种可能的实现方式中的任意一种,在第五方面的第七种可能的实现方式中,所述第一直接通信请求消息或所述第二直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to any one of the fourth to sixth possible implementation manners of the fifth aspect, in a seventh possible implementation manner of the fifth aspect, the first direct communication request message or the second direct communication The request message further includes application identification information, where the application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
结合第五方面,在第五方面的第八种可能的实现方式中,所述通信模块具体用于:With reference to the fifth aspect, in an eighth possible implementation manner of the fifth aspect, the communications module is specifically configured to:
将所述第一公网IP地址作为发送给所述第二UE的数据包的源IP地址,将所述第一公网端口号作为所述数据包的源端口号,将第二公网IP地址作为所述数据包的目的IP地址,将第二公网端口号作为所述数据包的目的端口号,将所述数据包通过所述直接通信路径发送给所述第二UE,其中,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址,所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号。Using the first public network IP address as the source IP address of the data packet sent to the second UE, using the first public network port number as the source port number of the data packet, and using the second public network IP address The address is used as the destination IP address of the data packet, and the second public network port number is used as the destination port number of the data packet, and the data packet is sent to the second UE by using the direct communication path, where The second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the second UE a public network port number used by the network communication path to communicate with the first UE.
本发明第六方面提供一种第二UE,其特征在于,包括:A sixth aspect of the present invention provides a second UE, including:
接收模块,用于接收第一UE发送的切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;a receiving module, configured to receive, by the first UE, handover indication information, where the handover indication information is used to indicate that the second UE switches a communication path with the first UE from a network communication path to a direct communication path;
获取模块,用于获取第二公网IP地址和第二公网端口号,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址,所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号;An obtaining module, configured to obtain a second public network IP address and a second public network port number, where the second public network IP address is used by the second UE to communicate with the first UE in the network communication path a public network IP address, where the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path;
路径建立模块,用于使用所述第二公网IP地址和所述第二公网端口 号建立所述直接通信路径;a path establishing module, configured to use the second public network IP address and the second public network port Number establishing the direct communication path;
通信模块,用于在所述直接通信路径上与所述第一UE通信。And a communication module, configured to communicate with the first UE on the direct communication path.
结合第六方面,在第六方面的第一种可能的实现方式中,所述获取模块具体用于:With reference to the sixth aspect, in a first possible implementation manner of the sixth aspect, the acquiring module is specifically configured to:
向所述第一UE发送第二请求消息,所述第二请求消息用于向所述第一UE请求获取所述第二公网IP地址和所述第二公网端口号;Sending a second request message to the first UE, where the second request message is used to request the first UE to acquire the second public network IP address and the second public network port number;
接收所述第一UE返回的第二响应消息,所述第二响应消息中包括:所述第二公网IP地址和所述第二公网端口号。And receiving, by the first UE, a second response message, where the second response message includes: the second public network IP address and the second public network port number.
结合第六方面的第一种可能的实现方式,在第六方面的第二种可能的实现方式中,所述接收模块还用于:In conjunction with the first possible implementation of the sixth aspect, in a second possible implementation manner of the sixth aspect, the receiving module is further configured to:
接收所述第一UE发送的第一请求消息,所述第一请求消息中包括所述切换指示信息,所述第一请求消息用于请求获取第一公网IP地址和第一公网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号;And receiving, by the first UE, the first request message, where the first request message includes the handover indication information, where the first request message is used to request to acquire a first public network IP address and a first public network port number. The first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, and the first public network port number is the first a public network port number used by the UE to communicate with the second UE in the network communication path;
根据所述切换指示信息,确定所述第一UE与所述第二UE在所述网络通信路径中使用的所述第一公网IP地址和所述第一公网端口号;Determining, according to the handover indication information, the first public network IP address and the first public network port number used by the first UE and the second UE in the network communication path;
所述第二UE还包括:发送模块,用于将所述第一公网IP地址和所述第一公网端口号携带在第一响应消息中发送给所述第一UE。The second UE further includes: a sending module, configured to send the first public network IP address and the first public network port number to the first UE in a first response message.
结合第六方面的第二种可能的实现方式,在第六方面的第三种可能的实现方式中,所述第一请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to the second possible implementation manner of the sixth aspect, in a third possible implementation manner of the sixth aspect, the first request message further includes application identifier information, where the application identifier information is used to indicate the The second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
结合第六方面,在第六方面的第四种可能的实现方式中,所述获取模块具体用于:With reference to the sixth aspect, in a fourth possible implementation manner of the sixth aspect, the acquiring module is specifically configured to:
接收所述第一UE发送的第一直接通信请求消息,所述第一直接通信请求消息包括所述第二公网IP地址和所述第二公网端口号。Receiving, by the first UE, a first direct communication request message, where the first direct communication request message includes the second public network IP address and the second public network port number.
结合第六方面的第四种可能的实现方式,在第六方面的第五种可能的实现方式中,所述切换指示信息携带在所述第一直接通信请求消息中。With reference to the fourth possible implementation manner of the sixth aspect, in a fifth possible implementation manner of the sixth aspect, the handover indication information is carried in the first direct communication request message.
结合第六方面的第四种或第五种可能的实现方式,在第六方面的第六 种可能的实现方式中,所述第二UE还包括:In conjunction with the fourth or fifth possible implementation of the sixth aspect, the sixth aspect of the sixth aspect In a possible implementation manner, the second UE further includes:
发送模块,用于向所述第一UE返回第一直接通信响应消息,所述第一直接通信响应消息中包括:第一公网IP地址和第一公网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号。a sending module, configured to return a first direct communication response message to the first UE, where the first direct communication response message includes: a first public network IP address and a first public network port number, the first public network The IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, and the first public network port number is the first UE in the network communication path. A public network port number used for communicating with the second UE.
结合第六方面,在第六方面的第七种可能的实现方式中,所述接收模块具体用于:With reference to the sixth aspect, in a seventh possible implementation manner of the sixth aspect, the receiving module is specifically configured to:
接收所述第一UE发送的第二直接通信请求消息,所述第二直接通信请求消息中包括所述切换指示信息;Receiving, by the first UE, a second direct communication request message, where the second direct communication request message includes the handover indication information;
所述获取模块具体用于:The obtaining module is specifically configured to:
向应用服务器发送第四请求消息,所述第四请求消息用于请求获取所述第二公网IP地址和所述第二公网端口号;Sending a fourth request message to the application server, where the fourth request message is used to request to acquire the second public network IP address and the second public network port number;
接收所述应用服务器返回的第四响应消息,所述第四响应消息中包括:所述第二公网IP地址和所述第二公网端口号。Receiving a fourth response message returned by the application server, where the fourth response message includes: the second public network IP address and the second public network port number.
结合第六方面的第四种至第七种可能的实现方式中的任意一种,在第六方面的第八种可能的实现方式中,所述第一直接通信请求消息或所述第二直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to any one of the fourth to seventh possible implementation manners of the sixth aspect, in the eighth possible implementation manner of the sixth aspect, the first direct communication request message or the second direct The communication request message further includes application identification information, where the application identification information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path. .
结合第六方面,在第六方面的第九种可能的实现方式中,所述第二UE在所述直接通信路径上与所述第一UE通信,包括通信模块具体用于:With reference to the sixth aspect, in a ninth possible implementation manner of the sixth aspect, the second UE is in communication with the first UE on the direct communication path, and the communications module is specifically configured to:
将所述第二公网IP地址作为发送给所述第一UE的数据包的源IP地址,将所述第二公网端口号作为所述数据包的源端口号,将第一公网IP地址作为所述数据包的目的IP地址,将第一公网端口号作为所述数据包的目的端口号,将所述数据包通过所述直接通信路径发送给所述第一UE,其中,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号。The second public network IP address is used as a source IP address of the data packet sent to the first UE, and the second public network port number is used as a source port number of the data packet, and the first public network IP is used. The address is used as the destination IP address of the data packet, and the first public network port number is used as the destination port number of the data packet, and the data packet is sent to the first UE by using the direct communication path, where The first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, where the first public network port number is the first UE A public network port number used by the network communication path to communicate with the second UE.
本发明第七方面提供一种第一UE,包括: A seventh aspect of the present invention provides a first UE, including:
发送模块,用于向第二UE发送切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;a sending module, configured to send, to the second UE, the handover indication information, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from a network communication path to a direct communication path;
获取模块,用于获取第一公网IP地址和第一公网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号;An acquiring module, configured to obtain a first public network IP address and a first public network port number, where the first public network IP address is used by the first UE to communicate with the second UE in the network communication path. a public network IP address, where the first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path;
所述获取模块,还用于获取第二私网IP地址和第二私网端口号,所述第二私网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网IP地址,所述第二私网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网端口号;The acquiring module is further configured to obtain a second private network IP address and a second private network port number, where the second private network IP address is the second UE in the network communication path and the first UE a private network IP address used by the communication, where the second private network port number is a private network port number used by the second UE to communicate with the first UE in the network communication path;
路径建立模块,用于使用所述第一公网IP地址、所述第一公网端口号、所述第二私网IP地址和所述第二私网端口号建立所述直接通信路径;a path establishing module, configured to establish the direct communication path by using the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number;
通信模块,用于在所述直接通信路径上与所述第二UE通信。And a communication module, configured to communicate with the second UE on the direct communication path.
结合第七方面,在第七方面的第一种可能的实现方式中,所述路径建立模块具体用于:With reference to the seventh aspect, in a first possible implementation manner of the seventh aspect, the path establishing module is specifically configured to:
建立所述第一公网IP地址、所述第一公网端口号与第一私网IP地址、第一私网端口号的第一对应关系,以及第二公网IP地址、第二公网端口号与所述第二私网IP地址、所述第二私网端口号的第二对应关系,其中,所述第一私网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网IP地址,所述第一私网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网端口号,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址、所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号。Establishing a first correspondence between the first public network IP address, the first public network port number, the first private network IP address, and the first private network port number, and the second public network IP address and the second public network a second corresponding relationship between the port number and the second private network IP address and the second private network port number, wherein the first private network IP address is the first UE in the network communication path a private network IP address used by the second UE to communicate, where the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path, The second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the second UE A public network port number used to communicate with the first UE in the network communication path.
结合第七方面的第一种可能的实现方式,在第七方面的第二种可能的实现方式中,所述通信模块具体用于:In conjunction with the first possible implementation of the seventh aspect, in a second possible implementation manner of the seventh aspect, the communications module is specifically configured to:
根据所述第一对应关系将发送给所述第二UE的数据包的源IP地址替换为所述第一公网IP地址,将所述数据包的源端口号替换为所述第一公网端口号,根据所述第二对应关系将所述数据包的目的IP地址替换为所 述第二私网IP地址,将所述数据包的目的端口号替换为所述第二私网端口号,其中,所述数据包的源端口号为所述第一私网端口号,所述数据包的源端口号为所述第一私网端口号,所述数据包的目的IP地址为所述第二公网IP地址,所述数据包的目的端口号为所述第二公网端口号,所述第一UE将所述数据包通过所述直接通信路径发送给所述第二UE;Substituting the source IP address of the data packet sent to the second UE with the first public network IP address according to the first correspondence, and replacing the source port number of the data packet with the first public network a port number, replacing the destination IP address of the data packet with the second correspondence The second private network IP address, the destination port number of the data packet is replaced with the second private network port number, where the source port number of the data packet is the first private network port number, The source port number of the data packet is the first private network port number, the destination IP address of the data packet is the second public network IP address, and the destination port number of the data packet is the second public network port No., the first UE sends the data packet to the second UE by using the direct communication path;
或者,通过所述直接通信路径接收所述第二UE发送的数据包。Or receiving, by the direct communication path, a data packet sent by the second UE.
结合第七方面,在第七方面的第三种可能的实现方式中,所述发送模块具体用于:With reference to the seventh aspect, in a third possible implementation manner of the seventh aspect, the sending module is specifically configured to:
所述第一UE向所述第二UE发送第三直接通信请求消息,所述第三直接通信请求消息中包括:所述切换指示信息;The first UE sends a third direct communication request message to the second UE, where the third direct communication request message includes: the handover indication information;
所述获取模块具体用于:The obtaining module is specifically configured to:
接收所述第二UE返回的第三直接通信响应消息,所述第三直接通信响应消息中包括:所述第一公网IP地址和所述第一公网端口号;And receiving, by the second UE, a third direct communication response message, where the third direct communication response message includes: the first public network IP address and the first public network port number;
所述第三直接通信响应消息中还包括:所述第二私网IP地址和所述第二私网端口号,从所述第三直接通信响应消息中获取所述第二私网IP地址和所述第二私网端口号。The third direct communication response message further includes: the second private network IP address and the second private network port number, obtaining the second private network IP address from the third direct communication response message, and The second private network port number.
结合第七方面,在第七方面的第四种可能的实现方式中,所述发送模块具体用于:With reference to the seventh aspect, in a fourth possible implementation manner of the seventh aspect, the sending module is specifically configured to:
向所述第二UE发送第四直接通信请求消息,所述第四直接通信请求消息中包括:所述切换指示信息;Sending a fourth direct communication request message to the second UE, where the fourth direct communication request message includes: the handover indication information;
所述获取模块获取所述第一公网IP地址和所述第一公网端口号,包括:The acquiring module acquires the first public network IP address and the first public network port number, including:
向应用服务器发送第三请求消息,所述第三请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号;Sending a third request message to the application server, where the third request message is used to request to obtain the first public network IP address and the first public network port number;
接收所述应用服务器返回的第三响应消息,所述第三响应消息中包括:所述第一公网IP地址和所述第一公网端口号;Receiving a third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number;
所述获取模块获取所述第二私网IP地址和所述第二私网端口号,包括:The acquiring module acquires the second private network IP address and the second private network port number, including:
接收所述第二UE返回的第四直接通信响应消息,所述第四直接通信响应消息中包括:所述第二私网IP地址和所述第二私网端口号。 And receiving, by the second UE, a fourth direct communication response message, where the fourth direct communication response message includes: the second private network IP address and the second private network port number.
结合第七方面的第三种可能的实现方式,在第七方面的第五种可能的实现方式中,所述第三直接通信请求消息中还包括:第一私网IP地址和第一私网端口号、第二公网IP地址和第二公网端口号,所述第一私网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网IP地址,所述第一私网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网端口号,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址、所述第二公网端口号为所述第二UE在所述网络通信路径中所述第一UE通信所使用的公网端口号。With reference to the third possible implementation manner of the seventh aspect, in a fifth possible implementation manner of the seventh aspect, the third direct communication request message further includes: a first private network IP address and a first private network a port number, a second public network IP address, and a second public network port number, where the first private network IP address is a private network used by the first UE to communicate with the second UE in the network communication path. An IP address, where the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path, and the second public network IP address is the a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the first UE in the network communication path. The public network port number used by the UE for communication.
结合第七方面的第四种可能的实现方式,在第七方面的第六种可能的实现方式中,所述第四直接通信请求消息中还包括:第一私网IP地址和第一私网端口号,所述第一私网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网IP地址,所述第一私网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网端口号。With reference to the fourth possible implementation manner of the seventh aspect, in a sixth possible implementation manner of the seventh aspect, the fourth direct communication request message further includes: a first private network IP address and a first private network a port number, where the first private network IP address is a private network IP address used by the first UE to communicate with the second UE in the network communication path, where the first private network port number is A private network port number used by the first UE to communicate with the second UE in the network communication path.
结合第七方面的第五种或第六种可能的实现方式,在第七方面的第七种可能的实现方式中,所述第三直接通信请求消息或所述第四直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to the fifth or the sixth possible implementation manner of the seventh aspect, in a seventh possible implementation manner of the seventh aspect, the third direct communication request message or the fourth direct communication request message is further The application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
本发明第八方面提供一种第二UE,包括:An eighth aspect of the present invention provides a second UE, including:
接收模块,用于接收第一UE发送的切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;a receiving module, configured to receive, by the first UE, handover indication information, where the handover indication information is used to indicate that the second UE switches a communication path with the first UE from a network communication path to a direct communication path;
获取模块,用于获取第二公网IP地址和第二公网端口号,所述第二公网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网IP地址,所述第二公网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的公网端口号;An obtaining module, configured to obtain a second public network IP address and a second public network port number, where the second public network IP address is used by the second UE to communicate with the first UE in the network communication path a public network IP address, where the second public network port number is a public network port number used by the second UE to communicate with the first UE in the network communication path;
所述获取模块,还用于获取第一私网IP地址和第一私网端口号,所述第一私网IP地址为所述第一UE在所述网络通信路径中与所述第二UE 通信所使用的私网IP地址,所述第一私网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的私网端口号;The acquiring module is further configured to obtain a first private network IP address and a first private network port number, where the first private network IP address is the first UE in the network communication path and the second UE a private network IP address used by the communication, where the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path;
路径建立模块,用于使用所述第二公网IP地址、所述第二公网端口号、所述第一私网IP地址和所述第一私网端口建立所述直接通信路径;a path establishing module, configured to establish the direct communication path by using the second public network IP address, the second public network port number, the first private network IP address, and the first private network port;
通信模块,用于在所述直接通信路径上与所述第一UE通信。And a communication module, configured to communicate with the first UE on the direct communication path.
结合第八方面,在第八方面的第一种可能的实现方式中,所述路径建立模块具体用于:In conjunction with the eighth aspect, in a first possible implementation manner of the eighth aspect, the path establishing module is specifically configured to:
建立所述第二公网IP地址、所述第二公网端口号与第二私网IP地址、第二私网端口号的第一对应关系,以及第一公网IP地址、第一公网端口号与所述第一私网IP地址、所述第一私网端口号的第二对应关系,其中,所述第二私网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网IP地址,所述第二私网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号。Establishing a first correspondence between the second public network IP address, the second public network port number, the second private network IP address, and the second private network port number, and the first public network IP address and the first public network a second corresponding relationship between the port number and the first private network IP address and the first private network port number, where the second private network IP address is the second UE in the network communication path The private network IP address used by the first UE to communicate, and the second private network port number is a private network port number used by the second UE to communicate with the first UE in the network communication path, The first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, and the first public network port number is the first UE A public network port number used to communicate with the second UE in the network communication path.
结合第八方面的第一种可能的实现方式,在第八方面的第二种可能的实现方式中,所述通信模块具体用于:With reference to the first possible implementation of the eighth aspect, in a second possible implementation manner of the eighth aspect, the communications module is specifically configured to:
根据所述第一对应关系将发送给所述第一UE的数据包的源IP地址替换为所述第二公网IP地址,将所述数据包的源端口号替换为所述第二公网端口号,根据所述第二对应关系将所述数据包的目的IP地址替换为所述第一私网IP地址,将所述数据包的目的端口号替换为所述第一私网端口号,其中,所述数据包的源端口号为所述第二私网端口号,所述数据包的源端口号为所述第二私网端口号,所述数据包的目的IP地址为所述第一公网IP地址,所述数据包的目的端口号为所述第一公网端口号,所述第二UE将替换后的数据包通过所述直接通信路径发送给所述第一UE;Substituting the source IP address of the data packet sent to the first UE with the second public network IP address according to the first correspondence, and replacing the source port number of the data packet with the second public network And replacing, by the second correspondence, the destination IP address of the data packet with the first private network IP address, and replacing the destination port number of the data packet with the first private network port number, The source port number of the data packet is the second private network port number, the source port number of the data packet is the second private network port number, and the destination IP address of the data packet is the first a public network IP address, the destination port number of the data packet is the first public network port number, and the second UE sends the replaced data packet to the first UE by using the direct communication path;
或者,通过所述直接通信路径接收所述第一UE发送的数据包。Or receiving, by the direct communication path, a data packet sent by the first UE.
结合第八方面的第一种可能的实现方式,在第八方面的第三种可能的实现方式中,所述接收模块具体用于:In conjunction with the first possible implementation of the eighth aspect, in a third possible implementation manner of the eighth aspect, the receiving module is specifically configured to:
接收所述第一UE发送的第三直接通信请求消息,所述第三直接通信 请求消息中包括:所述切换指示信息;Receiving a third direct communication request message sent by the first UE, the third direct communication The request message includes: the switching indication information;
所述获取模块具体用于:The obtaining module is specifically configured to:
所述第三直接通信请求消息中还包括所述第二公网IP地址和所述第二公网端口号,从所述第三直接通信请求消息中获取所述第二公网IP地址和所述第二公网端口号;The third direct communication request message further includes the second public network IP address and the second public network port number, and the second public network IP address and the location are obtained from the third direct communication request message. Said second public network port number;
所述第三直接通信请求消息中还包括所述第一私网IP地址和所述第一私网端口号,从所述第三直接通信请求消息中获取所述第一私网IP地址和所述第一私网端口号。The third direct communication request message further includes the first private network IP address and the first private network port number, and the first private network IP address and the location are obtained from the third direct communication request message. The first private network port number.
结合第八方面的第一种可能的实现方式,在第八方面的第四种可能的实现方式中,所述接收模块具体用于:With reference to the first possible implementation of the eighth aspect, in a fourth possible implementation manner of the eighth aspect, the receiving module is specifically configured to:
接收所述第一UE发送的第四直接通信请求消息,所述第四直接通信请求消息中包括:所述切换指示信息;And receiving, by the first UE, a fourth direct communication request message, where the fourth direct communication request message includes: the handover indication information;
所述获取模块获取所述第二公网IP地址和所述第二公网端口号,包括:The obtaining module acquires the second public network IP address and the second public network port number, including:
向应用服务器发送第四请求消息,所述第四请求消息用于请求获取所述第二公网IP地址和所述第二公网端口号;Sending a fourth request message to the application server, where the fourth request message is used to request to acquire the second public network IP address and the second public network port number;
接收所述应用服务器返回的第四响应消息,所述第四响应消息中包括所述第二公网IP地址和所述第二公网端口号;Receiving a fourth response message returned by the application server, where the fourth response message includes the second public network IP address and the second public network port number;
所述获取模块获取所述第一私网IP地址和所述第一私网端口号,包括:The acquiring module acquires the first private network IP address and the first private network port number, including:
所述第四直接通信请求消息中还包括所述第一私网IP地址和所述第一私网端口号,所述获取模块从所述第四直接通信请求消息中获取所述第一私网IP地址和所述第一私网端口号。The fourth direct communication request message further includes the first private network IP address and the first private network port number, and the obtaining module acquires the first private network from the fourth direct communication request message. The IP address and the first private network port number.
结合第八方面的第三种可能的实现方式,在第八方面的第五种可能的实现方式中,所述第二UE还包括:In conjunction with the third possible implementation of the eighth aspect, in a fifth possible implementation manner of the eighth aspect, the second UE further includes:
发送模块,用于向所述第一UE返回第三直接通信响应消息,所述第三直接通信响应消息中包括第一公网IP地址、第一公网端口号、第二私网IP地址和第二私网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使 用的公网端口号,所述第二私网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网IP地址,所述第二私网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网端口号。a sending module, configured to return a third direct communication response message to the first UE, where the third direct communication response message includes a first public network IP address, a first public network port number, and a second private network IP address, and a second private network port number, where the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, and the first public network port Number that the first UE communicates with the second UE in the network communication path a public network port number used, the second private network IP address being a private network IP address used by the second UE to communicate with the first UE in the network communication path, and the second private network port The number is a private network port number used by the second UE to communicate with the first UE in the network communication path.
结合第八方面的第四种可能的实现方式,在第八方面的第六种可能的实现方式中,所述第二UE还包括:In conjunction with the fourth possible implementation of the eighth aspect, in a sixth possible implementation of the eighth aspect, the second UE further includes:
发送模块,用于向所述第一UE返回第四直接通信响应消息,所述第四直接通信响应消息中包括第二私网IP地址和第二私网端口号,所述第二私网IP地址为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网IP地址,所述第二私网端口号为所述第二UE在所述网络通信路径中与所述第一UE通信所使用的私网端口号。a sending module, configured to return a fourth direct communication response message to the first UE, where the fourth direct communication response message includes a second private network IP address and a second private network port number, and the second private network IP address The address is a private network IP address used by the second UE to communicate with the first UE in the network communication path, and the second private network port number is the second UE in the network communication path. The private network port number used to communicate with the first UE.
结合第八方面的第五种或第六种可能的实现方式,在第八方面的第七种可能的实现方式中,所述第三直接通信请求消息或所述第四直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。With reference to the fifth or the sixth possible implementation manner of the eighth aspect, in a seventh possible implementation manner of the eighth aspect, the third direct communication request message or the fourth direct communication request message is further The application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
本发明第九方面提供一种第一UE,所述第一UE包括:处理器、存储器、通信接口和系统总线,所述存储器和所述通信接口通过所述系统总线与所述处理器连接并通信;A ninth aspect of the present invention provides a first UE, where the first UE includes: a processor, a memory, a communication interface, and a system bus, where the memory and the communication interface are connected to the processor through the system bus Communication
所述存储器,用于存储计算机执行指令;The memory is configured to store a computer execution instruction;
所述处理器,用于运行所述计算机执行指令,执行如本发明第一方面以及第一方面的第一种至第八种任一所述的方法。The processor, configured to execute the computer to execute instructions, to perform the method of any one of the first to eighth aspects of the first aspect of the invention.
本发明第十方面提供一种第二UE,所述第二UE包括:处理器、存储器、通信接口和系统总线,所述存储器和所述通信接口通过所述系统总线与所述处理器连接并通信;A tenth aspect of the present invention provides a second UE, where the second UE includes: a processor, a memory, a communication interface, and a system bus, where the memory and the communication interface are connected to the processor through the system bus Communication
所述存储器,用于存储计算机执行指令;The memory is configured to store a computer execution instruction;
所述处理器,用于运行所述计算机执行指令,执行如本发明第二方面以及第二方面的第一种至第九种任一所述的方法。The processor, configured to execute the computer-executed instructions, to perform the method of any one of the first to ninth aspects of the second aspect of the present invention.
本发明第十一方面提供一种第一UE,所述第一UE包括:处理器、存储器、通信接口和系统总线,所述存储器和所述通信接口通过所述系统 总线与所述处理器连接并通信;An eleventh aspect of the present invention provides a first UE, where the first UE includes: a processor, a memory, a communication interface, and a system bus, and the memory and the communication interface pass the system a bus is connected to and communicates with the processor;
所述存储器,用于存储计算机执行指令;The memory is configured to store a computer execution instruction;
所述处理器,用于运行所述计算机执行指令,执行如本发明第三方面以及第三方面的第一种至第七种任一所述的方法。The processor, configured to execute the computer-executed instructions, to perform the method of any one of the first to seventh aspects of the third aspect and the third aspect of the present invention.
本发明第十二方面提供一种第二UE,所述第二UE包括:处理器、存储器、通信接口和系统总线,所述存储器和所述通信接口通过所述系统总线与所述处理器连接并通信;A twelfth aspect of the present invention provides a second UE, where the second UE includes: a processor, a memory, a communication interface, and a system bus, where the memory and the communication interface are connected to the processor through the system bus And communicate;
所述存储器,用于存储计算机执行指令;The memory is configured to store a computer execution instruction;
所述处理器,用于运行所述计算机执行指令,执行如本发明第四方面以及第二方面的第一种至第七种任一所述的方法。The processor, configured to execute the computer-executed instructions, to perform the method of any one of the first to seventh aspects of the fourth aspect of the present invention and the second aspect.
本发明实施例提供的网络通信和直接通信之间的切换方法和装置,第一UE通过向第二UE发送切换指示信息,以指示第二UE将与第一UE之间的通信路径从网络通信路径切换到直接通信路径,并获取第一公网IP地址和第一公网端口号,使用第一公网IP地址和第一公网端口号建立直接通信路径。所述方法中,在通信路径切换后,第二UE接收到的第一UE发送的数据包没有变化,在第二UE看来第一UE的IP地址和端口号并没有变化,从而保证用户的业务不中断。The method and device for switching between network communication and direct communication provided by the embodiment of the present invention, the first UE sends the handover indication information to the second UE to indicate that the second UE communicates with the communication path of the first UE from the network. The path is switched to the direct communication path, and the first public network IP address and the first public network port number are obtained, and the first public network IP address and the first public network port number are used to establish a direct communication path. In the method, after the communication path is switched, the data packet sent by the first UE received by the second UE does not change, and the IP address and the port number of the first UE do not change in the second UE, thereby ensuring the user's Business is not interrupted.
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description of the drawings used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any inventive labor.
图1为本发明实施例一提供的网络通信和直接通信之间的切换方法的流程图;1 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 1 of the present invention;
图2为本发明实施例二提供的网络通信和直接通信之间的切换方法的流程图;2 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 2 of the present invention;
图3为本发明实施例三提供的网络通信和直接通信之间的切换方法的信令流程图; 3 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 3 of the present invention;
图4为本发明实施例四提供的网络通信和直接通信之间的切换方法的信令流程图;4 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 4 of the present invention;
图5为本发明实施例五提供的网络通信和直接通信之间的切换方法的信令流程图;5 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 5 of the present invention;
图6为本发明实施例六提供的网络通信和直接通信之间的切换方法的信令流程图;6 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 6 of the present invention;
图7为本发明实施例七提供的网络通信和直接通信之间的切换方法的流程图;7 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 7 of the present invention;
图8为本发明实施例八提供的网络通信和直接通信之间的切换方法的流程图;8 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 8 of the present invention;
图9为本发明实施例九提供的网络通信和直接通信之间的切换方法的信令流程图;9 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 9 of the present invention;
图10为本发明实施例十提供的第一UE的结构示意图;FIG. 10 is a schematic structural diagram of a first UE according to Embodiment 10 of the present invention;
图11为本发明实施例十一提供的第二UE的结构示意图;FIG. 11 is a schematic structural diagram of a second UE according to
图12为本发明实施例十二提供的第一UE的结构示意图;FIG. 12 is a schematic structural diagram of a first UE according to
图13为本发明实施例十三提供的第二UE的结构示意图;FIG. 13 is a schematic structural diagram of a second UE according to
图14为本发明实施例十四提供的第一UE的结构示意图;FIG. 14 is a schematic structural diagram of a first UE according to
图15为本发明实施例十五提供的第二UE的结构示意图;FIG. 15 is a schematic structural diagram of a second UE according to Embodiment 15 of the present invention;
图16为本发明实施例十六提供的第一UE的结构示意图;FIG. 16 is a schematic structural diagram of a first UE according to Embodiment 16 of the present invention;
图17为本发明实施例十七提供的第二UE的结构示意图。FIG. 17 is a schematic structural diagram of a second UE according to Embodiment 17 of the present invention.
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
现有技术中,UE通过网络通信路径传输数据,以第一UE和第二UE之间的通信为例,若第一UE要向第二UE发送数据,第一UE发送的数据包的源IP地址为自己的私有IP地址、源端口号为自己的私有端口号, 目的IP地址为UE2的公网IP地址、目的端口号为UE2的公网端口号。由于私网IP地址不能在因特网(Internet)进行路由,因此,在发送端的路由器上需要进行网络地址转换(Network Address Translation,简称NAT),将UE1的私网IP地址转化为公网IP地址,将UE1的私网端口号转换为公网端口号,进行NAT的路由器也称为NAT服务器,NAT服务器可以为一个单独的路由器,也可以集成在P-GW上。经过NAT服务器转换后的数据包被发往Internet上进行传输,在接收端,接收端的NAT服务器接收到数据包后,将数据包的目的IP地址转换为UE2的私网IP地址,将数据包的目的端口号转换为UE2的私网端口号,然后,将转换后的数据包发送给UE2,最终UE2收到的数据包的源IP地址为UE1的公网IP地址,源端口号为UE1的公网端口号,目的IP地址为UE2的私网IP地址,目的端口号为UE2的私网端口号。In the prior art, the UE transmits data through the network communication path, taking the communication between the first UE and the second UE as an example. If the first UE is to send data to the second UE, the source IP address of the data packet sent by the first UE. The address is its own private IP address, and the source port number is its own private port number. The destination IP address is the public network IP address of UE2 and the destination port number is the public network port number of UE2. The IP address of the private network cannot be routed over the Internet. Therefore, the network address translation (NAT) of the UE is required to be translated into the public IP address of the UE1. The private network port number of UE1 is converted to the public network port number. The router that performs NAT is also called a NAT server. The NAT server can be a single router or integrated on the P-GW. The data packet converted by the NAT server is sent to the Internet for transmission. At the receiving end, after receiving the data packet, the receiving terminal's NAT server converts the destination IP address of the data packet into the private network IP address of UE2, and the data packet is The destination port number is converted to the private network port number of the UE2, and then the converted data packet is sent to the UE2. The source IP address of the data packet received by the UE2 is the public network IP address of the UE1, and the source port number is the public address of the UE1. The network port number, the destination IP address is the private network IP address of UE2, and the destination port number is the private network port number of UE2.
UE1发送的数据包在Internet上传输时,会经过eNB、P-GW、S-GW等,传输效率低,网络时延大。为了解决该问题,可以使用直接通信路径进行通信,直接通信路径即UE1和UE2之间直接相连的路径,UE1和UE2使用直接通信路径进行通信时,数据包不需要经过任何网络实体,从而降低了数据包传输的时延,提高了传输效率。When the data packet sent by UE1 is transmitted on the Internet, it will pass through the eNB, P-GW, S-GW, etc., and the transmission efficiency is low, and the network delay is large. In order to solve this problem, a direct communication path can be used for communication. The direct communication path is a path directly connected between UE1 and UE2. When UE1 and UE2 communicate using a direct communication path, the data packet does not need to pass through any network entity, thereby reducing the number of packets. The delay of packet transmission improves the transmission efficiency.
现有技术中,当UE1和UE2要将传输路径从网络通信路径切换到直接通信路径上时,UE1和UE2需要先中断网络直接通信路径,然后,再建立直接通信路径,UE1和UE2在直接通信路径上使用的IP地址和在网络通信路径上使用的IP地址不同,由于IP地址变换了,从而导致业务不连续。In the prior art, when UE1 and UE2 want to switch the transmission path from the network communication path to the direct communication path, UE1 and UE2 need to interrupt the network direct communication path first, and then establish a direct communication path, and UE1 and UE2 are in direct communication. The IP address used on the path is different from the IP address used on the network communication path. As the IP address is changed, the service is not continuous.
图1为本发明实施例一提供的网络通信和直接通信之间的切换方法的流程图,如图1所示,本实施例的方法可以包括以下步骤:FIG. 1 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 1 of the present invention. As shown in FIG. 1 , the method in this embodiment may include the following steps:
步骤101、第一UE向第二UE发送切换指示信息,该切换指示信息用于指示第二UE将与第一UE之间的通信路径从网络通信路径切换到直接通信路径。Step 101: The first UE sends handover indication information to the second UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path.
本实施例中,网络通信路径为第一UE和第二UE之间的网络通信路径,第一UE要从网络通信路径切换到直接通信路径,本实施例的前提是第一UE与第二UE已经建立了网络通信路径,此处网络通信路径可以是LTE 网络通信路径,第一UE和第二UE建立网络通信路径为现有技术这里不做过多描述。当第一UE和第二UE距离较近时,第一UE和第二UE之间可以建立直接通信路径,当第一UE和第二UE通过该直接通信路径通信时,数据包不需要经过LTE核心网的传递,可以节省网络资源,并且能够减少第一UE和第二UE之间的通信时延。In this embodiment, the network communication path is a network communication path between the first UE and the second UE, and the first UE is to be switched from the network communication path to the direct communication path, and the premise of the embodiment is the first UE and the second UE. A network communication path has been established, where the network communication path can be LTE The network communication path, the first UE and the second UE establish a network communication path as the prior art is not described too much here. When the first UE and the second UE are relatively close, a direct communication path may be established between the first UE and the second UE, and when the first UE and the second UE communicate through the direct communication path, the data packet does not need to pass through the LTE. The delivery of the core network can save network resources and can reduce the communication delay between the first UE and the second UE.
步骤102、第一UE获取第一公网互联网协议(Internet Protocol,简称IP)地址和第一公网端口号。Step 102: The first UE acquires a first public network (Internet Protocol, IP address) address and a first public network port number.
本实施例以及以下实施例中,第一公网IP地址为第一UE在网络通信路径中与第二UE通信所使用的公网IP地址,第一公网端口号为第一UE在网络通信路径中与第二UE通信所使用的公网端口号,第二公网IP地址为第二UE在网络通信路径中与第一UE通信所使用的公网IP地址,第二公网端口号为第二UE在网络通信路径中与第一UE通信所使用的公网端口号。第一UE和第二UE各自知道自己的私网IP地址和私网端口号,以及对方的公网IP地址和公网端口号。In this embodiment and the following embodiments, the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path, and the first public network port number is the first UE in the network communication. a public network port number used by the second UE to communicate with the second UE in the path, where the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is The public network port number used by the second UE to communicate with the first UE in the network communication path. The first UE and the second UE each know their own private network IP address and private network port number, as well as the public network IP address and public network port number of the other party.
本实施例以及以下实施例中,第二公网IP地址为第二UE在网络通信路径中与第一UE通信所使用的公网IP地址,第二公网端口号为第二UE在网络通信路径中与第一UE通信所使用的公网端口号,第一私网IP地址为第一UE在网络通信路径中与第二UE通信所使用的私网IP地址,第一私网端口号为第一UE在网络通信路径中与第二UE通信所使用的私网端口号,第二私网IP地址为第二UE在网络通信路径中与第一UE通信所使用的私网IP地址,第二私网端口号为第二UE在网络通信路径中与第一UE通信所使用的私网端口号。In this embodiment and the following embodiments, the second public network IP address is a public network IP address used by the second UE to communicate with the first UE in the network communication path, and the second public network port number is the second UE in the network communication. a public network port number used by the first UE to communicate with the first UE in the path, where the first private network IP address is a private network IP address used by the first UE to communicate with the second UE in the network communication path, where the first private network port number is a private network port number used by the first UE to communicate with the second UE in the network communication path, where the second private network IP address is a private network IP address used by the second UE to communicate with the first UE in the network communication path, The second private network port number is a private network port number used by the second UE to communicate with the first UE in the network communication path.
本实施例中,第一UE建立直接通信路径,需要先获取第一公网IP地址和第一公网端口号,第一UE具体可以通过如下三种方式获取第一公网IP地址和第一公网端口号:In this embodiment, the first UE establishes a direct communication path, and needs to obtain the first public network IP address and the first public network port number. The first UE may obtain the first public network IP address and the first manner by using the following three manners. Public network port number:
(1)第一UE向第二UE发送第一请求消息,第一请求消息用于请求获取第一公网IP地址和第一公网端口号,第二UE根据第一请求消息向第一UE返回第一响应消息。第一UE接收第二UE返回的第一响应消息,该第一响应消息中包括:第一公网IP地址和第一公网端口号。(1) The first UE sends a first request message to the second UE, where the first request message is used to request to acquire the first public network IP address and the first public network port number, and the second UE sends the first request message to the first UE according to the first request message. Returns the first response message. The first UE receives the first response message returned by the second UE, where the first response message includes: a first public network IP address and a first public network port number.
当第一UE通过第一请求消息获取第一公网IP地址和第一公网端口号 时,可选的,第一请求消息中还可以携带切换指示信息。当然,第一切换指示信息还可以携带在其他消息中,本实施例并不对此进行限制。When the first UE obtains the first public network IP address and the first public network port number by using the first request message Optionally, the first request message may further carry the handover indication information. Of course, the first handover indication information may also be carried in other messages, which is not limited in this embodiment.
可选的,第一请求消息还包括应用标识信息,该应用标识信息用于指示第二UE将该应用标识对应的应用下与第一UE的通信路径从网络通信路径切换到直接通信路径,该应用标识信息可以为应用标识(Application Identity,简称APP ID)。当第一UE和第二UE之间具有多个应用时,第一UE可能会为每个应用建立一条直接通信路径,为了区分各个应用的直接通信路径,第一请求消息中需要携带每个应用的应用标识信息,以指示第二UE建立直接通信路径属于哪个应用。当第一UE和第二UE之间只有一个应用时,可选的,第一请求消息中可以不携带该应用的应用标识信息。Optionally, the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE switches the communication path of the application corresponding to the application identifier from the network communication path to the direct communication path. The application identifier information may be an application identifier (APP ID). When there are multiple applications between the first UE and the second UE, the first UE may establish a direct communication path for each application. In order to distinguish the direct communication path of each application, each application needs to be carried in the first request message. Application identification information to indicate to the second UE which application the direct communication path belongs to. When there is only one application between the first UE and the second UE, optionally, the application identifier information of the application may not be carried in the first request message.
(2)第一UE向第二UE发送第一直接通信请求消息,该第一直接通信请求消息中还包括:第二公网IP地址和第二公网端口号。(2) The first UE sends a first direct communication request message to the second UE, where the first direct communication request message further includes: a second public network IP address and a second public network port number.
第二UE根据第一直接通信请求消息向第一UE返回第一直接通信响应消息,第一UE接收第二UE返回的第一直接通信响应消息,该第一直接通信响应消息中包括:第一公网IP地址和第一公网端口号。The second UE returns a first direct communication response message to the first UE according to the first direct communication request message, and the first UE receives the first direct communication response message returned by the second UE, where the first direct communication response message includes: Public network IP address and first public network port number.
当第一UE通过第一直接通信请求消息获取第一公网IP地址和第一公网端口号时,可选的,第一UE可以将切换指示信息携带在第一直接通信请求消息中发送给第二UE,当然,切换指示信息还可以携带在其他消息中。When the first UE obtains the first public network IP address and the first public network port number by using the first direct communication request message, the first UE may send the handover indication information in the first direct communication request message to the first UE. The second UE, of course, the handover indication information can also be carried in other messages.
(3)第一UE向应用服务器发送第三请求消息,该第三请求消息用于请求获取第一公网IP地址和第一公网端口号。应用服务器为服务第一UE和第二UE通信的服务器,应用服务器中保存有第一公网IP地址、第一公网端口号、第二公网IP地址和第二公网端口号等。应用服务器收到第一UE发送的第三请求消息后,根据第三请求消息向第一UE返回第三响应消息,第一UE接收应用服务器返回的第三响应消息,第三响应消息中包括:第一公网IP地址和第一公网端口号。(3) The first UE sends a third request message to the application server, where the third request message is used to request to acquire the first public network IP address and the first public network port number. The application server is a server that serves communication between the first UE and the second UE. The application server stores the first public network IP address, the first public network port number, the second public network IP address, and the second public network port number. After receiving the third request message sent by the first UE, the application server returns a third response message to the first UE according to the third request message, where the first UE receives the third response message returned by the application server, where the third response message includes: The first public network IP address and the first public network port number.
当第一UE通过应用服务器获取第一公网IP地址和第一公网端口号时,可选的,第一UE通过第二直接通信请求消息向第二UE发送切换指示信息,第二直接通信请求消息中包括切换指示信息,当然,第一UE也 可以通过其他消息携带切换指示信息。When the first UE acquires the first public network IP address and the first public network port number through the application server, optionally, the first UE sends the handover indication information to the second UE by using the second direct communication request message, where the second direct communication is performed. The request message includes handover indication information, of course, the first UE also The switching indication information can be carried by other messages.
可选的,在第二种和第三种方式中,第一直接通信请求消息或第二直接通信请求消息中还可以包括应用标识信息。Optionally, in the second and third manners, the first direct communication request message or the second direct communication request message may further include application identification information.
需要说明的是,本实施例中,步骤101和步骤102在执行时并没有先后顺序,也可以同时执行。It should be noted that, in this embodiment,
步骤103、第一UE使用第一公网IP地址和第一公网端口号建立直接通信路径。Step 103: The first UE establishes a direct communication path by using the first public network IP address and the first public network port number.
具体的,第一UE使用第一公网IP地址和第一公网端口号建立底层连接。第一UE还可以生成该直接通信路径对应的数据流模板(Traffic Flow Template,简称TFT),该直接通信路径对应的TFT的匹配信息为:源IP地址为第一公网IP地址,源端口号为第一公网端口号,目的IP地址为第二公网IP地址,目的端口号为第二公网端口号。Specifically, the first UE establishes an underlying connection by using the first public network IP address and the first public network port number. The first UE may also generate a traffic flow template (TFT) corresponding to the direct communication path, where the matching information of the TFT corresponding to the direct communication path is: the source IP address is the first public network IP address, and the source port number is It is the first public network port number, the destination IP address is the second public network IP address, and the destination port number is the second public network port number.
第一UE使用第一公网IP地址和第一公网端口号建立直接通信路径之前,第一UE还接收第二UE发送的第二请求消息,第二请求消息用于向第一UE请求获取第二公网IP地址和第二公网端口;第一UE向第二UE发送第二响应消息,第二响应消息中包括:第二公网IP地址及端口号和第二公网端口号。Before the first UE establishes a direct communication path by using the first public network IP address and the first public network port number, the first UE further receives a second request message sent by the second UE, where the second request message is used to request acquisition from the first UE. a second public network IP address and a second public network port; the first UE sends a second response message to the second UE, where the second response message includes: a second public network IP address and a port number, and a second public network port number.
步骤104、第一UE在直接通信路径上与第二UE通信。Step 104: The first UE communicates with the second UE on a direct communication path.
具体的,第一UE将第一公网IP地址作为发送给第二UE的数据包的源IP地址,将第一公网端口号作为该数据包的源端口号,将第二公网IP地址作为该数据包的目的IP地址,将第二公网端口号作为该数据包的目的端口号,将该数据包通过直接通信路径发送给第二UE。若第一UE生成了TFT,则第一UE根据TFT将发送给第二UE的数据包匹配到对应的直接通信路径上。Specifically, the first UE uses the first public network IP address as the source IP address of the data packet sent to the second UE, the first public network port number as the source port number of the data packet, and the second public network IP address. As the destination IP address of the data packet, the second public network port number is used as the destination port number of the data packet, and the data packet is sent to the second UE through the direct communication path. If the first UE generates the TFT, the first UE matches the data packet sent to the second UE to the corresponding direct communication path according to the TFT.
本实施例中,第一UE在直接通信路径对应的TFT与网络通信路径对应的TFT不同,网络通信路径对应的TFT的源IP地址为第一私网IP地址,源端口号为第一私网端口号,直接通信路径对应的TFT的源IP地址为第一公网IP地址,源端口号为第一公网端口号,第一UE在两种通信路径上传输数据使用的TFT的目的IP地址和目的端口号没有变化,都为第二公网IP地址和第二公网端口号。 In this embodiment, the TFT corresponding to the direct communication path is different from the TFT corresponding to the network communication path, and the source IP address of the TFT corresponding to the network communication path is the first private network IP address, and the source port number is the first private network. Port number, the source IP address of the TFT corresponding to the direct communication path is the first public network IP address, the source port number is the first public network port number, and the destination IP address of the TFT used by the first UE to transmit data on the two communication paths The destination port number does not change. Both are the second public network IP address and the second public network port number.
本实施例中,第二UE接收到的第一UE通过直接通信路径发送的数据包的源IP地址为第一UE的公网IP地址、源端口号为第一UE的公网端口号,目的IP地址为第二UE的公网IP地址,目的IP地址为第二UE的公网端口号。可知,第二UE接收到的第一UE通过两种通信路径发送的数据包的源地址及源端口号相同,因此,在第二UE看来第一UE的IP地址和端口号并没有变化,从而保证用户的业务不中断。In this embodiment, the source IP address of the data packet sent by the first UE through the direct communication path is the public network IP address of the first UE, and the source port number is the public network port number of the first UE. The IP address is the public network IP address of the second UE, and the destination IP address is the public network port number of the second UE. It can be seen that the source address and the source port number of the data packet sent by the first UE through the two communication paths are the same. Therefore, the IP address and the port number of the first UE do not change in the second UE. Thereby ensuring that the user's business is not interrupted.
本实施例中,第一UE向第二UE发送切换指示信息,以指示第二UE将与第一UE之间的通信路径从网络通信路径切换到直接通信路径,并获取第一公网IP地址和第一公网端口号,使用第一公网IP地址和第一公网端口号建立直接通信路径。所述方法中,在通信路径切换后,第二UE接收到的第一UE发送的数据包没有变化,在第二UE看来第一UE的IP地址和端口号并没有变化,从而保证用户的业务不中断。In this embodiment, the first UE sends the handover indication information to the second UE, to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path, and obtains the first public network IP address. And the first public network port number, using the first public network IP address and the first public network port number to establish a direct communication path. In the method, after the communication path is switched, the data packet sent by the first UE received by the second UE does not change, and the IP address and the port number of the first UE do not change in the second UE, thereby ensuring the user's Business is not interrupted.
图2为本发明实施例二提供的网络通信和直接通信之间的切换方法的流程图,如图2所示,本实施例提供的方法可以包括以下步骤:2 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 2 of the present invention. As shown in FIG. 2, the method provided in this embodiment may include the following steps:
步骤201、第二UE接收第一UE发送的切换指示信息,该切换指示信息用于指示第二UE将与第一UE之间的通信路径从网络通信路径切换到直接通信路径。Step 201: The second UE receives the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path.
步骤202、第二UE获取第二公网IP地址和第二公网端口号。Step 202: The second UE acquires a second public network IP address and a second public network port number.
第二UE具体可以通过如下方式获取第二公网IP地址和第二公网端口号:The second UE may obtain the second public network IP address and the second public network port number by:
(1)第二UE向第一UE发送第二请求消息,第二请求消息用于向第一UE请求获取第二公网IP地址和第二公网端口号。第一UE接收到第二请求消息后,根据第二请求消息向第二UE返回第二响应消息,第二UE接收第一UE返回的第二响应消息,第二响应消息中包括:第二公网IP地址和第二公网端口号。(1) The second UE sends a second request message to the first UE, where the second request message is used to request the first UE to obtain the second public network IP address and the second public network port number. After receiving the second request message, the first UE returns a second response message to the second UE according to the second request message, and the second UE receives the second response message returned by the first UE, where the second response message includes: The network IP address and the second public network port number.
第二UE获取第二公网IP地址和第二公网端口号之前,第二UE还接收第一UE发送的第一请求消息,切换指示信息携带在第一请求消息中。第一请求消息用于请求获取第一公网IP地址和第一公网端口号,第二UE根据切换指示信息,确定第一UE与第二UE在网络通信路径中使用的第一公网IP地址和第一公网端口号;第二UE将第一公网IP地址和第一公 网端口号携带在第一响应消息中发送给第一UE。Before the second UE acquires the second public network IP address and the second public network port number, the second UE further receives the first request message sent by the first UE, where the handover indication information is carried in the first request message. The first request message is used to request to obtain the first public network IP address and the first public network port number, and the second UE determines, according to the handover indication information, the first public network IP used by the first UE and the second UE in the network communication path. Address and the first public network port number; the second UE will be the first public network IP address and the first public The network port number is carried in the first response message and sent to the first UE.
可选的,第一请求消息中还包括应用标识信息,应用标识信息用于指示第二UE将应用标识对应的应用下的通信路径从网络通信路径切换到直接通信路径。第二请求消息中也可以包括该应用标识信息和切换指示信息。Optionally, the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path. The application identification information and the handover indication information may also be included in the second request message.
(2)第二UE接收第一UE发送的第一直接通信请求消息,第一直接通信请求消息包括第二公网IP地址和第二公网端口号。可选的,切换指示信息也可以携带在第一直接通信请求消息中,当然,切换指示信息还可以携带在其他消息中。(2) The second UE receives the first direct communication request message sent by the first UE, where the first direct communication request message includes a second public network IP address and a second public network port number. Optionally, the handover indication information may also be carried in the first direct communication request message. Of course, the handover indication information may also be carried in other messages.
第二UE接收第一UE发送的第一直接通信请求消息之后,第二UE根据第一直接通信请求消息向第一UE返回第一直接通信响应消息,第一直接通信响应消息中包括:第一公网IP地址和第一公网端口号。After the second UE receives the first direct communication request message sent by the first UE, the second UE returns a first direct communication response message to the first UE according to the first direct communication request message, where the first direct communication response message includes: Public network IP address and first public network port number.
(3)第二UE向应用服务器发送第四请求消息,第四请求消息用于请求获取第二公网IP地址和第二公网端口号,应用服务器根据第四请求消息向第二UE返回第四响应消息,第二UE接收应用服务器返回的第四响应消息,第四响应消息中包括:第二公网IP地址和第二公网端口号。(3) The second UE sends a fourth request message to the application server, where the fourth request message is used to request to obtain the second public network IP address and the second public network port number, and the application server returns to the second UE according to the fourth request message. The fourth response message is sent by the second UE to the second UE. The fourth response message includes: a second public network IP address and a second public network port number.
当第二UE通过应用服务器获取第二公网IP地址和第二公网端口号时,可选的,切换指示信息携带在第二直接通信请求消息中,第二UE接收第一UE发送的第二直接通信请求消息,第二直接通信请求消息中包括切换指示信息,当然,切换指示信息还可以携带在其他消息中。When the second UE obtains the second public network IP address and the second public network port number through the application server, optionally, the handover indication information is carried in the second direct communication request message, and the second UE receives the first The second direct communication request message includes the handover indication information. Of course, the handover indication information may also be carried in other messages.
在上述第二种和第三种方式中,可选的,第一直接通信请求消息或第二直接通信请求消息中还包括应用标识信息。第二UE接收第一UE发送的第一直接通信请求消息之后,第二UE还向第一UE返回第一直接通信响应消息,第一直接通信响应消息中包括:第一公网IP地址和第一公网端口号。或者,第二UE接收第一UE发送的第二直接通信请求消息之后,第二UE向第一UE返回第二直接通信响应消息,第二直接通信响应消息中包括:应用标识信息。In the foregoing second and third manners, optionally, the first direct communication request message or the second direct communication request message further includes application identification information. After the second UE receives the first direct communication request message sent by the first UE, the second UE also returns a first direct communication response message to the first UE, where the first direct communication response message includes: a first public network IP address and a first A public network port number. Or, after the second UE receives the second direct communication request message sent by the first UE, the second UE returns a second direct communication response message to the first UE, where the second direct communication response message includes: application identifier information.
需要说明的是,本实施例中,步骤201和步骤202在执行时并没有先后顺序,也可以同时执行。It should be noted that, in this embodiment,
步骤203、第二UE使用第二公网IP地址和第二公网端口号建立直接 通信路径。Step 203: The second UE establishes a direct use of the second public network IP address and the second public network port number. Communication path.
具体的,第二UE使用第二公网IP地址和第二公网端口号建立底层连接。第二UE还可以生成该直接通信路径的TFT,该直接通信路径的TFT的源IP地址为第二公网IP地址,源端口号为第二公网端口号,目的IP地址为第一公网IP地址,目的端口号为第一公网端口号。Specifically, the second UE establishes an underlying connection by using the second public network IP address and the second public network port number. The second UE may also generate a TFT of the direct communication path, where the source IP address of the TFT of the direct communication path is the second public network IP address, the source port number is the second public network port number, and the destination IP address is the first public network. IP address, the destination port number is the first public network port number.
步骤204、第二UE在直接通信路径上与第一UE通信。Step 204: The second UE communicates with the first UE on a direct communication path.
具体的,第二UE将第二公网IP地址作为发送给第一UE的数据包的源IP地址,将第二公网端口号作为该数据包的源端口号,将第一公网IP地址作为该数据包的目的IP地址,将第一公网端口号作为该数据包的目的端口号,将该数据包通过该直接通信路径发送给第一UE。若第二UE生成了直接通信路径对应的TFT,则第二UE根据直接通信路径对应的TFT将发送给第一UE的数据包匹配到直接通信路径上。Specifically, the second UE uses the second public network IP address as the source IP address of the data packet sent to the first UE, and the second public network port number as the source port number of the data packet, and the first public network IP address. As the destination IP address of the data packet, the first public network port number is used as the destination port number of the data packet, and the data packet is sent to the first UE through the direct communication path. If the second UE generates the TFT corresponding to the direct communication path, the second UE matches the data packet sent to the first UE to the direct communication path according to the TFT corresponding to the direct communication path.
第二UE在网络通信路径上传输数据时,第二UE发送数据包的源IP地址为第二私网IP地址,源端口号为第二私网端口号,数据包的源IP地址会被NAT服务器被转换为第二公网IP地址,源端口号会被NAT服务器转换为第二公网端口号,NAT服务器根据转换后的第二公网IP地址和第二公网端口号将数据包发送给第一UE。当数据包在直接通信路径上传输时,不需要经过NAT服务器进行转换。在上述两种通信过程中,第一UE接收到的第二UE通过两种通信路径发送的数据包的源地址及源端口号相同,因此,在第一UE看来第二UE的IP地址和端口号并没有变化,从而保证用户的业务不中断。When the second UE transmits data on the network communication path, the source IP address of the second UE sending the data packet is the second private network IP address, the source port number is the second private network port number, and the source IP address of the data packet is NAT. The server is converted into the second public network IP address, and the source port number is converted into the second public network port number by the NAT server, and the NAT server sends the data packet according to the converted second public network IP address and the second public network port number. Give the first UE. When a packet is transmitted on the direct communication path, it does not need to be converted by the NAT server. In the above two communication processes, the source address and the source port number of the data packet sent by the second UE through the two communication paths are the same, and therefore, the IP address of the second UE is seen by the first UE. The port number does not change, thus ensuring that the user's business is not interrupted.
本实施例中,第二UE接收第一UE发送的切换指示信息,该切换指示信息用于指示第二UE将与第一UE之间的通信路径从网络通信路径切换到直接通信路径,并获取第二公网IP地址和第二公网端口号,使用第二公网IP地址和第二公网端口号建立直接通信路径。所述方法中,在通信路径切换后,第一UE接收到的第二UE发送的数据包没有变化,在第一UE看来第二UE的IP地址和端口号并没有变化,从而保证用户的业务不中断。In this embodiment, the second UE receives the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path, and obtains The second public network IP address and the second public network port number establish a direct communication path by using the second public network IP address and the second public network port number. In the method, after the communication path is switched, the data packet sent by the second UE received by the first UE does not change, and the IP address and the port number of the second UE do not change in the first UE, thereby ensuring the user's Business is not interrupted.
以下将通过几个具体实施例,对实施例一和实施例二的方法进行详细说明。 The methods of Embodiment 1 and Embodiment 2 will be described in detail below through several specific embodiments.
图3为本发明实施例三提供的网络通信和直接通信之间的切换方法的信令流程图,如图3所示,本实施例提供的方法可以包括以下步骤:FIG. 3 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 3 of the present invention. As shown in FIG. 3, the method provided in this embodiment may include the following steps:
步骤301、第一UE和第二UE建立网络通信路径。Step 301: The first UE and the second UE establish a network communication path.
在LTE系统中,网络通信路径即为通过建立PDN连接及承载(bear)传输数据的路径,以第一UE为例,第一UE通过第一eNB与第一核心网建立PDN连接,其中,第一eNB为第一UE的接入设备,第一核心网为第一UE的接入核心网,第一核心网中包括多个节点:移动性管理实体(Mobility Management Entity,简称MME)、服务网关(Serving Gateway,简称SGW)和PGW等。具体地,第一UE通过第一eNB向MME发送PDN连接请求(PDN connectivity request)或附着请求(attach request),MME在收到PDN连接请求或附着请求后,向SGW发送创建会话请求,SGW将创建会话请求发送给PGW,PGW为第一UE分配第一私网IP地址和第一私网端口号。然后,PGW创建会话响应(create session response)消息,会话响应消息中不但包含PGW为第一UE分配的第一私网IP地址和第一私网端口号,还可以包含第一私网IP地址和第一私网端口号对应的第一公网IP地址和第二公网端口号。第二公网IP地址和第二公网端口号也可以通过PDN连接建立过程或attatch过程的其他消息发送至第一UE,第一UE保存第一私网IP地址、第一私网端口号、第二公网IP地址和第二公网端口号,第二UE与第二核心网建立PND连接,第二UE建立PDN连接的过程与第一UE类似。In the LTE system, the network communication path is a path for establishing a PDN connection and a bearer to transmit data, and the first UE is used as an example, and the first UE establishes a PDN connection with the first core network by using the first eNB, where An eNB is an access device of the first UE, and the first core network is an access core network of the first UE, and the first core network includes multiple nodes: a mobility management entity (Mobility Management Entity, MME for short), and a service gateway. (Serving Gateway, SGW for short) and PGW. Specifically, the first UE sends a PDN connectivity request or an attach request to the MME by using the first eNB, and after receiving the PDN connection request or the attach request, the MME sends a create session request to the SGW, and the SGW will The create session request is sent to the PGW, and the PGW allocates the first private network IP address and the first private network port number to the first UE. Then, the PGW creates a session response message, and the session response message includes not only the first private network IP address and the first private network port number allocated by the PGW for the first UE, but also the first private network IP address and The first public network IP address and the second public network port number corresponding to the first private network port number. The second public network IP address and the second public network port number may also be sent to the first UE through the PDN connection establishment process or other messages of the attatch process, where the first UE saves the first private network IP address, the first private network port number, The second public network IP address and the second public network port number, the second UE establishes a PND connection with the second core network, and the process of establishing a PDN connection by the second UE is similar to that of the first UE.
步骤302、第一UE和第二UE通过网络通信路径进行通信。Step 302: The first UE and the second UE communicate through a network communication path.
步骤303、第一UE发起发现过程,确定自己与第二UE是否距离较近。Step 303: The first UE initiates a discovery process, and determines whether it is closer to the second UE.
若第一UE发现自己距离第二UE较近,则第一UE确定从网络通信路径切换到直接通信路径,第一UE如何发现第二UE为现有技术,这里不做过多描述。If the first UE finds that it is closer to the second UE, the first UE determines to switch from the network communication path to the direct communication path, and how the first UE finds the second UE is a prior art, which is not described too much here.
步骤304、第一UE和第二UE在发现过程中互相交换各自的二层标识(layer2ID)。Step 304: The first UE and the second UE exchange their respective Layer 2 IDs (layer2ID) in the discovery process.
可选地,在发现过程中,第一UE也可以获取第二UE的二层标识,但是,第二UE没有获取第一UE的二层标识。若第一UE和第二UE在发 现过程中没有互相交换各自的二层标识,或第一UE没有获取第二UE的二层标识,则第一UE和第二UE还可以通过应用层消息互相交换二层标识,二层标识用于建立直接通信路径上的二层连接。Optionally, in the process of the discovery, the first UE may also acquire the layer 2 identifier of the second UE, but the second UE does not acquire the layer 2 identifier of the first UE. If the first UE and the second UE are transmitting The first UE and the second UE can also exchange the Layer 2 identifiers through the application layer message, and the Layer 2 identifiers are used for the second layer to identify the Layer 2 identifiers of the second UE. Establish a Layer 2 connection on the direct communication path.
步骤305、第一UE和第二UE互相认证,建立直接通信路径上安全的二层连接。Step 305: The first UE and the second UE authenticate each other to establish a secure Layer 2 connection on the direct communication path.
步骤306、第一UE向第二UE发送第一请求消息,第一请求消息中包括切换指示信息和APP ID。Step 306: The first UE sends a first request message to the second UE, where the first request message includes the handover indication information and the APP ID.
第一请求消息用于请求获取第一公网IP地址和第一公网端口号,可选的,第一请求消息中携带第一UE的标识,第一UE的标识可以是应用层(application layer)标识,或(Mobile Subscriber International ISDN/PSTN number,简称MSISDN)。根据发现过程的不同实现方案,第一请求消息中是否携带第一UE的标识包括:The first request message is used to request to obtain the first public network IP address and the first public network port number. Optionally, the first request message carries the identifier of the first UE, and the identifier of the first UE may be an application layer. ), or (Mobile Subscriber International ISDN/PSTN number, MSISDN for short). According to different implementations of the discovery process, whether the identifier of the first UE is carried in the first request message includes:
(1)若第一UE和第二UE在发现过程中交换了彼此的二层标识,则第一请求消息中可以携带也可以不携带第一UE的标识。(1) If the first UE and the second UE exchange the mutual layer 2 identifiers in the discovery process, the first request message may or may not carry the identifier of the first UE.
(2)若在发现过程第一作为owner获取了第二UE的二层标识,而第二UE没有获取第一UE的二层标识,则第一请求消息中需要携带第一UE的标识。(2) If the second layer of the second UE is obtained by the owner in the discovery process, and the second UE does not obtain the layer 2 identifier of the first UE, the first request message needs to carry the identifier of the first UE.
(3)若第一UE和第二UE在彼此发现后,通过应用层消息交换了彼此的二层标识,则第一请求消息中不需要携带第一UE的标识。(3) The first UE and the second UE do not need to carry the identifier of the first UE in the first request message if the second layer identifier of the first UE is exchanged by the application layer message.
步骤307、第二UE根据切换指示信息和APP ID匹配到与第一UE的通信会话,获取第一UE在该通信会话使用的第一公网IP和第一公网端口号。Step 307: The second UE matches the handover indication information and the APP ID to the communication session with the first UE, and acquires the first public network IP and the first public network port number used by the first UE in the communication session.
步骤308、第二UE向第一UE发送第一请求响应消息,第一请求响应消息中包括第一公网IP和第一公网端口号。Step 308: The second UE sends a first request response message to the first UE, where the first request response message includes a first public network IP and a first public network port number.
步骤309、第二UE向第一UE发送第二请求消息,第二请求消息中包括APP ID。Step 309: The second UE sends a second request message to the first UE, where the second request message includes an APP ID.
第二请求消息用于向第一UE请求获取第二公网IP地址和第二公网端口号。第二请求消息中包括APP ID,可选的,第二请求消息中还包括切换指示信息,第二请求消息中包括的切换指示信息、APP ID与第一请求消息中包括的切换指示信息、APP ID相同,可选的,第二请求消息中还 包括第二UE的标识。The second request message is used to request the first UE to acquire the second public network IP address and the second public network port number. The second request message includes an APP ID. Optionally, the second request message further includes the handover indication information, the handover indication information included in the second request message, the APP ID, and the handover indication information included in the first request message, and the APP. The ID is the same, optional, and the second request message is also The identifier of the second UE is included.
步骤310、第一UE根据切换指示信息和APP ID匹配到与第二UE的通信会话,获取第二UE在该通信会话使用的第二公网IP和第二公网端口号。Step 310: The first UE matches the handover indication information and the APP ID to the communication session with the second UE, and acquires the second public network IP and the second public network port number used by the second UE in the communication session.
步骤311、第一UE向第二UE发送第二请求响应消息,第二请求响应消息中包括第二公网IP和第二公网端口号。Step 311: The first UE sends a second request response message to the second UE, where the second request response message includes a second public network IP and a second public network port number.
步骤312、第一UE和第二UE建立直接通信路径。Step 312: The first UE and the second UE establish a direct communication path.
第一UE使用第一公网IP和第一公网端口号建立直接通信路径,第二UE使用第二公网IP和第二公网端口号建立直接通信路径。第一UE和第二UE建立直接通信路径中,也可以生成TFT,具体生成方式请参照实施例一和实施例二的相关描述,这里不再赘述。The first UE establishes a direct communication path by using the first public network IP and the first public network port number, and the second UE establishes a direct communication path by using the second public network IP and the second public network port number. For the first UE and the second UE to establish a direct communication path, a TFT may also be generated. For the specific generation manner, refer to the related descriptions of the first embodiment and the second embodiment, and details are not described herein again.
步骤313、第一UE和第二UE在直接通信路径上进行通信。Step 313: The first UE and the second UE communicate on a direct communication path.
第一UE和第二UE在直接通信路径上进行通信的过程请参照实施例一和实施例二的相关描述,这里不再赘述。For the process of the first UE and the second UE communicating on the direct communication path, refer to the related descriptions of the first embodiment and the second embodiment, and details are not described herein again.
图4为本发明实施例四提供的网络通信和直接通信之间的切换方法的信令流程图,如图4所示,本实施例提供的方法可以包括以下步骤:4 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 4 of the present invention. As shown in FIG. 4, the method provided in this embodiment may include the following steps:
步骤401、第一UE和第二UE建立网络通信路径。Step 401: The first UE and the second UE establish a network communication path.
步骤402、第一UE和第二UE通过网络通信路径进行通信。Step 402: The first UE and the second UE communicate through a network communication path.
步骤403、第一UE发起发现过程,确定自己与第二UE是否距离较近。Step 403: The first UE initiates a discovery process, and determines whether it is closer to the second UE.
步骤404、第一UE和第二UE在发现过程中互相交换各自的二层标识。Step 404: The first UE and the second UE exchange their respective Layer 2 identifiers in the discovery process.
步骤405、第一UE和第二UE互相认证,建立直接通信路径上安全的二层连接。Step 405: The first UE and the second UE authenticate each other to establish a secure Layer 2 connection on the direct communication path.
步骤401-405的具体实现方式与实施例三步骤301-305相同,请参照实施例三的描述,这里不再赘述。The specific implementation of the steps 401-405 is the same as the third embodiment of the third embodiment 301-305. Please refer to the description of the third embodiment, and details are not described herein again.
步骤406、第一UE向第二UE发送第一直接通信请求消息,第一直接通信请求消息中包括切换指示信息、APP ID、第二公网IP地址和第二公网端口号。Step 406: The first UE sends a first direct communication request message to the second UE, where the first direct communication request message includes the handover indication information, the APP ID, the second public network IP address, and the second public network port number.
可选的,第一直接通信请求消息还可以包括第一UE的标识。 Optionally, the first direct communication request message may further include an identifier of the first UE.
步骤407、第二UE向第一UE返回第一直接通信请求响应消息,第一直接通信请求响应消息中包括APP ID、第一公网IP地址和第一公网端口号。Step 407: The second UE returns a first direct communication request response message to the first UE, where the first direct communication request response message includes an APP ID, a first public network IP address, and a first public network port number.
第二UE收到第一UE发送的第一直接通信请求消息后,保存第二公网IP地址和第二公网端口号,并根据切换指示信息和APP ID匹配到与第一UE的通信会话,获取第一UE在该通信会话中使用的第一公网IP地址和第一公网端口号,并生成第一直接通信请求响应消息,可选的,第一直接通信响应消息中还可以包括第二UE的标识。After receiving the first direct communication request message sent by the first UE, the second UE saves the second public network IP address and the second public network port number, and matches the communication session with the first UE according to the handover indication information and the APP ID. Obtaining a first public network IP address and a first public network port number used by the first UE in the communication session, and generating a first direct communication request response message. Optionally, the first direct communication response message may further include The identity of the second UE.
需说明的是,步骤407和步骤408在执行时并没有先后顺序,也可以并列执行。It should be noted that step 407 and step 408 are not sequential in execution, and may be performed in parallel.
步骤408、第一UE和第二UE建立直接通信路径。Step 408: The first UE and the second UE establish a direct communication path.
第一UE使用第一公网IP和第一公网端口号建立直接通信路径,第二UE使用第二公网IP和第二公网端口号建立直接通信路径。第一UE和第二UE建立直接通信路径中,也可以生成TFT,具体生成方式请参照实施例一和实施例二的相关描述,这里不再赘述。The first UE establishes a direct communication path by using the first public network IP and the first public network port number, and the second UE establishes a direct communication path by using the second public network IP and the second public network port number. For the first UE and the second UE to establish a direct communication path, a TFT may also be generated. For the specific generation manner, refer to the related descriptions of the first embodiment and the second embodiment, and details are not described herein again.
第二UE根据第二公网IP地址和第二公网端口号建立直接通信路径。The second UE establishes a direct communication path according to the second public network IP address and the second public network port number.
步骤409、第一UE向第二UE返回直接通信路径建立完成消息。Step 409: The first UE returns a direct communication path establishment complete message to the second UE.
第一UE在直接通信路径建立成功后,向第二UE返回直接通信路径建立完成消息,通知第二UE直接通信路径建立成功。After the first UE successfully establishes the direct communication path, the first UE returns a direct communication path setup complete message to the second UE, and notifies the second UE that the direct communication path is successfully established.
步骤410、第一UE和第二UE使用直接通信路径进行通信。Step 410: The first UE and the second UE communicate by using a direct communication path.
第一UE和第二UE在直接通信路径上进行通信的过程请参照实施例一和实施例二的相关描述,这里不再赘述。For the process of the first UE and the second UE communicating on the direct communication path, refer to the related descriptions of the first embodiment and the second embodiment, and details are not described herein again.
图5为本发明实施例五提供的网络通信和直接通信之间的切换方法的信令流程图,如图5所示,本实施例提供的方法可以包括以下步骤:FIG. 5 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 5 of the present invention. As shown in FIG. 5, the method provided in this embodiment may include the following steps:
步骤501、第一UE和第二UE建立网络通信路径。Step 501: The first UE and the second UE establish a network communication path.
步骤502、第一UE和第二UE通过网络通信路径进行通信。Step 502: The first UE and the second UE communicate by using a network communication path.
步骤503、第一UE发起发现过程,确定自己与第二UE是否距离较近。Step 503: The first UE initiates a discovery process, and determines whether it is closer to the second UE.
步骤504、第一UE和第二UE在发现过程中互相交换各自的二层标识。 Step 504: The first UE and the second UE exchange their respective Layer 2 identifiers in the discovery process.
步骤505、第一UE和第二UE互相认证,建立直接通信路径上安全的二层连接。Step 505: The first UE and the second UE authenticate each other to establish a secure Layer 2 connection on the direct communication path.
步骤501-505的具体实现方式与实施例三步骤301-305相同,请参照实施例三的描述,这里不再赘述。The specific implementation of the steps 501-505 is the same as the third embodiment of the third embodiment 301-305. Please refer to the description of the third embodiment, and details are not described herein again.
步骤506、第一UE向应用服务器发送第三请求消息。Step 506: The first UE sends a third request message to the application server.
第三请求消息用于请求获取第一公网IP地址和第一公网端口号。可选的,在第三请求消息中包含第二UE的标识信息,以使得应用服务器返回与第二UE之间会话的第一公网IP地址及第一公网端口号。The third request message is used to request to obtain the first public network IP address and the first public network port number. Optionally, the third request message includes the identifier information of the second UE, so that the application server returns the first public network IP address and the first public network port number of the session with the second UE.
步骤507、应用服务器向第一UE返回第三响应消息,第三响应消息中包括第一公网IP地址和第一公网端口号。Step 507: The application server returns a third response message to the first UE, where the third response message includes the first public network IP address and the first public network port number.
步骤508、第一UE向第二UE发送第二直接通信请求消息,第二直接通信请求消息中包括切换指示信息和APP ID。Step 508: The first UE sends a second direct communication request message to the second UE, where the second direct communication request message includes the handover indication information and the APP ID.
步骤509、第二UE向应用服务器发送第四请求消息。Step 509: The second UE sends a fourth request message to the application server.
第四请求消息用于请求获取第二公网IP地址和第二公网端口号。可选的,在第四请求消息中包含第一UE的标识信息,以使得应用服务器返回与第一UE之间会话的第二公网IP地址及第二公网端口号。The fourth request message is used to request to obtain the second public network IP address and the second public network port number. Optionally, the fourth request message includes the identifier information of the first UE, so that the application server returns a second public network IP address and a second public network port number of the session with the first UE.
步骤510、应用服务器向第二UE返回第四响应消息,第四响应消息中包括第二公网IP地址和第二公网端口号。Step 510: The application server returns a fourth response message to the second UE, where the fourth response message includes a second public network IP address and a second public network port number.
步骤511、第二UE向第一UE返回第二直接通信响应消息。Step 511: The second UE returns a second direct communication response message to the first UE.
第二直接通信响应消息中可包含第二UE的标识信息。The second direct communication response message may include identification information of the second UE.
步骤512、第一UE和第二UE建立直接通信路径。Step 512: The first UE and the second UE establish a direct communication path.
第一UE使用第一公网IP和第一公网端口号建立直接通信路径,第二UE使用第二公网IP和第二公网端口号建立直接通信路径。第一UE和第二UE建立直接通信路径中,也可以生成TFT,具体生成方式请参照实施例一和实施例二的相关描述,这里不再赘述。The first UE establishes a direct communication path by using the first public network IP and the first public network port number, and the second UE establishes a direct communication path by using the second public network IP and the second public network port number. For the first UE and the second UE to establish a direct communication path, a TFT may also be generated. For the specific generation manner, refer to the related descriptions of the first embodiment and the second embodiment, and details are not described herein again.
步骤513、第一UE和第二UE使用直接通信路径进行通信。Step 513: The first UE and the second UE communicate by using a direct communication path.
第一UE和第二UE在直接通信路径上进行通信的过程请参照实施例一和实施例二的相关描述,这里不再赘述。For the process of the first UE and the second UE communicating on the direct communication path, refer to the related descriptions of the first embodiment and the second embodiment, and details are not described herein again.
需说明的是,实施例一至实施例五中提到的第一直接通信请求消息和第二直接通信请求消息可以采用相同的消息类型实现,也可以采用不同的 消息类型实现,当第一直接通信请求消息和第二直接通信请求消息采用相同的消息类型实现时,第一直接通信响应消息和第二直接通信响应消息也采用相同的消息类型实现。另外,第一请求消息和第二请求消息可以采用相同的消息类型实现,也可以采用不同的消息类型实现,第三请求消息和第四请求消息可以采用相同的消息类型实现,也可以采用不同的消息类型实现,当第一请求消息和第二请求消息采用相同的消息类型时,第一响应消息和第二响应消息也采用相同的消息类型,当第三请求消息和第四请求消息采用相同的消息类型时,第三响应消息和第四响应消息也采用相同的消息类型。It should be noted that the first direct communication request message and the second direct communication request message mentioned in the first embodiment to the fifth embodiment may be implemented by using the same message type, or may be different. The message type is implemented. When the first direct communication request message and the second direct communication request message are implemented by the same message type, the first direct communication response message and the second direct communication response message are also implemented by the same message type. In addition, the first request message and the second request message may be implemented by using the same message type, or may be implemented by using different message types. The third request message and the fourth request message may be implemented by using the same message type, or may be different. The message type is implemented. When the first request message and the second request message adopt the same message type, the first response message and the second response message also adopt the same message type, when the third request message and the fourth request message adopt the same The third response message and the fourth response message also use the same message type when the message type is used.
可选地,在实施例一至五的基础上,第一UE在建立直接通信路径的过程中还可以携带公共安全指示(public safety indication),公共安全指示用于指示为第一UE服务的P-GW在网络通信路径释放后,保存第一UE的私网IP地址,以便第一UE需要将通信路径从直接通信路径切换到网络通信路径时,为第一UE分配该第一UE的私网IP地址,从而保证用户的业务不中断。公共安全指示可通过PDN连接请求消息或附着请求消息的协议配置选项(Protocol Configuration Options,简称PCO)字段或request type字段实现。若公共安全指示通过request type携带,则eNB会将该公共安全指示发送给MME,在PDN连接建立的过程中,如果MME的签约数据中配置有该UE作为public safty UE的私网IP地址,则MME将该私网IP地址发送给PGW,PGW保存并为UE分配该私网IP地址,以使得在第一UE切换到直接通信路径,再返回网络通信路径后,PGW可以为该第一UE分配相同的私网IP地址。若公共安全指示通过request type携带,该公共安全指示可以只在MME中保存不发送给PGW,当MME发起PDN连接的释放时,在delete session request中包含该公共安全指示,以使得PGW保存该私网IP地址,从而在第一UE切换到直接通信路径,再返回网络通信路径后,PGW可以为该第一UE分配相同的私网IP地址。Optionally, on the basis of the first to fifth embodiments, the first UE may further carry a public safety indication in the process of establishing a direct communication path, where the public security indication is used to indicate the P- serving for the first UE. After the network communication path is released, the GW saves the private network IP address of the first UE, so that the first UE needs to allocate the private network IP address of the first UE to the first UE when the communication path needs to be switched from the direct communication path to the network communication path. The address, so as to ensure that the user's business is not interrupted. The public safety indication can be implemented by a PDN connection request message or a Protocol Configuration Options (PCO) field or a request type field of the attach request message. If the public security indication is carried by the request type, the eNB sends the public security indication to the MME. In the process of establishing the PDN connection, if the MME's subscription data is configured with the private IP address of the public safty UE, The MME sends the private network IP address to the PGW, and the PGW saves and allocates the private network IP address to the UE, so that after the first UE switches to the direct communication path and returns to the network communication path, the PGW can allocate the first UE. The same private IP address. If the public security indication is carried by the request type, the public security indication may be saved in the MME and not sent to the PGW. When the MME initiates the release of the PDN connection, the public security indication is included in the delete session request, so that the PGW saves the private The IP address of the network, so that after the first UE switches to the direct communication path and returns to the network communication path, the PGW can allocate the same private network IP address to the first UE.
若第一UE不需要将通信路径从直接通信路径切换到网络通信路径,则不需要在建立网络通信路径的过程中携带公共安全指示。同理,第二UE也可以在建立直接通信路径的过程中还可以携带公共安全指示。以下将通过一个具体实施例进行说明: If the first UE does not need to switch the communication path from the direct communication path to the network communication path, there is no need to carry a public safety indication in the process of establishing the network communication path. Similarly, the second UE may also carry a public security indication in the process of establishing a direct communication path. The following will be explained by a specific embodiment:
图6为本发明实施例六提供的网络通信和直接通信之间的切换方法的信令流程图,如图6所示,本实施例提供的方法可以包括以下步骤:FIG. 6 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 6 of the present invention. As shown in FIG. 6, the method provided in this embodiment may include the following steps:
步骤601、第一UE和第二UE通过直接通信路径进行通信。Step 601: The first UE and the second UE communicate by using a direct communication path.
本实施例的前提是,第一UE和第二UE已经将通信路径切换从网络通信路径切换到直接通信路径,并且使用直接通信路径进行通信了。The premise of this embodiment is that the first UE and the second UE have switched the communication path switching from the network communication path to the direct communication path, and communicated using the direct communication path.
步骤602、在通信过程中,第一UE确定直接通信路径的通信质量低于预设门限。Step 602: In the communication process, the first UE determines that the communication quality of the direct communication path is lower than a preset threshold.
第一UE在通过过程中,会检测直接通信路径的通信质量,当直接通信路径的通信质量低于预设门限时,第一UE可以将通信路径从直接通信路径切换到网络通信路径。During the passing of the first UE, the communication quality of the direct communication path is detected. When the communication quality of the direct communication path is lower than the preset threshold, the first UE may switch the communication path from the direct communication path to the network communication path.
步骤603、第一UE和第一核心网建立PDN连接,在建立过程中携带公共安全指示信息。Step 603: The first UE establishes a PDN connection with the first core network, and carries public security indication information during the establishment process.
当第一UE确定从直接通信路径切换至网络通信路径时,若第一网络通信路径没有释放,则第一UE直接将通信路径从直接通信路径切换到第一网络通信路径上,本实施例中,第一网络通信路径为第一UE切换到直接通信路径之前使用的网络通信路径。若第一网络通信路径已经释放,则需要建立第二网络通信路径,并且需要保证为第一UE分配的在第二网络通信路径中通信所使用的私网IP地址与第一UE在第一网络通信路径上通信所使用的私网IP地址相同,这样,才能保证切换后用户的业务不中断。When the first UE determines to switch from the direct communication path to the network communication path, if the first network communication path is not released, the first UE directly switches the communication path from the direct communication path to the first network communication path, in this embodiment. The first network communication path is a network communication path used before the first UE switches to the direct communication path. If the first network communication path has been released, the second network communication path needs to be established, and the private network IP address used for communication in the second network communication path allocated for the first UE and the first UE are in the first network. The private network IP address used for communication on the communication path is the same, so that the service of the user after the handover is not interrupted.
具体的,第一UE可以在attach request或PDN connection request的PCO中包含公共安全指示信息,PGW根据保存的第一UE在第一网络通信路径上通信所使用的私网IP地址,将第一UE在第一网络通信路径上通信所使用的私网IP地址作为第一UE在第二网络通信路径上所使用的私网IP地址分配给第一UE。Specifically, the first UE may include public security indication information in the PCO of the attach request or the PDN connection request, and the PGW may be the first UE according to the saved private network IP address used by the first UE to communicate on the first network communication path. The private network IP address used for communication on the first network communication path is allocated to the first UE as the private network IP address used by the first UE on the second network communication path.
步骤604、第一核心网向第一UE发送分配的私网IP地址。Step 604: The first core network sends the allocated private network IP address to the first UE.
步骤605、第一UE根据第一核心网分配的私网IP地址建立第二网络通信路径。Step 605: The first UE establishes a second network communication path according to the private network IP address allocated by the first core network.
具体的,第一UE根据第一核心网分配的私网IP地址建立与第二UE之间的通信会话的承载,第一UE还可以根据第一核心网分配的私网IP地址生成第二网络通信路径对应的TFT,第二网络通信路径对应的TFT的匹 配信息中:源地址为第一核心网分配的私网IP地址,源端口号为第二UE所使用的用于与第二UE通信的私网端口号,目的IP地址为第二公网IP地址,目的端口号为第二公网端口号。Specifically, the first UE establishes a bearer of the communication session with the second UE according to the private network IP address allocated by the first core network, and the first UE may further generate the second network according to the private network IP address allocated by the first core network. TFT corresponding to the communication path, and the TFT corresponding to the second network communication path In the configuration information, the source IP address is the private network IP address assigned by the first core network, and the source port number is the private network port number used by the second UE to communicate with the second UE, and the destination IP address is the second public network IP address. Address, destination port number is the second public network port number.
步骤606、第一UE向第二UE发送直接通信取消请求消息。Step 606: The first UE sends a direct communication cancellation request message to the second UE.
直接通信取消请求消息中包括切换指示信息,该切换指示信息用于指示第二UE将与第一UE之间的通信路径从直接通信路径切换到第二网络通信路径。The direct communication cancellation request message includes handover indication information, and the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the direct communication path to the second network communication path.
步骤607、第二UE和第二核心网建立PDN连接,在建立过程中携带公共安全指示信息。Step 607: The second UE and the second core network establish a PDN connection, and carry the public security indication information in the establishing process.
步骤608、第二核心网向第二UE发送分配的私网IP地址。Step 608: The second core network sends the allocated private network IP address to the second UE.
第二核心网中的PGW中包括第二UE在第一网络通信路径上通信所使用的私网IP地址,第二核心网将第二UE在第一网络通信路径上通信所使用的私网IP地址,作为第二UE在第二网络通信路径上通信所使用的私网IP地址。The PGW in the second core network includes a private network IP address used by the second UE to communicate on the first network communication path, and the second core network uses the private network IP used by the second UE to communicate on the first network communication path. The address is the private network IP address used by the second UE to communicate on the second network communication path.
步骤609、第二UE根据第二核心网分配的私网IP地址建立第二网络通信路径。Step 609: The second UE establishes a second network communication path according to the private network IP address allocated by the second core network.
具体的,第二UE根据第二核心网分配的私网IP地址建立与第一UE之间的通信会话的承载,第二UE还可以根据第二核心网分配的私网IP地址和生成第二网络通信路径对应的TFT,第二网络通信路径对应的TFT的匹配信息中:源地址为第二核心网分配的私网IP地址,源端口号为第二UE所使用的用于与第一UE通信的私网端口号,目的IP地址为第一公网IP地址,目的端口号为第一公网端口号。Specifically, the second UE establishes a bearer of the communication session with the first UE according to the private network IP address allocated by the second core network, and the second UE may further generate a second according to the private network IP address allocated by the second core network. The TFT corresponding to the network communication path and the matching information of the TFT corresponding to the second network communication path: the source address is a private network IP address allocated by the second core network, and the source port number is used by the second UE for use with the first UE. The private network port number of the communication. The destination IP address is the first public network IP address, and the destination port number is the first public network port number.
步骤610、第二UE向第一UE发送直接通信取消响应消息。Step 610: The second UE sends a direct communication cancellation response message to the first UE.
本实施例的方法,当第一UE和第二UE将通信路径从网络通信路径切换到直接通信路径后,若直接通信路径的通信质量不好,第一UE和第二UE还可以将通信路径从直接通信路径切换到网络通信路径,并且可以保证切换过程中用户的业务不中断。In the method of this embodiment, after the first UE and the second UE switch the communication path from the network communication path to the direct communication path, if the communication quality of the direct communication path is not good, the first UE and the second UE may further connect the communication path. Switching from the direct communication path to the network communication path, and ensuring that the user's service is not interrupted during the handover.
图7为本发明实施例七提供的网络通信和直接通信之间的切换方法的流程图,如图7所示,本实施例提供的方法可以包括以下步骤:FIG. 7 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 7 of the present invention. As shown in FIG. 7, the method provided in this embodiment may include the following steps:
步骤701、第一UE向第二UE发送切换指示信息,切换指示信息用 于指示第二UE将与第一UE之间的通信路径从网络通信路径切换到直接通信路径。Step 701: The first UE sends handover indication information to the second UE, where the indication information is used for handover. And indicating that the communication path between the second UE and the first UE is switched from the network communication path to the direct communication path.
可选的,第一UE向第二UE发送切换指示信息,具体为:第一UE向第二UE发送第三直接通信请求消息或第四直接通信请求消息,该第三直接通信请求消息或第四直接通信请求消息中包括切换指示信息,当然,第一UE也可以通过其他消息发送切换指示信息。本实施例中,第三直接通信请求消息中还包括第一私网IP地址、第一私网端口号、第二公网IP地址和第二公网端口号;第四直接通信请求消息中还可以包括:第一私网IP地址和第一私网端口号。Optionally, the first UE sends the handover indication information to the second UE, where the first UE sends a third direct communication request message or a fourth direct communication request message to the second UE, where the third direct communication request message or the first The four direct communication request message includes the handover indication information. Of course, the first UE may also send the handover indication information by using other messages. In this embodiment, the third direct communication request message further includes a first private network IP address, a first private network port number, a second public network IP address, and a second public network port number; and the fourth direct communication request message is further The method may include: a first private network IP address and a first private network port number.
可选的,第三直接通信请求消息或第四直接通信请求消息中还包括应用标识信息。Optionally, the third direct communication request message or the fourth direct communication request message further includes application identification information.
步骤702、第一UE获取第一公网IP地址和第一公网端口号。Step 702: The first UE acquires a first public network IP address and a first public network port number.
步骤703、第一UE获取第二私网IP地址和第二私网端口号。Step 703: The first UE acquires a second private network IP address and a second private network port number.
一种实现方式中,第一UE获取第一公网IP地址和第一公网端口号,具体为:第一UE接收第二UE返回的第三直接通信响应消息,第三直接通信响应消息是第二UE根据第三直接通信请求消息返回的,第三直接通信响应消息中包括:第一公网IP地址、第一公网端口号。第三直接通信响应消息中还可以包括:第二私网IP地址和第二私网端口号,第一UE从第三直接通信响应消息中获取第二私网IP地址和第二私网端口号。In an implementation manner, the first UE acquires the first public network IP address and the first public network port number, specifically: the first UE receives the third direct communication response message returned by the second UE, and the third direct communication response message is The second UE is returned according to the third direct communication request message, where the third direct communication response message includes: a first public network IP address and a first public network port number. The third direct communication response message may further include: a second private network IP address and a second private network port number, where the first UE obtains the second private network IP address and the second private network port number from the third direct communication response message. .
另一种实现方式中,第一UE获取第一公网IP地址和第一公网端口号,具体为:第一UE向应用服务器发送第三请求消息,第三请求消息用于请求获取第一公网IP地址和第一公网端口号,可选的,在第三请求消息中包含第二UE的标识信息,以使得应用服务器返回与第二UE之间会话的第一公网IP地址及第一公网端口号。应用服务器根据第三请求消息向第一UE返回第三响应消息,第一UE接收应用服务器返回的第三响应消息,第三响应消息中包括:第一公网IP地址和第一公网端口号。相应的,第一UE获取第二私网IP地址和第二私网端口号,具体为:第一UE接收第二UE根据第四直接通信请求消息返回的第四直接通信响应消息,第四直接通信响应消息中包括:第二私网IP地址和第二私网端口号。In another implementation manner, the first UE acquires the first public network IP address and the first public network port number, where the first UE sends a third request message to the application server, and the third request message is used to request to obtain the first a public network IP address and a first public network port number. Optionally, the third request message includes the identifier information of the second UE, so that the application server returns the first public IP address of the session with the second UE. The first public network port number. The application server returns a third response message to the first UE according to the third request message, where the first UE receives the third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number. . Correspondingly, the first UE acquires the second private network IP address and the second private network port number, specifically: the first UE receives the fourth direct communication response message returned by the second UE according to the fourth direct communication request message, and the fourth direct The communication response message includes: a second private network IP address and a second private network port number.
需要说明的是,本实施例中,步骤701-703在执行时并没有先后顺序,
并且可以同时执行;且703步骤中的第三请求消息和第三直接通信请求消息在执行时没有先后顺序,并且可以同时执行。It should be noted that, in this embodiment, the steps 701-703 are not in the order of execution.
And can be executed at the same time; and the third request message and the third direct communication request message in the
步骤704、第一UE使用第一公网IP地址、第一公网端口号、第二私网IP地址和第二私网端口号建立直接通信路径。Step 704: The first UE establishes a direct communication path by using the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number.
本实施例中,第一UE在获取到第一公网IP地址、第一公网端口号、第二私网IP地址和第二私网端口号后,不需要通过信令交互建立直接通信路径,只需要根据第一公网IP地址、第一公网端口号、第二私网IP地址和第二私网端口号建立底层连接,并建立第一公网IP地址、第一公网端口号与第一私网IP地址、第一私网端口号的第一对应关系,以及第二公网IP地址、第二公网端口号与第二私网IP地址、第二私网端口号的第二对应关系。在直接通信路径建立过程中,第一UE也可以生成直接通信路径对应的TFT,本实施例中,直接通信路径对应的TFT与网络通信路径对应的TFT相同,直接通信路径对应的TFT的源IP地址为第一私网IP地址,源端口号为第一私网端口号、目的IP地址为第二公网IP地址,目的端口号为第二公网端口号,但直接通信路径的TFT的优先级高于网络通信路径的优先级,从而保证第一UE向第二UE发送数据包时优先使用直接通信路径的TFT。In this embodiment, after acquiring the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number, the first UE does not need to establish a direct communication path through signaling interaction. The first public network IP address, the first public network port number, the second private network IP address, and the second private network port number are established according to the first public network IP address, the first public network IP address, and the first public network port number. The first correspondence between the first private network IP address and the first private network port number, and the second public network IP address, the second public network port number, the second private network IP address, and the second private network port number The second correspondence. In the process of establishing a direct communication path, the first UE may also generate a TFT corresponding to the direct communication path. In this embodiment, the TFT corresponding to the direct communication path is the same as the TFT corresponding to the network communication path, and the source IP of the TFT corresponding to the direct communication path. The address is the first private network IP address, the source port number is the first private network port number, the destination IP address is the second public network IP address, and the destination port number is the second public network port number, but the TFT of the direct communication path takes precedence. The level is higher than the priority of the network communication path, thereby ensuring that the TFT of the direct communication path is preferentially used when the first UE sends a data packet to the second UE.
步骤705、第一UE在直接通信路径上与第二UE通信。Step 705: The first UE communicates with the second UE on the direct communication path.
本实施例中,为了保持用户业务的连续性,第一UE的应用层在封装发送给第二UE的数据包时,使用将第一私网IP地址作为该数据包的源IP地址、将第一私网端口号作为该数据包的源端口号、将第二公网IP地址作为该数据包的目的IP地址,将第二公网端口号作为该数据包的目的端口号。封装后的数据包与在网络通信路径上发送的数据包相同,因此,在第一UE的应用层看来网络通信路径和直接通信路径上的数据包相同。In this embodiment, in order to maintain the continuity of the user service, the application layer of the first UE uses the first private network IP address as the source IP address of the data packet when encapsulating the data packet sent to the second UE. A private network port number is used as the source port number of the data packet, the second public network IP address is used as the destination IP address of the data packet, and the second public network port number is used as the destination port number of the data packet. The encapsulated data packet is the same as the data packet transmitted on the network communication path, and therefore, the application layer of the first UE sees that the network communication path and the data packet on the direct communication path are the same.
为了使第二UE在直接通信路径上接收到数据包与在网络通信路径上接收到的数据包相同,在第一UE中可以增加一个接近业务层,该接近业务层用于根据第一对应关系和第二对应关系修改该数据包的源IP地址、源端口号、目的IP地址和目的端口号。具体的,第一UE的接近业务层根据第一对应关系将发送给第二UE的数据包的源IP地址替换为第一公网IP地址,将该数据包的源端口号替换为第一公网端口号,根据第二对应关系 将该数据包的目的IP地址替换为第二私网IP地址,将该数据包的目的端口号替换为第二私网端口号,第一UE将该数据包通过直接通信路径发送给第二UE。第二UE接收到的第一UE通过直接通信路径发送的数据包,与第一UE通过网络通信路径发送的数据包相同,即在第二UE看来通信路径切换前后第一UE的源IP地址、源端口号和目的IP地址和目的端口号都没有改变,从而保证第二UE上的业务不中断。第一UE还可以通过直接通信路径接收第二UE发送的数据包。In order to enable the second UE to receive the data packet on the direct communication path and the data packet received on the network communication path, a proximity service layer may be added to the first UE, and the proximity service layer is used according to the first correspondence. The source IP address, the source port number, the destination IP address, and the destination port number of the data packet are modified by the second correspondence. Specifically, the proximity service layer of the first UE replaces the source IP address of the data packet sent to the second UE with the first public network IP address according to the first correspondence, and replaces the source port number of the data packet with the first public Network port number, according to the second correspondence The destination IP address of the data packet is replaced with the second private network IP address, and the destination port number of the data packet is replaced with the second private network port number, and the first UE sends the data packet to the second UE by using the direct communication path. . The data packet sent by the first UE through the direct communication path is the same as the data packet sent by the first UE through the network communication path, that is, the source IP address of the first UE before and after the communication path is switched by the second UE. The source port number, the destination IP address, and the destination port number are unchanged, so that the service on the second UE is not interrupted. The first UE may also receive the data packet sent by the second UE by using a direct communication path.
本实施例和实施例一的区别在于,实施例一中,第二UE接收到的第一UE通过直接通信路径和网络通信路径发送的数据包的源IP地址和源端口号相同,但是目的IP地址和目的端口号不同。本实施例中,第二UE接收到的第一UE通过直接通信路径和网络通信路径发送的数据包的源IP地址和源端口号相同,并且目的IP地址和目的端口号也相同。The difference between this embodiment and the first embodiment is that, in the first embodiment, the source IP address and the source port number of the data packet sent by the first UE through the direct communication path and the network communication path are the same, but the destination IP address. The address and destination port number are different. In this embodiment, the source IP address and the source port number of the data packet sent by the first UE through the direct communication path and the network communication path are the same, and the destination IP address and the destination port number are also the same.
本实施例中,第一UE向第二UE发送切换指示信息,切换指示信息用于指示第二UE将与第一UE之间的通信路径从网络通信路径切换到直接通信路径,并获取第一公网IP地址、第一公网端口号、第二私网IP地址和第二私网端口号,根据第一公网IP地址、第一公网端口号、第二私网IP地址和第二私网端口号建立直接通信路径,使用该直接通信路径与第二UE进行通信。所述方法保证第一UE在通信路径切换前后,用户的业务不中断。In this embodiment, the first UE sends the handover indication information to the second UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path, and obtains the first The public network IP address, the first public network port number, the second private network IP address, and the second private network port number are based on the first public network IP address, the first public network port number, the second private network IP address, and the second The private network port number establishes a direct communication path, and the direct communication path is used to communicate with the second UE. The method ensures that the service of the user is not interrupted before and after the communication path is switched by the first UE.
图8为本发明实施例八提供的网络通信和直接通信之间的切换方法的流程图,如图8所示,本实施例提供的方法可以包括以下步骤:FIG. 8 is a flowchart of a method for switching between network communication and direct communication according to Embodiment 8 of the present invention. As shown in FIG. 8, the method provided in this embodiment may include the following steps:
步骤801、第二UE接收第一UE发送的切换指示信息,切换指示信息用于指示第二UE将与第一UE之间的通信路径从网络通信路径切换到直接通信路径。Step 801: The second UE receives the handover indication information sent by the first UE, where the handover indication information is used to indicate that the second UE switches the communication path with the first UE from the network communication path to the direct communication path.
可选的,切换指示信息携带在第三直接通信请求消息中或第四直接通信请求消息,第二UE接收第一UE发送的第三直接通信请求消息或第四直接通信请求消息,从第三直接通信请求消息或第四直接通信请求消息中获取到切换指示信息,当然,切换指示信息还可以携带其他消息中。可选的,第三直接通信请求消息或第四直接通信请求消息中还可以包括应用标识信息。 Optionally, the handover indication information is carried in the third direct communication request message or the fourth direct communication request message, and the second UE receives the third direct communication request message or the fourth direct communication request message sent by the first UE, from the third The handover indication information is obtained in the direct communication request message or the fourth direct communication request message. Of course, the handover indication information may also be carried in other messages. Optionally, the third direct communication request message or the fourth direct communication request message may further include application identification information.
步骤802、第二UE获取第二公网IP地址和第二公网端口号。Step 802: The second UE acquires a second public network IP address and a second public network port number.
步骤803、第二UE获取第一私网IP地址和第一私网端口号Step 803: The second UE acquires the first private network IP address and the first private network port number.
一种实现方式中,第三直接通信请求消息中还包括第二公网IP地址、第二公网端口号、第一私网IP地址和第一私网端口号,第二UE从第三直接通信请求消息中获取第二公网IP地址、第二公网端口号、第一私网IP地址和第一私网端口号。In an implementation manner, the third direct communication request message further includes a second public network IP address, a second public network port number, a first private network IP address, and a first private network port number, where the second UE is directly from the third The second public network IP address, the second public network port number, the first private network IP address, and the first private network port number are obtained in the communication request message.
另一种实现方式中,第二UE向应用服务器发送第四请求消息,第四请求消息用于请求获取第二公网IP地址和第二公网端口号,可选的,在第四请求消息中包含第一UE的标识信息,以使得应用服务器返回与第一UE之间会话的第二公网IP地址及第二公网端口号。应用服务器接收到第四请求消息后,根据第四请求消息向第二UE返回第四响应消息,第四响应消息中包括第二公网IP地址和第二公网端口号。相应的,第二UE从第四直接通信请求消息中获取第一私网IP地址和第一私网端口号,第四直接通信请求消息中包括第一私网IP地址和第一私网端口号。In another implementation manner, the second UE sends a fourth request message to the application server, where the fourth request message is used to request to obtain the second public network IP address and the second public network port number, optionally, in the fourth request message. The identifier information of the first UE is included, so that the application server returns a second public network IP address and a second public network port number of the session with the first UE. After receiving the fourth request message, the application server returns a fourth response message to the second UE according to the fourth request message, where the fourth response message includes the second public network IP address and the second public network port number. Correspondingly, the second UE obtains the first private network IP address and the first private network port number from the fourth direct communication request message, where the fourth direct communication request message includes the first private network IP address and the first private network port number. .
第二UE接收到第一UE发送的第三直接通信请求消息之后,第二UE还向第一UE返回第三直接通信响应消息,第三直接通信响应消息中包括第一公网IP地址、第一公网端口号、第二私网IP地址和第二私网端口号。After the second UE receives the third direct communication request message sent by the first UE, the second UE also returns a third direct communication response message to the first UE, where the third direct communication response message includes the first public network IP address, A public network port number, a second private network IP address, and a second private network port number.
第二UE接收到第一UE发送的第四直接通信请求消息之后,第二UE还向第一UE返回第四直接通信响应消息,第四直接通信响应消息中包括第二私网IP地址和第二私网端口号。After the second UE receives the fourth direct communication request message sent by the first UE, the second UE also returns a fourth direct communication response message to the first UE, where the fourth direct communication response message includes the second private network IP address and the first Second private network port number.
需要说明的是,本实施例中,步骤801-803在执行时并没有先后顺序,也可以同时执行;且803步骤中的第四请求消息和第四直接通信请求消息在执行时没有先后顺序,并且可以同时执行It should be noted that, in this embodiment, the steps 801-803 are not executed in sequence, and may be performed simultaneously; and the fourth request message and the fourth direct communication request message in the
步骤804、第二UE使用第二公网IP地址、第二公网端口号、第一私网IP地址和第一私网端口建立直接通信路径。Step 804: The second UE establishes a direct communication path by using the second public network IP address, the second public network port number, the first private network IP address, and the first private network port.
具体的,第二UE根据第二公网IP地址、第二公网端口号、第一私网IP地址和第一私网端口建立底层连接,并建立第二公网IP地址、第二公网端口号与第二私网IP地址、第二私网端口号的第一对应关系,以及第一公网IP地址、第一公网端口号与第一私网IP地址、第一私网端口号的第二对应关系。在建立过程中,第二UE也可以生成直接通信路径对应的 TFT,本实施例中,直接通信路径对应的TFT与网络通信路径对应的TFT相同,直接通信路径对应的TFT的源IP地址为第二私网IP地址,源端口号为第二私网端口号、目的IP地址为第一公网IP地址,目的端口号为第一公网端口号,但直接通信路径的TFT的优先级高于网络通信路径的优先级,从而保证第二UE向第一UE发送数据包时优先使用直接通信路径的TFT。Specifically, the second UE establishes an underlying connection according to the second public network IP address, the second public network port number, the first private network IP address, and the first private network port, and establishes a second public network IP address and a second public network. The first correspondence between the port number and the second private network IP address and the second private network port number, and the first public network IP address, the first public network port number, the first private network IP address, and the first private network port number The second correspondence. During the establishment process, the second UE may also generate a direct communication path corresponding to In the embodiment, the TFT corresponding to the direct communication path is the same as the TFT corresponding to the network communication path, and the source IP address of the TFT corresponding to the direct communication path is the second private network IP address, and the source port number is the second private network port number. The destination IP address is the first public network IP address, and the destination port number is the first public network port number, but the priority of the TFT of the direct communication path is higher than the priority of the network communication path, thereby ensuring that the second UE is to the first UE. The TFT of the direct communication path is preferred when sending a packet.
步骤805、第二UE在直接通信路径上与第一UE通信。Step 805: The second UE communicates with the first UE on a direct communication path.
具体的,第二UE根据第一对应关系将发送给第一UE的数据包的源IP地址替换为第二公网IP地址,将该数据包的源端口号替换为第二公网端口号,根据第二对应关系将该数据包的目的IP地址替换为第一私网IP地址,将该数据包的目的端口号替换为第一私网端口号,其中,该数据包的源端口号为第二私网端口号,该数据包的源端口号为第二私网端口号,该数据包的目的IP地址为第一公网IP地址,该数据包的目的端口号为第一公网端口号,第二UE将替换后的数据包通过直接通信路径发送给第一UE。第二UE还可以通过直接通信路径接收第一UE发送的数据包。本步骤的具体实现方式可参照实施例七中步骤705的相关描述,这里不再赘述。Specifically, the second UE replaces the source IP address of the data packet sent to the first UE with the second public network IP address according to the first correspondence, and replaces the source port number of the data packet with the second public network port number. Replace the destination IP address of the data packet with the first private network IP address, and replace the destination port number of the data packet with the first private network port number, where the source port number of the data packet is the first The port number of the second private network, the source port number of the data packet is the second private network port number, the destination IP address of the data packet is the first public network IP address, and the destination port number of the data packet is the first public network port number. And the second UE sends the replaced data packet to the first UE by using a direct communication path. The second UE may also receive the data packet sent by the first UE by using a direct communication path. For a specific implementation of this step, reference may be made to the related description of
本实施例中,为了保持用户业务的连续性,第二UE的应用层在封装发送给第一UE的数据包时,使用将第二私网IP地址作为该数据包的源IP地址、将第二私网端口号作为该数据包的源端口号、将第一公网IP地址作为该数据包的目的IP地址,将第一公网端口号作为该数据包的目的端口号。封装后的数据包与在网络通信路径上发送的数据包相同。在网络通信路径中传输的数据包需要经过第一UE侧和第二UE侧的NAT服务器的地址转换。In this embodiment, in order to maintain the continuity of the user service, the application layer of the second UE uses the second private network IP address as the source IP address of the data packet when encapsulating the data packet sent to the first UE. The second private network port number is used as the source port number of the data packet, the first public network IP address is used as the destination IP address of the data packet, and the first public network port number is used as the destination port number of the data packet. The encapsulated packet is the same as the packet sent on the network communication path. The data packets transmitted in the network communication path need to undergo address translation by the NAT server on the first UE side and the second UE side.
在直接通信路径的传输过程中,第一UE需要对数据包的源、目的IP地址和源、目的端口号进行替换,这样在第一UE看来切换前后第二UE的源IP地址、源端口号和目的IP地址和目的端口号都没有改变,从而保证第一UE上的业务不中断。During the transmission of the direct communication path, the first UE needs to replace the source and destination IP addresses of the data packet with the source and destination port numbers, so that the source IP address and source port of the second UE before and after the first UE seems to be switched. The number and the destination IP address and the destination port number are unchanged, so that the service on the first UE is not interrupted.
本发明实施例九采用一个具体的实施例,对实施例七和实施例八的技术方案进行详细说明。图9为本发明实施例九提供的网络通信和直接通信之间的切换方法的信令流程图,如图9所示,本实施例提供的方法可以包 括以下步骤:The ninth embodiment of the present invention uses a specific embodiment to describe the technical solutions of the seventh embodiment and the eighth embodiment in detail. FIG. 9 is a signaling flowchart of a method for switching between network communication and direct communication according to Embodiment 9 of the present invention. As shown in FIG. 9, the method provided in this embodiment may include Including the following steps:
步骤901、第一UE和第二UE分别建立网络通信路径。Step 901: The first UE and the second UE respectively establish a network communication path.
步骤902、第一UE和第二UE通过网络通信路径进行通信。Step 902: The first UE and the second UE communicate through a network communication path.
步骤903、第一UE发起发现过程,确定自己与第二UE是否距离较近。Step 903: The first UE initiates a discovery process, and determines whether it is closer to the second UE.
步骤904、第一UE和第二UE在发现过程中互相交换各自的二层标识。Step 904: The first UE and the second UE exchange their respective Layer 2 identifiers in the discovery process.
步骤905、第一UE和第二UE互相认证,建立直接通信路径上安全的二层连接。Step 905: The first UE and the second UE authenticate each other to establish a secure Layer 2 connection on the direct communication path.
步骤901-905的具体实现方式与实施例三步骤301-305相同,请参照实施例三的描述,这里不再赘述。The specific implementation of the steps 901-905 is the same as the third embodiment of the third embodiment 301-305. Please refer to the description of the third embodiment, and details are not described herein again.
步骤906、第一UE向应用服务器发送第三请求消息。Step 906: The first UE sends a third request message to the application server.
步骤907、应用服务器返回第三响应消息,第三响应消息中包括第一公网IP地址和第一公网端口号。Step 907: The application server returns a third response message, where the third response message includes a first public network IP address and a first public network port number.
步骤908、第一UE向第二UE发送第四直接通信请求消息,第四直接通信请求消息中包括切换指示信息、APP ID、第一私网IP地址和第一私网端口号。Step 908: The first UE sends a fourth direct communication request message to the second UE, where the fourth direct communication request message includes the handover indication information, the APP ID, the first private network IP address, and the first private network port number.
可选的,第四直接通信请求消息中还可以第一UE的标识。Optionally, the identifier of the first UE may also be included in the fourth direct communication request message.
步骤909、第二UE根据切换指示信息和APP ID向应用服务器发送第四请求消息。Step 909: The second UE sends a fourth request message to the application server according to the handover indication information and the APP ID.
步骤910、应用服务器向第二UE返回第四响应消息,第四响应消息中第二公网IP地址和第二公网端口号。Step 910: The application server returns a fourth response message to the second UE, where the second public network IP address and the second public network port number are in the fourth response message.
步骤911、第二UE建立并保存第二公网IP地址、第二公网端口号与第二私网IP地址、第二私网端口号的第一对应关系,以及第一公网IP地址、第一公网端口号与第一私网IP地址、第一私网端口号的第二对应关系。Step 911: The second UE establishes and saves a first correspondence between the second public network IP address, the second public network port number, the second private network IP address, and the second private network port number, and the first public network IP address, The second correspondence between the first public network port number and the first private network IP address and the first private network port number.
步骤912、第二UE向第一UE返回第四直接通信响应消息,第四直接通信响应消息中包括第二私网IP地址和第二私网端口号。Step 912: The second UE returns a fourth direct communication response message to the first UE, where the fourth direct communication response message includes a second private network IP address and a second private network port number.
步骤913、第二UE建立并保存第一公网IP地址、第一公网端口号与第一私网IP地址、第一私网端口号的第一对应关系,以及第二公网IP地 址、第二公网端口号与第二私网IP地址、第二私网端口号的第二对应关系。Step 913: The second UE establishes and saves a first public network IP address, a first public network port number, a first private network IP address, a first private network port number, and a second public network IP address. The second correspondence between the address, the second public network port number, the second private network IP address, and the second private network port number.
步骤914、第一UE和第二UE在直接通信路径上通信。Step 914: The first UE and the second UE communicate on a direct communication path.
第一UE和第二UE在直接通信路径上通信过程请参照实施例七和实施例八的相关描述,这里不再赘述。For the communication process of the first UE and the second UE on the direct communication path, refer to the related descriptions of the seventh embodiment and the eighth embodiment, and details are not described herein again.
需说明的是,实施例七至实施例九中提到的第三直接通信请求消息和第四直接通信请求消息可以采用相同的消息类型实现,也可以采用不同的消息类型实现,当第三直接通信请求消息和第四直接通信请求消息采用相同的消息类型时,第三直接通信响应消息和第四直接通信响应消息也采用相同的消息类型相同的消息类型实现。另外,第三请求消息和第四请求消息可以采用相同的消息类型实现,也可以采用不同的消息类型实现,当第三请求消息和第四请求消息采用相同的消息类型时,第三响应消息和第四响应消息也采用相同的消息类型。It should be noted that the third direct communication request message and the fourth direct communication request message mentioned in the seventh embodiment to the ninth embodiment may be implemented by using the same message type, or may be implemented by using different message types. When the communication request message and the fourth direct communication request message adopt the same message type, the third direct communication response message and the fourth direct communication response message are also implemented by the same message type of the same message type. In addition, the third request message and the fourth request message may be implemented by using the same message type, or may be implemented by using different message types. When the third request message and the fourth request message adopt the same message type, the third response message and The fourth response message also uses the same message type.
图10为本发明实施例十提供的第一UE的结构示意图,如图10所示,本实施例提供的第一UE包括:发送模块11、获取模块12、路径建立模块13和通信模块14。10 is a schematic structural diagram of a first UE according to Embodiment 10 of the present invention. As shown in FIG. 10, the first UE provided in this embodiment includes: a sending
发送模块11,用于向第二UE发送切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;The sending
获取模块12,用于获取第一公网IP地址和第一公网端口号;The obtaining
路径建立模块13,用于使用所述第一公网IP地址和所述第一公网端口号建立所述直接通信路径;The
通信模块14,用于在所述直接通信路径上与所述第二UE通信。The
第一种实现方式中,所述发送模块11具体用于:向所述第二UE发送第一请求消息,所述第一请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号,所述第一请求消息中包括所述切换指示信息。相应的,所述获取模块12具体用于:接收所述第二UE返回的第一响应消息,所述第一响应消息中包括:所述第一公网IP地址和所述第一公网端口号。In a first implementation manner, the sending
可选的,所述第一请求消息还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所 述网络通信路径切换到所述直接通信路径。Optionally, the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE sends the communication path under the application corresponding to the application identifier from the The network communication path is switched to the direct communication path.
可选的,所述第一UE还包括:接收模块,用于接收所述第二UE发送的第二请求消息,所述第二请求消息用于向所述第一UE请求获取第二公网IP地址和第二公网端口;相应的,所述发送11模块,还用于向所述第二UE发送第二响应消息,所述第二响应消息中包括:所述第二公网IP地址及端口号和所述第二公网端口号。Optionally, the first UE further includes: a receiving module, configured to receive a second request message sent by the second UE, where the second request message is used to request the first UE to acquire a second public network The IP address and the second public network port; correspondingly, the sending 11 module is further configured to send a second response message to the second UE, where the second response message includes: the second public network IP address And a port number and the second public network port number.
第二种实现方式中,所述获取模块12具体用于:向所述第二UE发送第一直接通信请求消息,所述第一直接通信请求消息中还包括:第二公网IP地址和第二公网端口号,然后,接收所述第二UE返回的第一直接通信响应消息,所述第一直接通信响应消息中包括:所述第一公网IP地址和所述第一公网端口号。相应的,所述切换指示信息可以携带在所述第一直接通信请求消息中。In the second implementation manner, the acquiring
第三种实现方式中,所述发送模块11具体用于:向所述第二UE发送第二直接通信请求消息,所述第二直接通信请求消息中包括所述切换指示信息;相应的,所述获取模块12具体用于:向应用服务器发送第三请求消息,所述第三请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号;然后,接收所述应用服务器返回的第三响应消息,所述第三响应消息中包括:所述第一公网IP地址和所述第一公网端口号。In a third implementation manner, the sending
可选的,所述第一直接通信请求消息或所述第二直接通信请求消息中还包括应用标识信息。Optionally, the first direct communication request message or the second direct communication request message further includes application identification information.
本实施例中,所述通信模块14具体用于:In this embodiment, the
将所述第一公网IP地址作为发送给所述第二UE的数据包的源IP地址,将所述第一公网端口号作为所述数据包的源端口号,将第二公网IP地址作为所述数据包的目的IP地址,将第二公网端口号作为所述数据包的目的端口号,将所述数据包通过所述直接通信路径发送给所述第二UE。Using the first public network IP address as the source IP address of the data packet sent to the second UE, using the first public network port number as the source port number of the data packet, and using the second public network IP address The address is used as the destination IP address of the data packet, and the second public network port number is used as the destination port number of the data packet, and the data packet is sent to the second UE by using the direct communication path.
本实施例提供的第一UE,可用于执行实施例一、实施例三至实施例六的方法,具体实现方式和技术效果类似,这里不再赘述。The first UE provided in this embodiment may be used to perform the methods in the first embodiment and the third embodiment to the sixth embodiment. The specific implementation manners and technical effects are similar, and details are not described herein again.
图11为本发明实施例十一提供的第二UE的结构示意图,如图11所示,本实施例提供的第二UE包括:接收模块21、获取模块22、路径建立模块23和通信模块24。
FIG. 11 is a schematic structural diagram of a second UE according to
接收模块21,用于接收第一UE发送的切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;The receiving
获取模块22,用于获取第二公网IP地址和第二公网端口号;The obtaining
路径建立模块23,用于使用所述第二公网IP地址和所述第二公网端口号建立所述直接通信路径;The
通信模块24,用于在所述直接通信路径上与所述第一UE通信。The
第一种实现方式中,所述获取模块22具体用于:向所述第一UE发送第二请求消息,所述第二请求消息用于向所述第一UE请求获取所述第二公网IP地址和所述第二公网端口号;接收所述第一UE返回的第二响应消息,所述第二响应消息中包括:所述第二公网IP地址和所述第二公网端口号。In the first implementation manner, the acquiring
可选的,所述接收模块21还用于:接收所述第一UE发送的第一请求消息,所述第一请求消息中包括所述切换指示信息,所述第一请求消息用于请求获取第一公网IP地址和第一公网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号;根据所述切换指示信息,确定所述第一UE与所述第二UE在所述网络通信路径中使用的所述第一公网IP地址和所述第一公网端口号。相应的,所述第二UE还包括:发送模块,用于将所述第一公网IP地址和所述第一公网端口号携带在第一响应消息中发送给所述第一UE。Optionally, the receiving
可选的,所述第一请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。Optionally, the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE sends the communication path under the application corresponding to the application identifier from the network communication path. Switch to the direct communication path.
在第二种实现方式中,所述获取模块22具体用于:接收所述第一UE发送的第一直接通信请求消息,所述第一直接通信请求消息包括所述第二公网IP地址和所述第二公网端口号。相应的,所述切换指示信息可以携带在所述第一直接通信请求消息中。所述第二UE还包括:发送模块,用于向所述第一UE返回第一直接通信响应消息,所述第一直接通信响应消
息中包括:第一公网IP地址和第一公网端口号。In a second implementation manner, the acquiring
在第三种实现方式中,所述接收模块21具体用于:接收所述第一UE发送的第二直接通信请求消息,所述第二直接通信请求消息中包括所述切换指示信息。相应的,所述获取模块22具体用于:向应用服务器发送第四请求消息,所述第四请求消息用于请求获取所述第二公网IP地址和所述第二公网端口号;接收所述应用服务器返回的第四响应消息,所述第四响应消息中包括:所述第二公网IP地址和所述第二公网端口号。In a third implementation manner, the receiving
可选的,所述第一直接通信请求消息或所述第二直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。Optionally, the first direct communication request message or the second direct communication request message further includes application identification information, where the application identification information is used to indicate that the second UE uses the application corresponding to the application identifier. The communication path is switched from the network communication path to the direct communication path.
本实施例中,所述通信模块具体用于:将所述第二公网IP地址作为发送给所述第一UE的数据包的源IP地址,将所述第二公网端口号作为所述数据包的源端口号,将第一公网IP地址作为所述数据包的目的IP地址,将第一公网端口号作为所述数据包的目的端口号,将所述数据包通过所述直接通信路径发送给所述第一UE。In this embodiment, the communication module is specifically configured to: use the second public network IP address as a source IP address of a data packet sent to the first UE, and use the second public network port number as the The source port number of the data packet, the first public network IP address is used as the destination IP address of the data packet, and the first public network port number is used as the destination port number of the data packet, and the data packet is directly A communication path is sent to the first UE.
本实施例提供的第二UE,可用于执行实施例二至实施例六的方法,具体实现方式和技术效果类似,这里不再赘述。The second UE provided in this embodiment may be used to perform the methods in the second embodiment to the sixth embodiment. The specific implementation manners and technical effects are similar, and details are not described herein again.
图12为本发明实施例十二提供的第一UE的结构示意图,如图12所示,本实施例提供的第一UE包括:发送模块31、获取模块32、路径建立模块33和通信模块34。FIG. 12 is a schematic structural diagram of a first UE according to
发送模块31,用于向第二UE发送切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;The sending
获取模块32,用于获取第一公网IP地址和第一公网端口号;The obtaining
所述获取模块32,还用于获取第二私网IP地址和第二私网端口号;The obtaining
路径建立模块33,用于使用所述第一公网IP地址、所述第一公网端口号、所述第二私网IP地址和所述第二私网端口号建立所述直接通信路径;The
通信模块34,用于在所述直接通信路径上与所述第二UE通信。
The
本实施例中,所述路径建立模块33具体用于:建立所述第一公网IP地址、所述第一公网端口号与第一私网IP地址、第一私网端口号的第一对应关系,以及第二公网IP地址、第二公网端口号与所述第二私网IP地址、所述第二私网端口号的第二对应关系。In this embodiment, the
所述通信模块34具体用于:根据所述第一对应关系将发送给所述第二UE的数据包的源IP地址替换为所述第一公网IP地址,将所述数据包的源端口号替换为所述第一公网端口号,根据所述第二对应关系将所述数据包的目的IP地址替换为所述第二私网IP地址,将所述数据包的目的端口号替换为所述第二私网端口号,其中,所述数据包的源端口号为所述第一私网端口号,所述数据包的源端口号为所述第一私网端口号,所述数据包的目的IP地址为所述第二公网IP地址,所述数据包的目的端口号为所述第二公网端口号,所述第一UE将所述数据包通过所述直接通信路径发送给所述第二UE;或者,通过所述直接通信路径接收所述第二UE发送的数据包。The
一种实现方式中,所述发送模块31具体用于:向所述第二UE发送第三直接通信请求消息,所述第三直接通信请求消息中包括:所述切换指示信息;所述获取模块32具体用于:接收所述第二UE返回的第三直接通信响应消息,所述第三直接通信响应消息中包括:所述第一公网IP地址和所述第一公网端口号;所述第三直接通信响应消息中还包括:所述第二私网IP地址和所述第二私网端口号,所述获取模块32从所述第三直接通信响应消息中获取所述第二私网IP地址和所述第二私网端口号。In an implementation manner, the sending
另一种实现方式中,所述发送模块31具体用于:向所述第二UE发送第四直接通信请求消息,所述第四直接通信请求消息中包括:所述切换指示信息。所述获取模块32获取所述第一公网IP地址和所述第一公网端口号,包括:向应用服务器发送第三请求消息,所述第三请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号;接收所述应用服务器返回的第三响应消息,所述第三响应消息中包括:所述第一公网IP地址和所述第一公网端口号。所述获取模块32获取所述第二私网IP地址和所述第二私网端口号,包括:接收所述第二UE返回的第四直接通信响应消息,所述第四直接通信响应消息中包括:所述第二私网IP地址和所述第
二私网端口号。In another implementation manner, the sending
可选的,所述第三直接通信请求消息中还包括:第一私网IP地址和第一私网端口号、第二公网IP地址和第二公网端口号。Optionally, the third direct communication request message further includes: a first private network IP address and a first private network port number, a second public network IP address, and a second public network port number.
可选的,所述第四直接通信请求消息中还包括:第一私网IP地址和第一私网端口号。Optionally, the fourth direct communication request message further includes: a first private network IP address and a first private network port number.
可选的,所述第三直接通信请求消息或所述第四直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。Optionally, the third direct communication request message or the fourth direct communication request message further includes application identification information, where the application identification information is used to indicate that the second UE uses the application corresponding to the application identifier. The communication path is switched from the network communication path to the direct communication path.
本实施例提供的第一UE,可用于执行实施例七和实施例八提供的方案,具体实现方式和技术效果类似,这里不再赘述。The first UE provided in this embodiment may be used to perform the solution provided in the seventh embodiment and the eighth embodiment. The specific implementation manners and technical effects are similar, and details are not described herein again.
图13为本发明实施例十三提供的第二UE的结构示意图,如图13所示,本实施例提供的第二UE包括:接收模块41、获取模块42、路径建立模块43和通信模块44。FIG. 13 is a schematic structural diagram of a second UE according to
接收模块41,用于接收第一UE发送的切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;The receiving
获取模块42,用于获取第二公网IP地址和第二公网端口号;The obtaining
所述获取模块42,还用于获取第一私网IP地址和第一私网端口号;The obtaining
路径建立模块43,用于使用所述第二公网IP地址、所述第二公网端口号、所述第一私网IP地址和所述第一私网端口建立所述直接通信路径;The
通信模块44,用于在所述直接通信路径上与所述第一UE通信。The
本实施例中,所述路径建立模块43具体用于:建立所述第二公网IP地址、所述第二公网端口号与第二私网IP地址、第二私网端口号的第一对应关系,以及第一公网IP地址、第一公网端口号与所述第一私网IP地址、所述第一私网端口号的第二对应关系。In this embodiment, the
可选的,所述通信模块44具体用于:根据所述第一对应关系将发送给所述第一UE的数据包的源IP地址替换为所述第二公网IP地址,将所述数据包的源端口号替换为所述第二公网端口号,根据所述第二对应关系将所述数据包的目的IP地址替换为所述第一私网IP地址,将所述数据包
的目的端口号替换为所述第一私网端口号,其中,所述数据包的源端口号为所述第二私网端口号,所述数据包的源端口号为所述第二私网端口号,所述数据包的目的IP地址为所述第一公网IP地址,所述数据包的目的端口号为所述第一公网端口号,所述第二UE将替换后的数据包通过所述直接通信路径发送给所述第一UE;或者,通过所述直接通信路径接收所述第一UE发送的数据包。Optionally, the
一种实现方式中,所述接收模块41具体用于:接收所述第一UE发送的第三直接通信请求消息,所述第三直接通信请求消息中包括:所述切换指示信息。所述第三直接通信请求消息中还包括所述第二公网IP地址和所述第二公网端口号,所述获取模块42具体用于:从所述第三直接通信请求消息中获取所述第二公网IP地址和所述第二公网端口号。所述第三直接通信请求消息中还包括所述第一私网IP地址和所述第一私网端口号,所述获取模块42具体用于:从所述第三直接通信请求消息中获取所述第一私网IP地址和所述第一私网端口号。In an implementation manner, the receiving
另一种实现方式中,所述接收模块41具体用于:接收所述第一UE发送的第四直接通信请求消息,所述第四直接通信请求消息中包括:所述切换指示信息。所述获取模块42获取所述第二公网IP地址和所述第二公网端口号,包括:向应用服务器发送第四请求消息,所述第四请求消息用于请求获取所述第二公网IP地址和所述第二公网端口号;接收所述应用服务器返回的第四响应消息,所述第四响应消息中包括所述第二公网IP地址和所述第二公网端口号。所述获取模块获取所述第一私网IP地址和所述第一私网端口号,包括:所述第四直接通信请求消息中还包括所述第一私网IP地址和所述第一私网端口号,所述获取模块42从所述第四直接通信请求消息中获取所述第一私网IP地址和所述第一私网端口号。In another implementation manner, the receiving
可选的,所述第二UE还包括:发送模块,用于向所述第一UE返回第三直接通信响应消息,所述第三直接通信响应消息中包括第一公网IP地址、第一公网端口号、第二私网IP地址和第二私网端口号,或者,向所述第一UE返回第四直接通信响应消息,所述第四直接通信响应消息中包括第二私网IP地址和第二私网端口号。Optionally, the second UE further includes: a sending module, configured to return a third direct communication response message to the first UE, where the third direct communication response message includes a first public network IP address, and a first a public network port number, a second private network IP address, and a second private network port number, or returning a fourth direct communication response message to the first UE, where the fourth direct communication response message includes a second private network IP address. Address and second private network port number.
可选的,所述第三直接通信请求消息或所述第四直接通信请求消息中 还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。Optionally, in the third direct communication request message or the fourth direct communication request message The application identifier information is further used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path to the direct communication path.
本实施例提供的第二UE,可用于执行实施例八和实施例九的方案,具体实现方式和技术效果类似,这里步骤赘述。The second UE provided in this embodiment may be used to implement the solutions in the eighth embodiment and the ninth embodiment. The specific implementation manners and the technical effects are similar.
图14为本发明实施例十四提供的第一UE的结构示意图,如图14所示,本实施例提供的第一UE500包括:处理器51、存储器52、通信接口53和系统总线54,所述存储器51和所述通信接口53通过所述系统总线与所述处理器51连接并通信;所述存储器51,用于存储计算机执行指令;所述通信接口53用于和其他设备进行通信,所述处理器,用于运行所述计算机执行指令,执行如下所述的方法:FIG. 14 is a schematic structural diagram of a first UE according to
向第二UE发送切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;Transmitting, by the second UE, handover indication information, where the handover indication information is used to indicate that the second UE switches a communication path with the first UE from a network communication path to a direct communication path;
获取第一公网IP地址和第一公网端口号,所述第一公网IP地址为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网IP地址,所述第一公网端口号为所述第一UE在所述网络通信路径中与所述第二UE通信所使用的公网端口号;Obtaining a first public network IP address and a first public network port number, where the first public network IP address is a public network IP address used by the first UE to communicate with the second UE in the network communication path The first public network port number is a public network port number used by the first UE to communicate with the second UE in the network communication path;
使用所述第一公网IP地址和所述第一公网端口号建立所述直接通信路径;Establishing the direct communication path by using the first public network IP address and the first public network port number;
在所述直接通信路径上与所述第二UE通信。Communicating with the second UE on the direct communication path.
可选的,所述处理器51向第二UE发送切换指示信息,具体为:所述处理器51向所述第二UE发送第一请求消息,所述第一请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号,所述第一请求消息中包括所述切换指示信息。所述处理器51获取第一公网IP地址和第一公网端口号,具体为:接收所述第二UE返回的第一响应消息,所述第一响应消息中包括:所述第一公网IP地址和所述第一公网端口号。Optionally, the processor 51 sends the handover indication information to the second UE, where the processor 51 sends a first request message to the second UE, where the first request message is used to request to obtain the The first public network IP address and the first public network port number, and the first request message includes the handover indication information. The processor 51 obtains the first public network IP address and the first public network port number, specifically: receiving the first response message returned by the second UE, where the first response message includes: the first public The network IP address and the first public network port number.
可选的,所述第一请求消息还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。 Optionally, the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE switches the communication path under the application corresponding to the application identifier from the network communication path. To the direct communication path.
所述处理器51使用所述第一公网IP地址和所述第一公网端口号建立所述直接通信路径之前,所述处理器51还用于:接收所述第二UE发送的第二请求消息,所述第二请求消息用于向所述第一UE请求获取第二公网IP地址和第二公网端口,并向所述第二UE发送第二响应消息,所述第二响应消息中包括:所述第二公网IP地址及端口号和所述第二公网端口号。Before the processor 51 establishes the direct communication path by using the first public network IP address and the first public network port number, the processor 51 is further configured to: receive the second a request message, the second request message is used to request the first UE to acquire a second public network IP address and a second public network port, and send a second response message to the second UE, where the second response is The message includes: the second public network IP address and port number and the second public network port number.
可选的,所述处理器51获取第一公网IP地址和第一公网端口号,具体为:所述处理器51向所述第二UE发送第一直接通信请求消息,所述第一直接通信请求消息中还包括:第二公网IP地址和第二公网端口号;接收所述第二UE返回的第一直接通信响应消息,所述第一直接通信响应消息中包括:所述第一公网IP地址和所述第一公网端口号。可选的,所述切换指示信息携带在所述第一直接通信请求消息中。Optionally, the processor 51 obtains the first public network IP address and the first public network port number, where the processor 51 sends a first direct communication request message to the second UE, where the first The direct communication request message further includes: a second public network IP address and a second public network port number; receiving the first direct communication response message returned by the second UE, where the first direct communication response message includes: The first public network IP address and the first public network port number. Optionally, the handover indication information is carried in the first direct communication request message.
可选的,所述处理器51向第二UE发送切换指示信息,具体为:向所述第二UE发送第二直接通信请求消息,所述第二直接通信请求消息中包括所述切换指示信息。所述处理器51获取第一公网IP地址和第一公网端口号,具体为:向应用服务器发送第三请求消息,所述第三请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号;接收所述应用服务器返回的第三响应消息,所述第三响应消息中包括:所述第一公网IP地址和所述第一公网端口号。Optionally, the processor 51 sends the handover indication information to the second UE, where the second direct communication request message is sent to the second UE, where the second direct communication request message includes the handover indication information. . The processor 51 obtains the first public network IP address and the first public network port number, specifically: sending a third request message to the application server, where the third request message is used to request to obtain the first public network IP address. And receiving, by the first public network port number, a third response message that is returned by the application server, where the third response message includes: the first public network IP address and the first public network port number.
可选的,所述第一直接通信请求消息或所述第二直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。Optionally, the first direct communication request message or the second direct communication request message further includes application identification information, where the application identification information is used to indicate that the second UE uses the application corresponding to the application identifier. The communication path is switched from the network communication path to the direct communication path.
所述处理器51在所述直接通信路径上与所述第二UE通信,具体为:所述处理器51将所述第一公网IP地址作为发送给所述第二UE的数据包的源IP地址,将所述第一公网端口号作为所述数据包的源端口号,将第二公网IP地址作为所述数据包的目的IP地址,将第二公网端口号作为所述数据包的目的端口号,将所述数据包通过所述直接通信路径发送给所述第二UE。The processor 51 communicates with the second UE on the direct communication path, where the processor 51 uses the first public network IP address as a source of data packets sent to the second UE. The IP address, the first public network port number is used as the source port number of the data packet, the second public network IP address is used as the destination IP address of the data packet, and the second public network port number is used as the data. And a destination port number of the packet, where the data packet is sent to the second UE by using the direct communication path.
本实施例提供的第一UE,可用于执行实施例一、实施例三至实施例六的方案,具体实现方式和技术效果类似,这里不再赘述。 The first UE provided in this embodiment may be used to implement the solutions in the first embodiment and the third embodiment to the sixth embodiment. The specific implementation manners and technical effects are similar, and details are not described herein again.
图15为本发明实施例十五提供的第二UE的结构示意图,如图15所示,本实施例提供的第二UE600包括:处理器61、存储器62、通信接口63和系统总线64,所述存储器62和所述通信接口63通过所述系统总线64与所述处理器61连接并通信;所述存储器62,用于存储计算机执行指令;所述通信接口63用于和其他设备通信进行通信,所述处理器61,用于运行所述计算机执行指令,执行如下所述的方法:FIG. 15 is a schematic structural diagram of a second UE according to Embodiment 15 of the present invention. As shown in FIG. 15, the
接收第一UE发送的切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径;Receiving, by the first UE, handover indication information, where the handover indication information is used to indicate that the second UE switches a communication path with the first UE from a network communication path to a direct communication path;
获取第二公网IP地址和第二公网端口号;Obtaining a second public network IP address and a second public network port number;
使用所述第二公网IP地址和所述第二公网端口号建立所述直接通信路径;Establishing the direct communication path by using the second public network IP address and the second public network port number;
在所述直接通信路径上与所述第一UE通信。Communicating with the first UE on the direct communication path.
可选的,所述处理器61获取第二公网IP地址和第二公网端口号,具体为:向所述第一UE发送第二请求消息,所述第二请求消息用于向所述第一UE请求获取所述第二公网IP地址和所述第二公网端口号;接收所述第一UE返回的第二响应消息,所述第二响应消息中包括:所述第二公网IP地址和所述第二公网端口号。Optionally, the processor 61 obtains the second public network IP address and the second public network port number, specifically: sending a second request message to the first UE, where the second request message is used to Receiving, by the first UE, the second public network IP address and the second public network port number; receiving a second response message that is returned by the first UE, where the second response message includes: the second public The network IP address and the second public network port number.
可选的,所述处理器61获取第二公网IP地址和第二公网端口号之前,还用于:接收所述第一UE发送的第一请求消息,所述第一请求消息中包括所述切换指示信息,所述第一请求消息用于请求获取第一公网IP地址和第一公网端口号;根据所述切换指示信息,确定所述第一UE与所述第二UE在所述网络通信路径中使用的所述第一公网IP地址和所述第一公网端口号;将所述第一公网IP地址和所述第一公网端口号携带在第一响应消息中发送给所述第一UE。Optionally, before the acquiring, by the processor 61, the second public network IP address and the second public network port number, the processor 61 is further configured to: receive the first request message sent by the first UE, where the first request message includes And the first indication message is used to request to obtain the first public network IP address and the first public network port number; and determining, according to the handover indication information, that the first UE and the second UE are The first public network IP address and the first public network port number used in the network communication path; carrying the first public network IP address and the first public network port number in a first response message Transmitting to the first UE.
可选的,所述第一请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。Optionally, the first request message further includes application identifier information, where the application identifier information is used to indicate that the second UE sends the communication path under the application corresponding to the application identifier from the network communication path. Switch to the direct communication path.
可选的,所述处理器61获取第二公网IP地址和第二公网端口号,具体为:接收所述第一UE发送的第一直接通信请求消息,所述第一直接通 信请求消息包括所述第二公网IP地址和所述第二公网端口号。可选的,所述切换指示信息携带在所述第一直接通信请求消息中。Optionally, the processor 61 obtains the second public network IP address and the second public network port number, specifically: receiving the first direct communication request message sent by the first UE, where the first direct communication The request message includes the second public network IP address and the second public network port number. Optionally, the handover indication information is carried in the first direct communication request message.
所述处理器61接收所述第一UE发送的第一直接通信请求消息之后,还用于:向所述第一UE返回第一直接通信响应消息,所述第一直接通信响应消息中包括:第一公网IP地址和第一公网端口号。After receiving the first direct communication request message sent by the first UE, the processor 61 is further configured to: return a first direct communication response message to the first UE, where the first direct communication response message includes: The first public network IP address and the first public network port number.
可选的,所述处理器61接收第一UE发送的切换指示信息,具体为:接收所述第一UE发送的第二直接通信请求消息,所述第二直接通信请求消息中包括所述切换指示信息;所述处理器61获取第二公网IP地址和第二公网端口号,具体为:向应用服务器发送第四请求消息,所述第四请求消息用于请求获取所述第二公网IP地址和所述第二公网端口号;接收所述应用服务器返回的第四响应消息,所述第四响应消息中包括:所述第二公网IP地址和所述第二公网端口号。Optionally, the processor 61 receives the handover indication information sent by the first UE, specifically: receiving a second direct communication request message sent by the first UE, where the second direct communication request message includes the handover Instructing the information that the second public network IP address and the second public network port number are obtained by the processor 61, specifically: sending a fourth request message to the application server, where the fourth request message is used to request to acquire the second public Receiving a fourth response message returned by the application server, where the fourth response message includes: the second public network IP address and the second public network port number.
可选的,所述第一直接通信请求消息或所述第二直接通信请求消息中还包括应用标识信息。Optionally, the first direct communication request message or the second direct communication request message further includes application identification information.
可选的,所述处理器61在所述直接通信路径上与所述第一UE通信,具体为:将所述第二公网IP地址作为发送给所述第一UE的数据包的源IP地址,将所述第二公网端口号作为所述数据包的源端口号,将第一公网IP地址作为所述数据包的目的IP地址,将第一公网端口号作为所述数据包的目的端口号,将所述数据包通过所述直接通信路径发送给所述第一UE。Optionally, the processor 61 communicates with the first UE on the direct communication path, specifically: using the second public network IP address as a source IP address of a data packet sent to the first UE. Address, the second public network port number is used as the source port number of the data packet, the first public network IP address is used as the destination IP address of the data packet, and the first public network port number is used as the data packet. The destination port number, the data packet is sent to the first UE by using the direct communication path.
本实施例提供的第二UE,可用于执行实施例二至实施例六提供的方案,具体实现方式和技术效果类似,这里不再赘述。The second UE provided in this embodiment may be used to perform the solution provided in the second embodiment to the sixth embodiment. The specific implementation manners and technical effects are similar, and details are not described herein again.
图16为本发明实施例十六提供的第一UE的结构示意图,如图16所示,本实施例提供的第一UE700包括:处理器71、存储器72、通信接口73和系统总线74,所述存储器72和所述通信接口73通过所述系统总线74与所述处理器71连接并通信;所述存储器72,用于存储计算机执行指令;所述通信接口73用于和其他设备进行通信,所述处理器71,用于运行所述计算机执行指令,执行如下所述的方法:FIG. 16 is a schematic structural diagram of a first UE according to Embodiment 16 of the present invention. As shown in FIG. 16, the
向第二UE发送切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径; Transmitting, by the second UE, handover indication information, where the handover indication information is used to indicate that the second UE switches a communication path with the first UE from a network communication path to a direct communication path;
获取第一公网IP地址和第一公网端口号;Obtaining the first public network IP address and the first public network port number;
获取第二私网IP地址和第二私网端口号;Obtaining a second private network IP address and a second private network port number;
使用所述第一公网IP地址、所述第一公网端口号、所述第二私网IP地址和所述第二私网端口号建立所述直接通信路径;Establishing the direct communication path by using the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number;
在所述直接通信路径上与所述第二UE通信。Communicating with the second UE on the direct communication path.
所述处理器71使用所述第一公网IP地址、所述第一公网端口号、所述第二私网IP地址和所述第二私网端口号建立所述直接通信路径,具体为:所述处理器71建立所述第一公网IP地址、所述第一公网端口号与第一私网IP地址、第一私网端口号的第一对应关系,以及第二公网IP地址、第二公网端口号与所述第二私网IP地址、所述第二私网端口号的第二对应关系。The processor 71 establishes the direct communication path by using the first public network IP address, the first public network port number, the second private network IP address, and the second private network port number, specifically The processor 71 establishes a first correspondence between the first public network IP address, the first public network port number, the first private network IP address, and the first private network port number, and the second public network IP address. The second correspondence between the address, the second public network port number, the second private network IP address, and the second private network port number.
所述处理器71在所述直接通信路径上与所述第二UE通信,具体为:所述处理器71根据所述第一对应关系将发送给所述第二UE的数据包的源IP地址替换为所述第一公网IP地址,将所述数据包的源端口号替换为所述第一公网端口号,根据所述第二对应关系将所述数据包的目的IP地址替换为所述第二私网IP地址,将所述数据包的目的端口号替换为所述第二私网端口号,其中,所述数据包的源端口号为所述第一私网端口号,所述数据包的源端口号为所述第一私网端口号,所述数据包的目的IP地址为所述第二公网IP地址,所述数据包的目的端口号为所述第二公网端口号,所述第一UE将所述数据包通过所述直接通信路径发送给所述第二UE;或者,所述第一UE通过所述直接通信路径接收所述第二UE发送的数据包。The processor 71 communicates with the second UE on the direct communication path, specifically: the source IP address of the data packet that the processor 71 sends to the second UE according to the first correspondence. And replacing with the first public network IP address, replacing the source port number of the data packet with the first public network port number, and replacing the destination IP address of the data packet with the second corresponding relationship. The second private network IP address, the destination port number of the data packet is replaced with the second private network port number, where the source port number of the data packet is the first private network port number, The source port number of the data packet is the first private network port number, the destination IP address of the data packet is the second public network IP address, and the destination port number of the data packet is the second public network port The first UE sends the data packet to the second UE by using the direct communication path; or the first UE receives the data packet sent by the second UE by using the direct communication path.
可选的,所述处理器71向第二UE发送切换指示信息,具体为:向所述第二UE发送第三直接通信请求消息,所述第三直接通信请求消息中包括:所述切换指示信息。所述处理器71获取第一公网IP地址和第一公网端口号,具体为:接收所述第二UE返回的第三直接通信响应消息,所述第三直接通信响应消息中包括:所述第一公网IP地址和所述第一公网端口号。所述第三直接通信响应消息中还包括:所述第二私网IP地址和所述第二私网端口号,所述处理器71获取第二私网IP地址和第二私网端口号,具体为:从所述第三直接通信响应消息中获取所述第二私网IP地址 和所述第二私网端口号。Optionally, the processor 71 sends the handover indication information to the second UE, where the third direct communication request message is sent to the second UE, where the third direct communication request message includes: the handover indication information. The processor 71 obtains the first public network IP address and the first public network port number, specifically: receiving the third direct communication response message returned by the second UE, where the third direct communication response message includes: The first public network IP address and the first public network port number are described. The third direct communication response message further includes: the second private network IP address and the second private network port number, and the processor 71 acquires the second private network IP address and the second private network port number. Specifically, the second private network IP address is obtained from the third direct communication response message. And the second private network port number.
可选的,所述处理器71向第二UE发送切换指示信息,具体为:向所述第二UE发送第四直接通信请求消息,所述第四直接通信请求消息中包括:所述切换指示信息。所述处理器71获取第一公网IP地址和所述第一公网端口号,具体为:向应用服务器发送第三请求消息,所述第三请求消息用于请求获取所述第一公网IP地址和所述第一公网端口号;接收所述应用服务器返回的第三响应消息,所述第三响应消息中包括:所述第一公网IP地址和所述第一公网端口号。所述处理器71获取第二私网IP地址和第二私网端口号,具体为:接收所述第二UE返回的第四直接通信响应消息,所述第四直接通信响应消息中包括:所述第二私网IP地址和所述第二私网端口号。Optionally, the processor 71 sends the handover indication information to the second UE, where the fourth direct communication request message is sent to the second UE, where the fourth direct communication request message includes: the handover indication information. The processor 71 obtains the first public network IP address and the first public network port number, specifically: sending a third request message to the application server, where the third request message is used to request to acquire the first public network. An IP address and the first public network port number; receiving a third response message returned by the application server, where the third response message includes: the first public network IP address and the first public network port number . The processor 71 obtains the second private network IP address and the second private network port number, specifically: receiving the fourth direct communication response message returned by the second UE, where the fourth direct communication response message includes: The second private network IP address and the second private network port number are described.
可选的,所述第三直接通信请求消息中还包括:第一私网IP地址和第一私网端口号、第二公网IP地址和第二公网端口号。Optionally, the third direct communication request message further includes: a first private network IP address and a first private network port number, a second public network IP address, and a second public network port number.
可选的,所述第四直接通信请求消息中还包括:第一私网IP地址和第一私网端口号。Optionally, the fourth direct communication request message further includes: a first private network IP address and a first private network port number.
可选的,所述第三直接通信请求消息或所述第四直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。Optionally, the third direct communication request message or the fourth direct communication request message further includes application identification information, where the application identification information is used to indicate that the second UE uses the application corresponding to the application identifier. The communication path is switched from the network communication path to the direct communication path.
本实施例提供的第一UE,可用于执行实施例七和实施例八提供的方案,具体实现方式和技术效果类似,这里不再赘述。The first UE provided in this embodiment may be used to perform the solution provided in the seventh embodiment and the eighth embodiment. The specific implementation manners and technical effects are similar, and details are not described herein again.
图17为本发明实施例十七提供的第二UE的结构示意图,如图17所示,本实施例提供的第二UE800包括:包括:处理器81、存储器82、通信接口83和系统总线84,所述存储器82和所述通信接口83通过所述系统总线84与所述处理器81连接并通信;所述存储器82,用于存储计算机执行指令;所述通信接口83用于和其他设备进行通信,所述处理器81,用于运行所述计算机执行指令,执行下所述的方法:FIG. 17 is a schematic structural diagram of a second UE according to Embodiment 17 of the present invention. As shown in FIG. 17, the
接收第一UE发送的切换指示信息,所述切换指示信息用于指示所述第二UE将与所述第一UE之间的通信路径从网络通信路径切换到直接通信路径; Receiving, by the first UE, handover indication information, where the handover indication information is used to indicate that the second UE switches a communication path with the first UE from a network communication path to a direct communication path;
获取第二公网IP地址和第二公网端口号;Obtaining a second public network IP address and a second public network port number;
获取第一私网IP地址和第一私网端口号;Obtaining the first private network IP address and the first private network port number;
使用所述第二公网IP地址、所述第二公网端口号、所述第一私网IP地址和所述第一私网端口建立所述直接通信路径;Establishing the direct communication path by using the second public network IP address, the second public network port number, the first private network IP address, and the first private network port;
在所述直接通信路径上与所述第一UE通信。Communicating with the first UE on the direct communication path.
可选的,所述处理器81使用所述第二公网IP地址、所述第二公网端口号、所述第一私网IP地址和所述第一私网端口建立所述直接通信路径,具体为:所述处理器81建立所述第二公网IP地址、所述第二公网端口号与第二私网IP地址、第二私网端口号的第一对应关系,以及第一公网IP地址、第一公网端口号与所述第一私网IP地址、所述第一私网端口号的第二对应关系。Optionally, the processor 81 establishes the direct communication path by using the second public network IP address, the second public network port number, the first private network IP address, and the first private network port. Specifically, the processor 81 establishes a first correspondence between the second public network IP address, the second public network port number, the second private network IP address, and the second private network port number, and the first The second corresponding relationship between the public network IP address, the first public network port number, the first private network IP address, and the first private network port number.
可选的,所述处理器81在所述直接通信路径上与所述第一UE通信,具体为:根据所述第一对应关系将发送给所述第一UE的数据包的源IP地址替换为所述第二公网IP地址,将所述数据包的源端口号替换为所述第二公网端口号,根据所述第二对应关系将所述数据包的目的IP地址替换为所述第一私网IP地址,将所述数据包的目的端口号替换为所述第一私网端口号;或者,通过所述直接通信路径接收所述第一UE发送的数据包。Optionally, the processor 81 is configured to communicate with the first UE on the direct communication path, where the source IP address of the data packet sent to the first UE is replaced according to the first correspondence. And replacing, by the second public network IP address, the source port number of the data packet with the second public network port number, and replacing the destination IP address of the data packet with the second correspondence relationship. The first private network IP address, the destination port number of the data packet is replaced with the first private network port number; or the data packet sent by the first UE is received through the direct communication path.
可选的,所述处理器81接收第一UE发送的切换指示信息,具体为:接收所述第一UE发送的第三直接通信请求消息,所述第三直接通信请求消息中包括:所述切换指示信息。所述处理器81获取第二公网IP地址和第二公网端口号,具体为:所述第三直接通信请求消息中还包括所述第二公网IP地址和所述第二公网端口号,所述处理器81从所述第三直接通信请求消息中获取所述第二公网IP地址和所述第二公网端口号。所述第三直接通信请求消息中还包括所述第一私网IP地址和所述第一私网端口号,所述处理器81获取第一私网IP地址和第一私网端口号,具体为:所述处理器81从所述第三直接通信请求消息中获取所述第一私网IP地址和所述第一私网端口号。Optionally, the processor 81 receives the handover indication information that is sent by the first UE, specifically: receiving a third direct communication request message sent by the first UE, where the third direct communication request message includes: Switch the indication information. The processor 81 obtains the second public network IP address and the second public network port number, where the third direct communication request message further includes the second public network IP address and the second public network port. The processor 81 obtains the second public network IP address and the second public network port number from the third direct communication request message. The third direct communication request message further includes the first private network IP address and the first private network port number, and the processor 81 obtains the first private network IP address and the first private network port number, specifically The processor 81 obtains the first private network IP address and the first private network port number from the third direct communication request message.
可选的,所述处理器81接收第一UE发送的切换指示信息,具体为:接收所述第一UE发送的第四直接通信请求消息,所述第四直接通信请求消息中包括:所述切换指示信息。所述处理器81获取第二公网IP地址和 第二公网端口号,具体为:向应用服务器发送第四请求消息,所述第四请求消息用于请求获取所述第二公网IP地址和所述第二公网端口号;接收所述应用服务器返回的第四响应消息,所述第四响应消息中包括所述第二公网IP地址和所述第二公网端口号。所述处理器81获取第一私网IP地址和第一私网端口号,具体为:所述第四直接通信请求消息中还包括所述第一私网IP地址和所述第一私网端口号,所述处理器81从所述第四直接通信请求消息中获取所述第一私网IP地址和所述第一私网端口号。Optionally, the processor 81 receives the handover indication information that is sent by the first UE, specifically: receiving a fourth direct communication request message sent by the first UE, where the fourth direct communication request message includes: Switch the indication information. The processor 81 acquires a second public network IP address and The second public network port number is specifically configured to: send a fourth request message to the application server, where the fourth request message is used to request to obtain the second public network IP address and the second public network port number; The fourth response message returned by the application server, where the fourth response message includes the second public network IP address and the second public network port number. The processor 81 obtains the first private network IP address and the first private network port number, where the fourth direct communication request message further includes the first private network IP address and the first private network port. The processor 81 obtains the first private network IP address and the first private network port number from the fourth direct communication request message.
所述处理器81接收到所述第一UE发送的所述第三直接通信请求消息之后,还用于:向所述第一UE返回第三直接通信响应消息,所述第三直接通信响应消息中包括第一公网IP地址、第一公网端口号、第二私网IP地址和第二私网端口号。After receiving the third direct communication request message sent by the first UE, the processor 81 is further configured to: return a third direct communication response message, the third direct communication response message, to the first UE. The first public network IP address, the first public network port number, the second private network IP address, and the second private network port number are included.
所述处理器81接收到所述第一UE发送的所述第第四直接通信请求消息之后,还用于:向所述第一UE返回第四直接通信响应消息,所述第四直接通信响应消息中包括第二私网IP地址和第二私网端口号。After receiving the fourth direct communication request message sent by the first UE, the processor 81 is further configured to: return, to the first UE, a fourth direct communication response message, where the fourth direct communication response The message includes a second private network IP address and a second private network port number.
可选的,所述第三直接通信请求消息或所述第四直接通信请求消息中还包括应用标识信息,所述应用标识信息用于指示所述第二UE将所述应用标识对应的应用下的所述通信路径从所述网络通信路径切换到所述直接通信路径。Optionally, the third direct communication request message or the fourth direct communication request message further includes application identification information, where the application identification information is used to indicate that the second UE uses the application corresponding to the application identifier. The communication path is switched from the network communication path to the direct communication path.
本实施例提供的第二UE,可用于执行实施例八和实施例九提供的方案,具体实现方式和技术效果类似,这里不再赘述。The second UE provided in this embodiment may be used to implement the solution provided in the eighth embodiment and the ninth embodiment. The specific implementation manners and technical effects are similar, and details are not described herein again.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。A person skilled in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by using hardware related to the program instructions. The foregoing program may be stored in a computer readable storage medium, and the program is executed when executed. The foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。 Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that The technical solutions described in the foregoing embodiments may be modified, or some or all of the technical features may be equivalently replaced; and the modifications or substitutions do not deviate from the technical solutions of the embodiments of the present invention. range.
Claims (74)
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2015/077263 WO2016169015A1 (en) | 2015-04-23 | 2015-04-23 | Method and apparatus for switching network communication and direct communication |
| CN201580038930.9A CN106537854B (en) | 2015-04-23 | 2015-04-23 | Method and device for switching between network communication and direct communication |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2015/077263 WO2016169015A1 (en) | 2015-04-23 | 2015-04-23 | Method and apparatus for switching network communication and direct communication |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2016169015A1 true WO2016169015A1 (en) | 2016-10-27 |
Family
ID=57143665
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2015/077263 Ceased WO2016169015A1 (en) | 2015-04-23 | 2015-04-23 | Method and apparatus for switching network communication and direct communication |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN106537854B (en) |
| WO (1) | WO2016169015A1 (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108347752A (en) * | 2018-02-07 | 2018-07-31 | 北京佰才邦技术有限公司 | Data transmission method and the network equipment |
| WO2023020466A1 (en) * | 2021-08-20 | 2023-02-23 | 维沃移动通信有限公司 | Data processing method and apparatus, terminal, access network device, and core network device |
| CN117545039A (en) * | 2022-08-02 | 2024-02-09 | 中国电信股份有限公司 | Path conversion method, device and system |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2019028811A1 (en) * | 2017-08-11 | 2019-02-14 | 华为技术有限公司 | Path switching method, related apparatus, and system |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8493937B2 (en) * | 2008-06-27 | 2013-07-23 | Google Inc. | Efficient handover of media communications in heterogeneous IP networks using LAN profiles and network handover rules |
| CN103795818A (en) * | 2014-01-27 | 2014-05-14 | 杭州顺浪信息技术有限公司 | NAT traversal method |
| WO2014130143A1 (en) * | 2013-02-22 | 2014-08-28 | Intel IP Corporation | Path switching procedure for device-to-device communication |
| CN104079487A (en) * | 2013-03-29 | 2014-10-01 | 索尼公司 | Communication apparatus, communication system, control method of communication apparatus and program |
-
2015
- 2015-04-23 WO PCT/CN2015/077263 patent/WO2016169015A1/en not_active Ceased
- 2015-04-23 CN CN201580038930.9A patent/CN106537854B/en not_active Expired - Fee Related
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8493937B2 (en) * | 2008-06-27 | 2013-07-23 | Google Inc. | Efficient handover of media communications in heterogeneous IP networks using LAN profiles and network handover rules |
| WO2014130143A1 (en) * | 2013-02-22 | 2014-08-28 | Intel IP Corporation | Path switching procedure for device-to-device communication |
| CN104079487A (en) * | 2013-03-29 | 2014-10-01 | 索尼公司 | Communication apparatus, communication system, control method of communication apparatus and program |
| CN103795818A (en) * | 2014-01-27 | 2014-05-14 | 杭州顺浪信息技术有限公司 | NAT traversal method |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108347752A (en) * | 2018-02-07 | 2018-07-31 | 北京佰才邦技术有限公司 | Data transmission method and the network equipment |
| WO2023020466A1 (en) * | 2021-08-20 | 2023-02-23 | 维沃移动通信有限公司 | Data processing method and apparatus, terminal, access network device, and core network device |
| CN115714984A (en) * | 2021-08-20 | 2023-02-24 | 维沃移动通信有限公司 | Data processing method, device, terminal, access network equipment and core network equipment |
| JP7659666B2 (en) | 2021-08-20 | 2025-04-09 | 維沃移動通信有限公司 | Data processing method, device, terminal, access network device, and core network device |
| CN117545039A (en) * | 2022-08-02 | 2024-02-09 | 中国电信股份有限公司 | Path conversion method, device and system |
| CN117545039B (en) * | 2022-08-02 | 2025-03-07 | 中国电信股份有限公司 | Path conversion method, device and system |
Also Published As
| Publication number | Publication date |
|---|---|
| CN106537854B (en) | 2019-09-13 |
| CN106537854A (en) | 2017-03-22 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| KR102332880B1 (en) | System and method of ip session continuity in a device to device communication system | |
| EP3016469B1 (en) | Method and device for mode switching | |
| US20120282915A1 (en) | Connecting device via multiple carriers | |
| CN112584371A (en) | Method for sending roaming signaling message, related equipment and communication system | |
| KR20190120345A (en) | Quality of service control method and apparatus, SMF, UPF, UE, PCF and AN | |
| WO2014005536A1 (en) | Communication method, device and system for neighbour terminals | |
| KR102126223B1 (en) | Method and system of signaling procedure for mobile communication core network | |
| CN108337674B (en) | A method, device and network system for IP address allocation | |
| CN110072297A (en) | A kind of network architecture, information interacting method and device | |
| CN110662308A (en) | Communication method and device | |
| WO2015124104A1 (en) | Path establishment method, device and system and core network device | |
| CN108271433B (en) | Data message processing method, control plane network element and user plane network element | |
| WO2016150140A1 (en) | Processing method and system for control packet in sdn-based gateway | |
| CN107277882B (en) | Data routing method, device and base station | |
| CN102282905B (en) | A kind of method, Apparatus and system setting up radio bearer | |
| CN106537854B (en) | Method and device for switching between network communication and direct communication | |
| WO2014194849A1 (en) | Method and device for switching direct communication path | |
| WO2015120685A1 (en) | Method for selecting shunt gateway and controller | |
| WO2013053133A1 (en) | Service data transmission processing method, device and communication system | |
| WO2017054611A1 (en) | User equipment initial attachment method and system | |
| WO2022183497A1 (en) | Communication method and communication apparatus | |
| CN106471787B (en) | Obtaining authorization to use proximity services in a mobile communication system | |
| CN106797632B (en) | Method, device and system for realizing business continuity | |
| WO2017124231A1 (en) | Internet protocol (ip) address allocation method, control plane gateway and user plane gateway | |
| WO2014127699A1 (en) | Method, equipment and system for establishing direct communication path |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 15889504 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 15889504 Country of ref document: EP Kind code of ref document: A1 |