The present disclosure relates to the field of mobile communications, and in particular, to a web page pushing method and apparatus, and a terminal.
Currently, an operator has increasingly more requirements for a captive portal, especially in a Wi-Fi terminal product, and a specific requirement may include the following. An operator requires that a portal site of the operator can be popped up after startup by a user, and then the user can surf the Internet normally; or after a user is in arrearage, a page, such as a recharge page or an arrearage reminder, is pushed to the user.
A second terminal receives an Internet access instruction, where the instruction may be a uniform resource locator (URL) address, for example, www.baidu.com; a Hypertext Transfer Protocol (http) request is sent to a network side according to the Internet access instruction; the network side returns a response packet to a first terminal; and the first terminal encapsulates the foregoing response packet into a captive portal packet customized by an operator, and sends the captive portal packet customized by the operator to the second terminal, so that the second terminal displays a captive portal page customized by the operator. However, when the second terminal runs an application and sends an http request to the first terminal, the first terminal cannot discriminate that the foregoing request is sent when the first terminal runs an application, thereby causing a problem that the second terminal cannot normally run the application and cannot display a captive portal page customized by an operator because a response packet that is returned for an http request sent to the first terminal when the application is run is mistakenly encapsulated into a captive portal packet customized by the operator, but a response packet that is returned for an http request sent when a browser is opened is not encapsulated.
Embodiments of the present disclosure provide a web page pushing method and apparatus, and a terminal, which can solve a problem that a second terminal cannot normally run an application and cannot display a captive portal page customized by an operator.
According to a first aspect, a web page pushing method is provided, where the method includes receiving, by a first terminal, a response packet, which is sent by a network side to the first terminal, for a request packet for visiting a target web page, where the response packet includes an Internet Protocol (IP) address of the target web page, determining whether the first terminal stores the response packet, if the first terminal stores the response packet, forwarding the response packet to a second terminal, if the first terminal does not store the response packet, storing the response packet in the first terminal, and replacing the IP address of the target web page in the response packet with an IP address of a preset web page to obtain a target response packet, and sending the target response packet to the second terminal, so that the second terminal displays the preset web page according to the target response packet.
With reference to the first aspect, in a first implementation manner of the first aspect, before the receiving, by a first terminal, a response packet, which is sent by a network side to the first terminal, for a request packet for visiting a target web, the method further includes sending, by the first terminal, the request packet for visiting the target web page to the network side, where the request packet includes a URL address of the target web page, so that the network side acquires and returns the IP address of the target web page according to the URL address, and receiving the response packet returned by the network side, where the response packet includes the IP address of the target web page.
With reference to the first aspect or the first implementation manner of the first aspect, in a second implementation manner of the first aspect, the response packet further includes an address of the second terminal and a source port address of the request packet for visiting the target web page.
According to a second aspect, a web page pushing apparatus is provided, where the apparatus includes a receiving unit, a determining unit, a forwarding unit, a replacing unit, and a sending unit, where the receiving unit is configured to receive a response packet, which is sent by a network side to a first terminal, for a request packet for visiting a target web page, where the response packet includes an IP address of the target web page, the determining unit is configured to determine whether the first terminal stores the response packet received by the receiving unit, the forwarding unit is configured to, when the determining unit determines that the first terminal stores the response packet, forward the response packet to a second terminal, the replacing unit is configured to, when the determining unit determines that the first terminal does not store the response packet, store the response packet in the first terminal, and replace the IP address of the target web page in the response packet with an IP address of a preset web page to obtain a target response packet, and the sending unit is configured to send the target response packet obtained by the replacing unit to the second terminal, so that the second terminal displays the preset web page according to the target response packet.
With reference to the second aspect, in a first implementation manner of the second aspect, the sending unit is further configured to send the request packet for visiting the target web page to the network side, where the request packet includes a URL address of the target web page, so that the network side acquires and returns the IP address of the target web page according to the URL address, and the receiving unit is further configured to receive the response packet returned by the network side, where the response packet includes the IP address of the target web page.
With reference to the second aspect or the first implementation manner of the second aspect, in a second implementation manner of the second aspect, the response packet further includes an address of the second terminal and a source port address of the request packet for visiting the target web page.
According to a third aspect, a terminal is provided, where the terminal includes a network interface, one or more processors, and a memory, where one or more programs are stored in the memory and are configured to be executed by the one or more processors, where the one or more programs include receiving a response packet, which is sent by a network side to the terminal, for a request packet for visiting a target web page, where the response packet includes an IP address of the target web page, determining whether the terminal stores the response packet, if the terminal stores the response packet, forwarding the response packet to a second terminal, if the terminal does not store the response packet, storing the response packet in the terminal, and replacing the IP address of the target web page in the response packet with an IP address of a preset web page to obtain a target response packet, and sending the target response packet to the second terminal, so that the second terminal displays the preset web page according to the target response packet.
With reference to the third aspect, in a first implementation manner of the third aspect, the one or more programs further include sending the request packet for visiting the target web page to the network side, where the request packet includes a URL address of the target web page, so that the network side acquires and returns the IP address of the target web page according to the URL address, and receiving the response packet returned by the network side, where the response packet includes the IP address of the target web page.
With reference to the third aspect or the first implementation manner of the third aspect, in a second implementation manner of the third aspect, the response packet further includes an address of the second terminal and a source port address of the request packet for visiting the target web page.
According to the web page pushing method and apparatus, and the terminal that are provided in the embodiments of the present disclosure, a received response packet is compared with a response packet stored in a first terminal, an IP address of a target web page in a response packet in which inconsistency exists by means of comparison is modified to obtain a target response packet, and the obtained target response packet is sent to a second terminal, so that the second terminal can normally run an application and can accurately display a preset web page.
To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the following clearly describes the technical solutions in the embodiments of the present disclosure with reference to the accompanying drawings in the embodiments of the present disclosure. The described embodiments are some but not all of the embodiments of the present disclosure. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present disclosure without creative efforts shall fall within the protection scope of the present disclosure.
To better understand embodiments of the present disclosure, the following uses specific embodiments to provide further explanation with reference to the accompanying drawings, and the embodiments constitute no limitation on the embodiments of the present disclosure.
It should be noted that, the first terminal has a WIFI connection function, for example, may be a customer premises equipment (CPE) or a home gateway with a WIFI connection function; a second terminal has a WIFI connection function, for example, may be a mobile terminal with a WIFI connection function, such as a mobile phone, a tablet computer, and a notebook computer, or may be a fixed terminal with a WIFI connection function, such as a desktop computer or a server. In addition, a browser and an application are installed on the second terminal.
Referring to a working principle diagram of a first terminal shown in
It should be noted that, the network side may include a domain name server (DNS), where the DNS server is configured to resolve a received URL address, so as to obtain an IP address corresponding to the URL address. For example, after the DNS server resolves a received URL address of Baidu www.baidu.com, an IP address of Baidu 202.108.22.5 can be obtained.
Optionally, after the network side acquires and returns the IP address of the target web page according to the URL address in the received request packet and before the first terminal receives the response packet returned by the network side, the method may further include reassembling, by the first terminal, the foregoing request packet according to the received IP address of the target web page, that is, replacing the URL address of the target web page in the request packet with the IP address of the target web page, so as to generate an http request packet, where the http request packet includes but is not limited to, a source port address of the request packet of the target web page, an address of the second terminal, and the IP address of the target web page; and sending the http request packet to the network side.
After receiving the http request packet sent by the first terminal, the network side returns a response packet for the foregoing http request packet to the first terminal, where the response packet includes the source port address of the request packet of the target web page, the address of the second terminal, and the IP address of the target web page.
It may be understood that, when the second terminal is a mobile terminal, an address of the second terminal may be an international mobile equipment identification number (IMEI) of the second terminal.
S120. Determine whether the first terminal stores the response packet.
It should be noted that, the first terminal may store the response packet in a table, or may store the foregoing response packet in a queue or another storage area in which data can be temporarily stored.
It should be noted herein that, when the first terminal has not received the response packet, the first packet does not store any content. When the first terminal receives the response packet, it is determined, according to the IP address of the target web page, the address of the second terminal, and the source port address of the request packet of the target web page, whether the first terminal stores the response packet.
S130. If the first terminal stores the response packet, forward the response packet to a second terminal.
S140. If the first terminal does not store the response packet, store the response packet in the first terminal, and replace the IP address of the target web page in the response packet with an IP address of a preset web page to obtain a target response packet.
It may be understood that, after the second terminal starts, the second terminal receives a first instruction for opening a browser, or receives a first instruction for opening an application; and when a first http request packet is sent to the network side through the first terminal, the first terminal returns a first response packet according to the first http request packet. Because what the network side returns is the first response packet, it is determined that the first terminal does not store the response packet, and then the response packet is stored in the first terminal. The source port address of the request packet of the target web page, the address of the second terminal, and the IP address of the target web page are stored in the first terminal.
It should be noted herein that, the preset web page may be a captive portal page customized by an operator. For example, when the operator is China Mobile, the foregoing preset web page may be a home page of China Mobile. In addition, after the second terminal is in arrearage, the foregoing preset web page may be a page pushed to the second terminal, such as a recharge page or an arrearage reminder.
A routing protocol stack of the first terminal replaces the IP address of the target web page in the foregoing first response packet with the IP address of the preset web page to obtain the target response packet.
For a response packet received by the first terminal except the first response packet, if the first terminal stores the response packet, the response packet is forwarded to the second terminal; otherwise, same processing for the first response packet is performed on the response packet except the first response packet. The foregoing step of determining, each time when a response packet is received, whether the first terminal stores the response packet may avoid that a same response packet is consecutively modified for multiple times, which causes that the second terminal cannot normally visit a target web page and user experience is affected.
S150. Send the target response packet to the second terminal, so that the second terminal displays the preset web page according to the target response packet.
It should be noted that, if the second terminal sends, when receiving an instruction for opening an application, the request packet for visiting the target web page to the first terminal, because the IP address in the target response packet is the IP address of the preset web page, the application identifies the foregoing received target response packet as a wrong response packet, that is, the second terminal fails to open the foregoing application. Afterwards, if the second terminal sends, when receiving an instruction for opening the application again, the request packet for visiting the target web page to the first terminal, a http request packet generated by the first terminal is consistent with a http request packet generated by the first terminal for the first time, and therefore returned response packets are also consistent. Therefore, it can be determined that the first terminal has stored the response packet, and the first terminal forwards the response packet to the second terminal, so that the second terminal can normally open the application.
If the second terminal sends, when receiving an instruction for opening a browser, the request packet for visiting the target web page to the first terminal, the IP address in the target response packet has been replaced with the IP address of the preset web page, and therefore, the browser can display the preset web page, such as the home page of China Mobile, according to the foregoing target response packet. After displaying the preset web page, the second terminal sends an instruction message to the first terminal, where the instruction message is used to instruct the first terminal no longer to modify the IP address in the response packet when receiving the response packet, so that the second terminal can normally visit the target web page, That is, a purpose that visiting the target web page by the second terminal is not affected is achieved in a case in which a captive portal page customized by an operator is displayed.
In an embodiment, a first terminal may preset a function of a captive portal and enable the function. When the function of the captive portal is enabled, the first terminal performs operations, such as determining and IP address modification, on a received response packet until the foregoing instruction message is received, where the instruction message may be an instruction for disabling the function of the captive portal. When receiving the foregoing instruction message, a network device side disables the function of the captive portal, that is, no longer modifies an IP address in the response packet.
In conclusion, according to the web page pushing method provided in this embodiment of the present disclosure, a received response packet is compared with a response packet stored in a first terminal, an IP address of a target web page in a response packet in which inconsistency exists by means of comparison is modified to an IP address of a preset web page to obtain a target response packet, and the obtained target response packet is sent to a second terminal, so that on the premise that the second terminal accurately displays the preset web page, normally opening a browser by the second terminal to visit the target web page is not affected, or normally opening an application by the second terminal is not affected.
S320. The first terminal receives a response packet for the request packet.
S330. Determine whether the first terminal stores the response packet.
S340. If stored, forward the response packet to a second terminal.
S350. If not stored, store the response packet, and replace an IP address of the target web page in the response packet with an IP address of a preset web page to obtain a target response packet.
S360. The first terminal sends the target response packet to the second terminal.
S370. The second terminal displays the preset web page.
The receiving unit 401 is configured to receive a response packet, which is sent by a network side to a first terminal, for a request packet for visiting a target web page, where the response packet includes an IP address of the target web page.
The determining unit 402 is configured to determine whether the first terminal stores the response packet received by the receiving unit 401.
The forwarding unit 403 is configured to, when the determining unit 402 determines that the first terminal stores the response packet, forward the response packet to a second terminal.
The replacing unit 404 is configured to, when the determining unit 402 determines that the first terminal does not store the response packet, store the response packet in the first terminal, and replace the IP address of the target web page in the response packet with an IP address of a preset web page to obtain a target response packet.
The sending unit 405 is configured to send the target response packet obtained by the replacing unit 404 to the second terminal, so that the second terminal displays the preset web page according to the target response packet.
Optionally, the sending unit 405 is further configured to send the request packet for visiting the target web page to the network side, where the request packet includes a URL address of the target web page, so that the network side acquires and returns the IP address of the target web page according to the URL address, and the receiving unit 401 is further configured to receive the response packet returned by the network side, where the response packet includes the IP address of the target web page.
Optionally, the response packet further includes an address of the second terminal and a source port address of the request packet for visiting the target web page.
According to the web page pushing apparatus provided in this embodiment of the present disclosure, a received response packet is compared with a response packet stored in a first terminal, an IP address of a target web page in a response packet in which inconsistency exists by means of comparison is modified to obtain a target response packet, and the obtained target response packet is sent to a second terminal, so that a browser of the second terminal can accurately display a preset web page.
The network interface 501 is configured to communicate with another device.
For example, the processor 502 may be a central processing unit (CPU).
The memory 503 may be a permanent memory, for example, a hard disk drive or a flash memory; and one or more programs are stored in the memory 503 and are configured to be executed by one or more processors 502, where the one or more programs include receiving a response packet, which is sent by a network side to the first terminal, for a request packet for visiting a target web page, where the response packet includes an IP address of the target web page, determining whether the first terminal stores the response packet, if the first terminal stores the response packet, forwarding the response packet to a second terminal, if the first terminal does not store the response packet, storing the response packet in the first terminal, and replacing the IP address of the target web page in the response packet with an IP address of a preset web page to obtain a target response packet, and sending the target response packet to the second terminal, so that the second terminal displays the preset web page according to the target response packet.
Further, the one or more programs further include: sending the request packet for visiting the target web page to the network side, where the request packet includes a URL address of the target web page, so that the network side acquires and returns the IP address of the target web page according to the URL address, and receiving the response packet returned by the network side, where the response packet includes the IP address of the target web page.
Optionally, the response packet further includes an address of the second terminal and a source port address of the request packet of the target web page.
According to the terminal provided in this embodiment of the present disclosure, a received response packet is compared with a response packet stored in a first terminal, an IP address of a target web page in a response packet in which inconsistency exists by means of comparison is modified to obtain a target response packet, and the obtained target response packet is sent to a second terminal, so that a browser of the second terminal can accurately display a preset web page.
A person skilled in the art may be further aware that, in combination with the examples described in the embodiments disclosed in this specification, units and algorithm steps can be implemented by electronic hardware, computer software, or a combination thereof. To clearly describe interchangeability between hardware and software, the foregoing has generally described compositions and steps of each example according to functions. Whether the functions are performed by hardware or software depends on particular applications and design constraint conditions of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that such implementation goes beyond the scope of the present disclosure.
Steps of methods or algorithms described in the embodiments disclosed in this specification may be implemented by hardware, a software module executed by a processor, or a combination thereof. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a compact disc (CD)-ROM, or any other form of storage medium known in the art.
In the foregoing specific implementation manners, the objectives, technical solutions, and benefit effects of the present disclosure are described in further detail. It should be understood that the foregoing descriptions are merely specific implementation manners of the present disclosure, but are not intended to limit the protection scope of the present disclosure. Any modification, equivalent replacement, or improvement made without departing from the spirit and principle of the present disclosure shall fall within the protection scope of the present disclosure.
This application is a continuation of International Application No. PCT/CN2014/081244, filed on Jun. 30, 2014, which is hereby incorporated by reference in its entirety.
Number | Name | Date | Kind |
---|---|---|---|
6661799 | Molitor | Dec 2003 | B1 |
7404008 | Takeuchi | Jul 2008 | B2 |
8499034 | Karasaridis | Jul 2013 | B2 |
8533780 | Parla | Sep 2013 | B2 |
8725888 | Short | May 2014 | B2 |
9178861 | Hulse | Nov 2015 | B2 |
9232338 | Henry | Jan 2016 | B1 |
9313205 | Martini | Apr 2016 | B2 |
20090183247 | Kasper et al. | Jul 2009 | A1 |
20090254658 | Kamikura | Oct 2009 | A1 |
20120317153 | Parthasarathy et al. | Dec 2012 | A1 |
20130148500 | Sonoda et al. | Jun 2013 | A1 |
20140090030 | Ong | Mar 2014 | A1 |
20150334116 | Martini | Nov 2015 | A1 |
20160323409 | Kolhi | Nov 2016 | A1 |
Number | Date | Country |
---|---|---|
1464425 | Dec 2003 | CN |
101510196 | Aug 2009 | CN |
103269313 | Aug 2013 | CN |
2002229898 | Aug 2002 | JP |
2013522933 | Jun 2013 | JP |
Entry |
---|
Partial English Translation and Abstract of Chinese Patent Application No. CN103269313, dated Aug. 28, 2015, 2 pages. |
Foreign Communication From a Counterpart Application, PCT Application No. PCT/CN2014/081244, International Search Report dated Mar. 31, 2015, 7 pages. |
Foreign Communication From a Counterpart Application, PCT Application No. PCT/CN2014/081244, Written Opinion dated Mar. 31, 2015, 4 pages. |
Foreign Communication From a Counterpart Application, European Application No. 14883530.9, Extended European Search Report dated May 12, 2016, 7 pages. |
Foreign Communication From a Counterpart Application, Japanese Application No. 2016-530319, Japanese Notice of Allowance dated Dec. 13, 2016, 3 pages. |
Number | Date | Country | |
---|---|---|---|
20150381749 A1 | Dec 2015 | US |
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2014/081244 | Jun 2014 | US |
Child | 14832100 | US |