Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described in further detail below with reference to the accompanying drawings, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Fig. 1 shows a schematic structure of a terminal 100. It should be understood that the terminal 100 shown in fig. 1 is only one example, and that the terminal 100 may have more or fewer components than shown in fig. 1, may combine two or more components, or may have a different configuration of components. The various components shown in the figures may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and/or application specific integrated circuits.
A hardware configuration block diagram of the terminal 100 according to an exemplary embodiment is exemplarily shown in fig. 1. As shown in fig. 1, the terminal 100 includes Radio Frequency (RF) circuit 110, memory 120, display unit 130, camera 140, sensor 150, audio circuit 160, wireless fidelity (WIRELESS FIDELITY, wi-Fi) module 170, processor 180, bluetooth module 181, and power supply 190.
The RF circuit 110 may be used for receiving and transmitting signals during the process of receiving and transmitting information or communication, may receive downlink data from the base station and then transmit the downlink data to the processor 180 for processing, and may transmit uplink data to the base station. Typically, RF circuitry includes, but is not limited to, antennas, at least one amplifier, transceivers, couplers, low noise amplifiers, diplexers, and the like.
Memory 120 may be used to store software programs and data. The processor 180 performs various functions of the terminal 100 and data processing by running software programs or data stored in the memory 120. Memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. The memory 120 stores an operating system that enables the terminal 100 to operate. The memory 120 in the present application may store an operating system and various application programs, and may also store program codes for executing the power saving method of the terminal according to the embodiment of the present application.
The display unit 130 may be used to receive input digital or character information, generate signal inputs related to user settings and function control of the terminal 100, and in particular, the display unit 130 may include a touch screen 131 provided at the front surface of the terminal 100, and collect touch operations thereon or thereabout by a user, such as clicking a button.
The display unit 130 may also be used to display information input by a user or information provided to the user and a graphical user interface (GRAPHICAL USER INTERFACE, GUI) of various menus of the terminal 100. In particular, the display unit 130 may include a display 132 disposed on the front of the terminal 100. The display 132 may be configured in the form of a liquid crystal display, light emitting diodes, or the like. The display unit 130 may be used to display a screen display area of the terminal in the present application.
The touch screen 131 may cover the display screen 132, or the touch screen 131 and the display screen 132 may be integrated to implement input and output functions of the terminal 100, and after integration, the touch screen may be simply referred to as a touch display screen. The display unit 130 may display the application program and the corresponding operation steps in the present application.
The camera 140 may be used to capture still images or video. The object generates an optical image through the lens and projects the optical image onto the photosensitive element. The photosensitive element may be a charge coupled device (charge coupled device, CCD) or a Complementary Metal Oxide Semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, which is then transferred to the processor 180 for conversion into a digital image signal.
The terminal 100 may further include at least one sensor 150, such as an acceleration sensor 151, a distance sensor 152, a fingerprint sensor 153, a temperature sensor 154. The terminal 100 may also be configured with other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, light sensors, motion sensors, and the like.
Audio circuitry 160, speaker 161, microphone 162 can provide an audio interface between the user and terminal 100. The audio circuit 160 may transmit the received electrical signal converted from audio data to the speaker 161, and the speaker 161 converts the electrical signal into a sound signal and outputs the sound signal. The terminal 100 may also be provided with a volume button for adjusting the volume of the sound signal, and may also be used for combining other buttons to adjust the enclosed area. On the other hand, the microphone 162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 160 and converted into audio data, which is output to the RF circuit 110 for transmission to, for example, another terminal, or to the memory 120 for further processing.
Wi-Fi belongs to a short-range wireless transmission technology, and the terminal 100 can help a user to send and receive e-mail, browse web pages, access streaming media and the like through the Wi-Fi module 170, so that wireless broadband internet access is provided for the user.
The processor 180 is a control center of the terminal 100, connects various parts of the entire terminal using various interfaces and lines, and performs various functions of the terminal 100 and processes data by running or executing software programs stored in the memory 120 and calling data stored in the memory 120. In some embodiments, the processor 180 may include one or more processing units, and the processor 180 may also integrate an application processor and a baseband processor, wherein the application processor primarily processes operating systems, user interfaces, application programs, and the like, and the baseband processor primarily processes wireless communications. It will be appreciated that the baseband processor described above may not be integrated into the processor 180. The processor 180 of the present application may run an operating system, an application program, a user interface display and a touch response, and a power saving method of the terminal according to the embodiment of the present application. In addition, the processor 180 is coupled with the display unit 130.
The bluetooth module 181 is configured to perform information interaction with other bluetooth devices having a bluetooth module through a bluetooth protocol. For example, the terminal 100 may establish a bluetooth connection with a wearable electronic device (e.g., a smart watch) also provided with a bluetooth module through the bluetooth module 181, thereby performing data interaction.
The terminal 100 also includes a power supply 190 (e.g., a battery) that provides power to the various components. The power supply may be logically connected to the processor 180 through a power management system, so that functions of managing charge, discharge, power consumption, etc. are implemented through the power management system. The terminal 100 may also be configured with power buttons for powering on and off the terminal, and for locking the screen, etc.
Fig. 2 is a block diagram of a software architecture of a terminal 100 according to an embodiment of the present application.
The layered architecture divides the software into several layers, each with distinct roles and branches. The layers communicate with each other through a software interface. In some embodiments, the Android system may be divided into four layers, from top to bottom, an application layer, an application framework layer, an Zhuoyun rows (Android runtime) and system libraries, and a kernel layer, respectively.
The application layer may include a series of application packages.
As shown in fig. 2, the application package may include applications such as phone, multimedia message, wi-Fi, weChat, information, alarm clock, gallery, calendar, WLAN, etc.
The application framework layer provides an application programming interface (application programming interface, API) and programming framework for the application of the application layer. The application framework layer includes a number of predefined functions.
As shown in FIG. 2, the application framework layer may include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.
The window manager is used for managing window programs. The window manager can acquire the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like.
The content provider is used to store and retrieve data and make such data accessible to applications. The data may include video, images, audio, telephone calls made and received, browsing history and bookmarks, phonebooks, short messages, etc.
The view system includes visual controls, such as controls to display text, controls to display pictures, and the like. The view system may be used to build applications. The display interface may be composed of one or more views. For example, a display interface including a short message notification icon may include a view displaying text and a view displaying a picture.
The telephony manager is used to provide the communication functions of the terminal 100. Such as the management of call status (including on, hung-up, etc.).
The resource manager provides various resources for the application program, such as localization strings, icons, pictures, layout files, video files, and the like.
The notification manager allows the application to display notification information (e.g., the message content of a short message) in a status bar, can be used to communicate notification type messages, can automatically disappear after a short dwell, and does not require user interaction. Such as notification manager is used to inform that the download is complete, message alerts, etc. The notification manager may also be a notification in the form of a chart or scroll bar text that appears on the system top status bar, such as a notification of a background running application, or a notification that appears on the screen in the form of a dialog window. For example, a text message is prompted in a status bar, a prompt tone is emitted, the terminal vibrates, and an indicator light blinks.
Android run time includes a core library and virtual machines. Android runtime is responsible for scheduling and management of the android system.
The core library comprises two parts, wherein one part is a function required to be called by java language, and the other part is an android core library.
The application layer and the application framework layer run in a virtual machine. The virtual machine executes java files of the application program layer and the application program framework layer as binary files. The virtual machine is used for executing the functions of object life cycle management, stack management, thread management, security and exception management, garbage collection and the like.
The system library may include a plurality of functional modules. Such as surface manager (surface manager), media library (Media Libraries), three-dimensional graphics processing library (e.g., openGL ES), 2D graphics engine (e.g., SGL), etc.
The surface manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
Media libraries support a variety of commonly used audio, video format playback and recording, still image files, and the like. The media library may support a variety of audio and video encoding formats, such as MPEG4, h.264, MP3, AAC, AMR, JPG, PNG, etc.
The three-dimensional graphic processing library is used for realizing three-dimensional graphic drawing, image rendering, synthesis, layer processing and the like.
A 2D (one way of animation) graphics engine is a drawing engine for 2D drawing.
The kernel layer is a layer between hardware and software. The inner core layer at least comprises a display driver, a camera driver, an audio driver and a sensor driver.
The terminal 100 in the embodiment of the present application may be an electronic device including, but not limited to, a smart phone, a tablet computer, a wearable electronic device (e.g., a smart watch), a notebook computer, and the like.
In this embodiment of the present application, the terminal shown in fig. 1 or fig. 2 may further receive a data packet sent by a first device through a target network, obtain a destination IP carried in the data packet, search, according to a stored correspondence between a network port of each network and the destination IP, a target network port corresponding to the destination IP, and send the data packet to a second device corresponding to the destination IP according to the target network port.
In order to enable a terminal to realize multi-network intercommunication when forwarding a data packet, the embodiment of the application provides a data packet sending method, a data packet sending device, a data packet sending terminal and a data packet medium.
Fig. 3 is a schematic diagram of a data packet sending process according to an embodiment of the present application, where the process includes:
s301, receiving a data packet sent by a first device through a target network, and acquiring a target IP carried in the data packet.
The data packet sending method provided by the embodiment of the application is applied to a terminal, and the terminal can be the terminal shown in fig. 1 or fig. 2.
The Android system in the terminal is an operating system based on the linux system, and in terms of network management, compared with the linux system, some restrictions are added in the Android system, so that the terminal using the Android system does not support simultaneous use of a plurality of networks and the networks cannot be communicated with each other. However, in the fields of security and protection, there are many application scenarios that need to use multiple networks for concurrency, for example, fig. 4 is an application scenario of a terminal provided by an embodiment of the present application, as shown in fig. 4, P50 is a terminal using an Android system, where the terminal is connected to two image capturing devices through two ethernet lines respectively, and the terminal is also connected to a router through Wi-Fi, and the router is connected to a notebook. In the application scenario shown in fig. 4, the terminal has a need of forwarding the data packet between different networks, that is, the terminal receives the data packet sent by any image acquisition device, and needs to send the data packet to the notebook.
In the embodiment of the present application, the device that sends the data packet to the terminal is referred to as a first device, and the device that receives the data packet sent by the terminal is referred to as a second device. Specifically, the first device sends a data packet to be forwarded by the terminal to the terminal, the terminal receives the data packet, and the data packet carries a destination IP, where the destination IP is an IP address of a forwarding object of the terminal, that is, an IP address of a second device that finally receives the data packet. The terminal obtains the destination IP carried in the data packet, and sends the data packet to the second device based on the destination IP.
In order to distinguish the network used when the first device sends the data packet to the terminal, the network is called a target network in the embodiment of the present application. The target network may be an ethernet, wi-Fi, or mobile network, among others.
S302, searching a target network port corresponding to the target IP according to the stored corresponding relation between the network port of each network and the target IP.
In the embodiment of the application, the terminal can be connected with a plurality of networks, wherein the terminal stores the network port corresponding to each network, and when the terminal sends the data packet through any network, the terminal sends the data packet based on the network port corresponding to the network. Typically, a network corresponds to a network port.
The corresponding relation between the network port of each network and the preset field of the destination IP is stored in the terminal, for example, the network ports of Wi-Fi corresponding to the destination IP with the first 24 fields as a certain value are stored in the terminal. The terminal may determine a destination network port used when sending the data packet based on the correspondence and a destination IP carried in the received data packet, and send the data packet based on the destination network port.
In the embodiment of the present application, the target network port may be a network port corresponding to a target network used by the first device, or may be a network port corresponding to another network.
And S303, sending the data packet to second equipment corresponding to the destination IP according to the destination network port.
After determining the target network port, the terminal sends a data packet to the second device corresponding to the target IP according to the target network port. Specifically, in the embodiment of the present application, the terminal determines, according to the target network port, a second device corresponding to the target IP, and sends the data packet to the second device.
In the embodiment of the application, the corresponding relation between the network port of each network and the destination IP is stored in the terminal, after the terminal receives the data packet sent by the first device through the destination network, the terminal searches the destination network port corresponding to the destination IP in the corresponding relation according to the destination IP carried in the data packet, and sends the data packet to the second device corresponding to the destination IP through the destination network port. In the embodiment of the application, even if the first equipment and the second equipment are positioned in two different networks, the terminal can forward the data packet, thereby realizing the multi-network intercommunication of the terminal.
In order to achieve multi-network interworking of the terminal, based on the above embodiment, in the embodiment of the present application, a procedure for storing a correspondence between a network port of each network and a destination IP includes:
if an input target instruction for storing the corresponding relation between the network port of each network and the target IP is received, determining a stored routing table corresponding to each network;
Acquiring other routing rules except a default routing rule in each routing table, wherein each other routing rule stores the corresponding relation between the numerical value of a preset field of the target IP and the network port;
And adding other routing rules in each routing table to a preset local routing table, and deleting the corresponding other routing rules in each routing table.
According to the embodiment, the Android system in the terminal is an operating system based on the linux system, and one policy table and a plurality of routing tables are stored in the linux system, wherein the terminal selects the routing table through the policy table, and 3 rules are defaulted in the policy table.
Fig. 5 is a schematic diagram of a policy table of a linux system according to an embodiment of the present application, where, as shown in fig. 5, a number in a first column of each rule is a priority corresponding to the rule, and the smaller the number is, the higher the priority is, the linux system preferentially accesses a rule with a high priority, and a last column of each rule is a name of a routing table corresponding to the rule. The local routing table stores the routing rule when the target IP is the IP of the terminal, and the local routing table is very special and cannot be deleted or covered; the main routing table is a general table for storing routes of networks connected to the linux system, such as ethernet, wi-Fi, and the like. defaults are an empty table that is reserved for some subsequent processing.
The meaning of each rule is that a packet sent from a (from) address (all) queries (look up) a specified routing table. For example, the first rule refers to a local routing table for data packets sent from any address, the second rule refers to a main routing table for data packets sent from any address, and the second rule refers to an default routing table for data packets sent from any address.
The main routing table of the linux system contains various routing rules, the routing rules are matched with the destination IP carried in the data packet, and if the destination IP carried in the data packet accords with a certain routing rule, the linux system sends the data packet from a network port corresponding to the routing rule.
Fig. 6 is a schematic diagram of a main routing table of a linux system according to an embodiment of the present application, where, as shown in fig. 6, the main routing table includes two routing rules, and the routing rule corresponding to 192.168.120.0/24 indicates that a first 24-bit data packet of a destination IP is 192.168.120 and sent out from a network port eth1, and the other default rule is a default routing rule, and when the destination IP carried in the data packet does not conform to the routing rule corresponding to 192.168.120.0/24, forwarding is performed according to the default routing rule.
The policy table and the routing table of the linux system exist in the Android system, but unlike the linux system, the linux system stores the routing rule of each network into a main routing table, and the Android system establishes a routing table for each network respectively, wherein the policy table of the Android system corresponds to each routing table. This results in the problem that after a terminal using the Android system receives a data packet sent by a device based on a certain network, the terminal will query a corresponding routing table of the network, that is, the terminal will send the data packet using a network port corresponding to the network or a default network port corresponding to the network, that is, the terminal in the prior art does not support multi-network interworking.
Fig. 7 is a schematic diagram of a policy table in a terminal provided in an embodiment of the present application, where, as shown in fig. 7, policy rules are set in the policy table of the terminal for each network, the terminal is connected to two ethernet networks, network ports corresponding to the two ethernet networks are eth0 and eth1, respectively, the terminal is also connected to Wi-Fi, and a network port corresponding to the Wi-Fi is wlan0. The ethernet network with the network port being eth0 corresponds to a routing table named 1027, the ethernet network with the network port being eth1 corresponds to a routing table named 1028, and the Wi-Fi network with the network port being wlan0 corresponds to a routing table named 1029.
On the basis of fig. 7, fig. 8 is a schematic diagram of a terminal named 1029 in a terminal provided by the embodiment of the present application, where, as shown in fig. 8, the routing table includes two routing rules, and the routing rule corresponding to 192.168.36.0/24 indicates that a data packet with the first 24 bits of the destination IP being 192.168.36 is sent out from a wlan0 of the network port, and the other default rule is a default routing rule, and when the destination IP carried in the data packet does not conform to the routing rule corresponding to 192.168.36.0/24, forwarding is performed according to the default routing rule.
Based on this, in the embodiment of the present application, in order to enable the terminal to implement multi-network interworking, a technician may input, to the terminal, a target instruction for storing a correspondence between a network port of each network and a destination IP, and after the terminal receives the target instruction, the terminal stores, according to an operation corresponding to the target instruction, other routing rules corresponding to each network except for a default routing rule in a local routing table higher in priority than a routing table of each network. Therefore, when the terminal receives the data packet and inquires the routing rule in the routing table, the terminal can inquire the local routing table containing the routing rule of each network preferentially, and multi-network intercommunication of the terminal is further realized.
Specifically, in the embodiment of the present application, after receiving an input target instruction for storing the correspondence between the network port of each network and the destination IP, the terminal determines the stored routing table corresponding to each network, and obtains the routing rules other than the default routing rule in each routing table. The terminal adds other routing rules in each routing table to a preset local routing table, and deletes the other routing rules in each routing table.
In the embodiment of the present application, each other routing rule stores a correspondence between a value of a preset field of the destination IP and a network port. For example, the destination IP of 192.168.36 for the first 24 bits corresponds to network port wlan0, etc.
In the prior art, a routing table is established for each network, and after the terminal receives a data packet sent by a device based on a certain network, the terminal queries two public routing tables, namely the first two rules in fig. 7, the local routing table and the routing table named 99, in addition to the corresponding routing table of the network. The local routing table is the same as the local routing table in the linux system, is default and not allowed to be modified, and does not influence the selection of the network ports by the terminal. The routing table named 99 is actually a legacy_system routing table, which is also a common routing table, but is blank, and based on this feature of the legacy_system routing table, in the embodiment of the present application, the legacy_system routing table is determined as a preset local routing table, that is, in the embodiment of the present application, other routing rules in each routing table are added to the legacy_system routing table.
Fig. 9 is a schematic diagram of a legacy_system routing table with other routing rules added to each routing table according to an embodiment of the present application, where, as shown in fig. 9, two ethernet networks and other routing rules in one Wi-Fi network routing table are both added to the legacy_system table. If the network port is the routing rule of 192.168.1.0/24 corresponding to the Ethernet of eth0, the network port is the routing rule of 192.168.2.0/24 corresponding to the Ethernet of eth1, and the network port is the routing rule of 192.168.36.0/24 corresponding to the Wi-Fi of wlan 0.
In order to find a target network port corresponding to a destination IP, so that a terminal may send a data packet based on the target network port, on the basis of the foregoing embodiments, in the embodiment of the present application, the searching for the target network port corresponding to the destination IP according to the stored correspondence between the network port of each network and the destination IP includes:
accessing the local routing table, and acquiring each routing rule stored in the local routing table;
and determining a target network port corresponding to the target value of the preset field of the target IP according to the corresponding relation between the value of the preset field of the target IP and the network port stored in each routing rule.
As can be seen from the above embodiments, the local routing table preset in the terminal stores other routing rules except the default routing rule corresponding to each network. Based on this, in the embodiment of the present application, after the terminal obtains the destination IP carried in the data packet, the terminal accesses the local routing table and obtains each routing rule stored in the local routing table.
In the embodiment of the present application, the correspondence between the value of the preset field of the destination IP and the network port is stored in each routing rule, and the terminal may search the target network port corresponding to the target value in the correspondence according to the target value of the preset field of the destination IP carried in the data packet.
For example, the routing rule stored in the local routing table of the terminal is that the destination IP with the first 24 bits of 192.168.1.0 corresponds to the network port eth0, the destination IP with the first 24 bits of 192.168.2.0 corresponds to the network port eth1, and the destination IP with the first 24 bits of 192.168.36.0 corresponds to the network port wlan0.
In order to achieve the sending of the data packet, based on the foregoing embodiments, in the embodiment of the present application, if the target network port is not found, the method further includes:
Determining a first routing table corresponding to the stored target network, and acquiring a default routing rule stored in the first routing table;
And sending the data packet to the second equipment corresponding to the target IP according to the default port stored in the default routing rule.
In the embodiment of the application, if the terminal does not find the target network port corresponding to the target IP in the preset local routing table, the terminal sends the data packet by using the default port corresponding to the target network.
Specifically, in the embodiment of the present application, if the terminal does not find the target network port corresponding to the target IPI in the preset local routing table, the terminal determines the stored first routing table corresponding to the target network, and obtains the default routing rule stored in the first routing table. And the terminal sends the data packet to the second equipment corresponding to the target IP according to the default port stored in the default routing rule.
In order to enable each network in the terminal to be in an online state, so as to realize multi-network interworking, in the embodiments of the present application, before receiving a data packet sent by the first device through the first network, the method further includes:
Receiving an input starting instruction and starting;
and setting the current state of each network to be online according to the preset request message corresponding to each network.
In the related art, a terminal allows only one network to be on-line even though the terminal is connected to a plurality of networks. Specifically, the terminal will match the appropriate network according to the received network request, and make the matched network online, and make other networks offline. The network request can specify various attributes of the network, such as transmission type, internet surfing capability and the like, for example, if the network request specifies that the internet surfing capability is required, the terminal can provide the internet surfing capability according to whether each network can provide the internet surfing capability when matching the network, if the Ethernet, wi-Fi or data all meet the requirements, the network with high priority is online, and if the network request specifies that the transmission type uses Wi-Fi, only the Wi-Fi meets the requirements, and the terminal can enable the Wi-Fi to be online.
Based on this, in the embodiment of the present application, the technician stores the request message of the network request corresponding to each network in the terminal in advance, and the terminal makes the network corresponding to each network request online according to each network request, thereby realizing the multi-network online of the terminal.
Specifically, a request message of a network request corresponding to each network is preconfigured in the terminal, and after the terminal receives a starting instruction to start, the terminal triggers the request message of each network request and sets the current state of each network to be on-line. If a terminal is newly connected to a network in a starting state, a technician is required to write a request message of a network request corresponding to the new network into the terminal.
For example, if there are two ethernet networks in the terminal, and one Wi-Fi, the technician will configure a request packet corresponding to three network requests, where two network requests specify that the transmission type of the network is ethernet, and the other network request specifies that the transmission type of the network is Wi-Fi. When the two ethernets exist in the terminal, a limitation condition of a network port corresponding to each ethernet can be added in a request message corresponding to each ethernet, or a corresponding relation between the request message corresponding to each ethernet and the network port can be saved. If the first network request of the first ethernet is a first network request, a network port eth0 corresponding to the first ethernet may be written in a first request packet of the first network request, or a correspondence between the first network request and the network port eth0 may be stored in the terminal, based on which, when the terminal executes the first request packet corresponding to the first network request, the first ethernet with the network port eth0 is online.
In addition, in the embodiment of the application, a routing forwarding function exists in the terminal, and the routing forwarding function is a function for enabling the terminal to execute forwarding of the data packet. Specifically, if the routing forwarding function is not started in the terminal, after the terminal receives the data packet sent by the first device, the terminal acquires the destination IP carried in the data packet, if the destination IP is inconsistent with the IP of the terminal, the terminal discards the data packet, and correspondingly, if the routing forwarding function is started in the terminal, if the terminal recognizes that the destination IP is inconsistent with the IP of the terminal, the terminal forwards the data packet. The terminal stores the interface corresponding to the route forwarding function, and if the route forwarding function needs to be started, the terminal calls the interface.
In order to achieve multi-network interworking of the terminals, on the basis of the above embodiments, in the embodiment of the present application, the method further includes:
If the current mode is a multi-network intercommunication mode, judging whether contents are stored in the iptables or not;
If yes, copying the content stored in the iptables into a preset target folder, and deleting the content in the iptables.
In the embodiment of the application, the terminal also stores iptables, wherein the iptables stores a rule which limits the multi-network intercommunication of the terminal. Based on this, if multi-network interworking of the terminals is to be realized, the rule in the iptables needs to be deleted.
Specifically, in the embodiment of the present application, the terminal identifies whether the current mode is a multi-network interworking mode, if so, the terminal determines whether content exists in the iptables, if so, the terminal copies the content stored in the iptables to a preset target folder, and deletes the content in the iptables.
When the terminal identifies whether the current mode is the multi-network intercommunication mode, the terminal can judge whether the route forwarding function is started currently. Generally, the preset target folder is a folder created by a technician under the data directory of the terminal, and the preset file may be named as iptables_sav.dat, and then the path question/data/iptables_sav.dat of the preset folder.
When copying the content stored in the iptables into a preset target folder and deleting the content in the iptables, the terminal can be realized by the following procedures:
iptables-save>/data/iptables_sav.dat
iptables–F
In order to close the multi-network interworking of the terminal, based on the above embodiments, in the embodiment of the present application, the method further includes:
if the current mode is a non-multi-network intercommunication mode, judging whether contents are stored in the iptables or not;
if not, copying the content stored in the preset target folder to the iptables, and deleting the content in the target folder.
Based on the above embodiment, in the embodiment of the present application, if the terminal identifies that the route forwarding function is not currently turned on, that is, the current mode of the terminal is a non-multi-network interworking mode, the terminal determines whether content is stored in the iptables, and if not, the terminal copies the content stored in the preset target folder to the iptables, and deletes the content in the target folder.
The terminal copies the content stored in the preset target folder to the iptables, and deletes the content in the target folder, which can be realized by the following procedures:
iptables-restore</data/iptables_sav.dat
iptables_sav.dat–F
the following describes a packet forwarding method according to an embodiment of the present application with reference to a specific embodiment:
Fig. 10 is a schematic flow chart of packet forwarding according to an embodiment of the present application, where, as shown in fig. 10, the process includes:
S1001, receiving an input starting instruction and starting.
And the user sends a starting instruction to the terminal through an external key of the terminal, and the terminal starts after receiving the starting instruction.
S1002, setting the current state of each network to be on-line according to a preset request message corresponding to each network.
The terminal obtains a preset request message corresponding to each network, and sets the current state of the network corresponding to each request message to be on-line according to each request message.
S1003, the terminal starts a route forwarding function.
The terminal calls an interface corresponding to the route forwarding function, and opens the route forwarding function, so that the terminal can support multi-network intercommunication.
And S1004, copying the content stored in the iptables into a preset target folder, and deleting the content in the iptables.
The terminal copies the content stored in the iptables into a preset target folder, and deletes the content in the iptables, so that the terminal is not limited by rules in the iptables, and multi-network intercommunication of the terminal is realized.
S1005, a data packet sent by the first device through the target network is received, and a target IP carried in the data packet is obtained.
The terminal receives a data packet sent by the first device through the target network, acquires a target IP carried in the data packet, and forwards the data packet if the target IP is inconsistent with the IP of the terminal.
S1006, accessing the local routing table, obtaining each routing rule stored in the local routing table, and determining a target network port corresponding to the target value of the preset field of the target IP according to the corresponding relation between the value of the preset field of the target IP stored in each routing rule and the network port.
The terminal obtains the target value of the preset field of the destination IP, accesses the local routing table, and stores each routing rule in the local routing table. And the terminal determines a target network port corresponding to the target value according to the corresponding relation between the value of the preset field of the target IP stored in each routing rule and the network port.
And S1007, according to the target network port, the data packet is sent to the second equipment corresponding to the target IP.
Fig. 11 is a schematic structural diagram of a data packet sending device according to an embodiment of the present application, where, as shown in fig. 11, the device includes:
A receiving module 1101, configured to receive a data packet sent by a first device through a target network;
the processing module 1102 is configured to obtain a destination IP carried in the data packet, and find a target network port corresponding to the destination IP according to a stored correspondence between a network port of each network and the destination IP;
And a sending module 1103, configured to send the data packet to a second device corresponding to the destination IP according to the destination network port.
In a possible implementation manner, the processing module 1102 is specifically configured to determine, if an input target instruction for storing a correspondence between a network port and a destination IP of each network is received, a routing table corresponding to each stored network, obtain other routing rules in each routing table except for a default routing rule, where a correspondence between a value of a preset field of the destination IP and the network port is stored in each other routing rule, add the other routing rules in each routing table to a preset local routing table, and delete the corresponding other routing rules in each routing table.
In a possible implementation manner, the processing module 1102 is specifically configured to access the local routing table, obtain each routing rule stored in the local routing table, and determine, according to a correspondence between a value of a preset field of a destination IP stored in each routing rule and a network port, a target network port corresponding to a target value of the preset field of the destination IP.
In a possible implementation manner, the processing module 1102 is further configured to determine a first routing table corresponding to the stored target network, and obtain a default routing rule stored in the first routing table;
the sending module 1103 is further configured to send the data packet to a second device corresponding to the destination IP according to a default port stored in the default routing rule.
In a possible implementation manner, the receiving module 1101 is further configured to receive an input power-on command to perform power-on;
the processing module 1102 is further configured to set the current state of each network to be online according to a preset request packet corresponding to each network.
In a possible implementation manner, the processing module 1102 is further configured to determine whether content is stored in the iptables if the current mode is a multi-network interworking mode, and if so, copy the content stored in the iptables to a preset target folder, and delete the content in the iptables.
In a possible implementation manner, the processing module 1102 is further configured to determine whether content is stored in the iptables if the current mode is a non-multi-network interworking mode, and copy, if not, content stored in a preset target folder to the iptables, and delete the content in the target folder.
Based on the same inventive concept, fig. 12 is another schematic structural diagram of a terminal according to an embodiment of the present application, as shown in fig. 12, including one or more (including two) processors 1201 and a communication interface 1202.
Optionally, the terminal further comprises a memory 1203, which memory 1203 may comprise read only memory and random access memory, and provide operating instructions and data to the processor. A portion of the memory may also include non-volatile random access memory (non-volatile random access memory, NVRAM).
In some implementations, as shown in FIG. 12, the memory 1203 stores elements, execution modules or data structures, or a subset thereof, or an extended set thereof.
As shown in fig. 12, in some embodiments of the present application, the corresponding operation is performed by calling an operation instruction stored in the memory 1203 (which may be stored in an operating system).
As shown in fig. 12, a processor 1201 controls the processing operations of the headend device, which may also be referred to as a central processing unit (central processing unit, CPU).
As shown in fig. 12, the memory 1203 may include a read only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory 1203 may also include NVRAM. Such as an application communication interface and memory, are coupled together by a bus system 1204, where the bus system 1204 may include a power bus, a control bus, a status signal bus, etc., in addition to a data bus. But for clarity of illustration, the various buses are labeled as bus system 1204 in fig. 12.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.