WO2013086928A1 - 一种互联方法、装置和*** - Google Patents

一种互联方法、装置和*** Download PDF

Info

Publication number
WO2013086928A1
WO2013086928A1 PCT/CN2012/085060 CN2012085060W WO2013086928A1 WO 2013086928 A1 WO2013086928 A1 WO 2013086928A1 CN 2012085060 W CN2012085060 W CN 2012085060W WO 2013086928 A1 WO2013086928 A1 WO 2013086928A1
Authority
WO
WIPO (PCT)
Prior art keywords
socket
function
remote
address
server
Prior art date
Application number
PCT/CN2012/085060
Other languages
English (en)
French (fr)
Inventor
周日明
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP12857411.8A priority Critical patent/EP2712127A4/en
Publication of WO2013086928A1 publication Critical patent/WO2013086928A1/zh
Priority to US14/143,433 priority patent/US9137334B2/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/30Definitions, standards or architectural aspects of layered protocol stacks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/2592Translation of Internet protocol [IP] addresses using tunnelling or encapsulation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Definitions

  • the present invention relates to the field of communications, and in particular, to an interconnection method, apparatus, and system.
  • the two machines are connected through the switch device to realize mutual access of more than two machines, which constitutes a local area network.
  • the switch device because of the small number of machines, it is easy to configure the IP address of each machine, and there are few conflicts.
  • two machines can access each other directly based on IP addresses.
  • the public network is based on a global or multinational, inter-provincial network.
  • a large number of machines are running. If each machine needs to occupy an IP address, it will consume a large amount of IP address resources.
  • NAT Network Addres s Translating
  • the source machine and the destination end machine that send and receive IP packets
  • the system level corresponds to the data link layer and the physical layer
  • the operating system (Operatium Signal) is used to process the transport layer and the network layer
  • the operating system also provides a socket programming interface (Socket API) to develop specific for the business client.
  • Application protocol The business client corresponds to the application layer protocol.
  • the Socket API is a set of functions that the operating system provides to applications for developing web applications.
  • the virtual network card technology is generally used to interconnect the service client in one local area network with the service server in another local area network on the public network.
  • the virtual network card technology loads an IP packet hook at the operating system layer of the client and the server, and hooks the IP packet of the specific destination address and sends it through the tunnel.
  • Virtual NIC technology adds a virtual NIC layer between the operating system and the physical NIC for The IP packet sent by the operating system to the network card is intercepted, and the specific IP packet is converted, thereby interconnecting the service client and the service server.
  • the virtual network card technology can be used to interconnect the service client in one LAN with the service server in another LAN on the public network, but the technology has the following technical defects:
  • the virtual network card is a process running in the kernel.
  • the software conflicts are relatively large, and the system compatibility and stability are not good.
  • the present invention provides a LAN traversal technical solution based on Socket remote call, which realizes that the service client remotely calls the Socket in the server LAN, and communicates with the server as in the same local area network.
  • the embodiments of the present invention provide a method, an apparatus, and a system for interconnecting a service client in a local area network with a service server in another local area network on a public network.
  • an embodiment of the present invention provides an interconnection method, where the method includes:
  • the message structure is sent such that the remote socket Socekt invokes the server to execute a second Socket API function corresponding to the first Socket API function in the message structure.
  • an embodiment of the present invention provides an interconnection apparatus, where the apparatus includes:
  • An obtaining unit configured to obtain information of a first socket programming interface Socket API function invoked by a business client
  • Encapsulating unit the information used to encapsulate the first Socket API function is a message structure;
  • a sending unit configured to send the message structure, so that the remote socket Socekt invokes the server to execute a second Socket API function corresponding to the first Socket API function in the message structure.
  • an embodiment of the present invention provides an interconnection system, where the system includes the foregoing interconnection device, a remote Socket calling server, a service client, and a service server; and the remote Socket calling server executes a message structure sent by the interconnection device.
  • a second Socket API function corresponding to the first Socket API function in the body, so that the service client in the first local area network and the service server in the second local area network are interconnected on the public network.
  • the remote Socket calling server is in the second local area network, and the second local area network is in the public network.
  • the embodiment of the invention provides an interconnection method, device and system, wherein an HTTP tunnel and a Socket connection are established between a remote Socket calling client component and a remote Socket calling server, and a remote socket calling client component and a remote socket call are implemented.
  • the server is interconnected by the service servers within the same local area network.
  • the remote Socket calls the client and the remote Socket calls the server to implement remote Socket calls based on the application layer, without changing the operating system, network characteristics, and without paying attention to the network protocol, which is very simple.
  • FIG. 2 is a schematic diagram of an implementation principle of interconnecting a service client and a service server in a virtual network card technology
  • FIG. 3 is a flowchart of a method for interconnecting according to Embodiment 1 of the present invention
  • FIG. 4 is a schematic diagram of a layered structure and a network layered structure of a host in a remote Socket technology according to an embodiment of the present invention
  • FIG. 5 is a schematic diagram of an implementation of an interconnection according to Embodiment 2 of the present invention.
  • FIG. 6 is a flowchart of a method for interconnecting according to Embodiment 3 of the present invention.
  • Figure ⁇ is a schematic diagram of a process of a complete remote Socket call according to Embodiment 4 of the present invention.
  • FIG. 8 is a schematic diagram of an interconnected device according to Embodiment 5 of the present invention.
  • FIG. 9 is a schematic diagram of another interconnected device according to Embodiment 6 of the present invention.
  • the virtual NIC technology is implemented in the operating system, and a virtual NIC is added between the operating system and the physical NIC.
  • the virtual NIC is used to intercept the IP packets sent by the operating system to the physical NIC and convert the specific ip packets.
  • FIG 2 is a schematic diagram showing the implementation principle of the interconnection between the service client and the service server in the virtual network card technology. As shown in Figure 1:
  • Step 1 When the service client invokes the operating system to send an RTP (Real Time Transport Protocol) packet, the operating system packages it into an I P packet.
  • RTP Real Time Transport Protocol
  • Virtual NIC Construction A new IP packet (which can be an HTTP packet at the application layer) places the original IP packet information in an HTTP packet.
  • the destination address of the new IP packet is the public network address of the virtual NIC server (202. 204. 65. 3).
  • Step 2 The virtual network card calls the physical network card to send the new IP packet to the network.
  • Step 3 The physical NIC routes the new IP packet to the NAT gateway via the LAN.
  • Step 4 The NAT gateway tampers with the source address and source port of the new IP packet to receive the IP packet delivered by the virtual NIC server.
  • Step 5 When the virtual network card server receives an HTTP packet, extract the original IP packet carried by the HTTP packet, and tamper with the source IP address and port of the original IP packet, and change its ⁇ ⁇ to its own internal network address and port. (1 0. 1 0. 2. 1 1 080), then send the IP packet to the service server. When the service server returns an IP packet, it returns through the original channel.
  • the virtual network card technology can reduce the occupation of the NAT port resources by the service client when using the NAT gateway. It can also solve the problem that the SIP (Session Initiation Protocol) cannot be correctly negotiated when the LAN gateway is used to interconnect the public network with the public network. It can also solve the problem that the business client behind the firewall connects to the public network server.
  • the virtual NIC approach has the following technical deficiencies:
  • the virtual network card is a process running in the kernel.
  • the software conflicts are relatively large, and the system compatibility and stability are not good.
  • an embodiment of the present invention provides an interconnection method, apparatus, and system, in which an HTTP tunnel and a Socket connection are established between a remote Socket calling client component and a remote Socket calling server, and a remote socket call is implemented.
  • the client component interacts with the remote Socket call server, and because the remote Socket call client component is a component on the business client, the remote Socket call server runs in the local area network where the service server is located, thus implementing the first local area network.
  • the service client having the remote Socket call server and the service server in the second local area network are interconnected on a public network, the remote Socket calling server is in the second local area network, and the second local area network is in the In the public network.
  • the remote Socket calling client and the remote Socket calling server implement remote Socket calling based on the application layer, without changing the operating system, network characteristics, and without paying attention to the network protocol, achieving a very simple order.
  • FIG. 3 is a flowchart of a method for interconnecting according to Embodiment 1 of the present invention. As shown in Figure 1, this embodiment includes the following steps:
  • Step 301 The remote Socket invokes the client component to obtain information about the first Socket API function invoked by the business client.
  • the business client calls the remote socket to call the Socket API function in the client component.
  • the business client initializes the remote Socket calling client component.
  • the remote Socket call client component starts, an HTTP tunnel is established to call the server device address of the remote Socket on the server side configured in advance, and the remote Socket calls the client component and the remote Socket call server to transmit the network data through the HTTP tunnel.
  • the Socket API function may be a function for creating a Socket connection; or a function for obtaining a free IP address and port of a local area network where the remote socket calls the server; or associating a source IP address, a source port, a destination IP address, a destination port, and The function of the Socket connection, the source IP address and the source port are the idle IP address and port.
  • the destination address and the destination port may be an IP address and a port configured by the service client in advance.
  • the Socket API function may also be a function for performing network data interaction through the Socket connection; or a function for setting or acquiring parameters of the Socket connection; or a function for closing the Socket connection.
  • Step 302 The remote Socket calling client component encapsulates the information of the first Socket API function into a message structure.
  • the remote Socket calling client component encapsulates the Socket API function information called by the application layer into an internal message structure. All information about the Socket API function is included in the message structure. This information includes: function name, source IP address, source port, destination IP address, destination port, and the content of the message.
  • a set of data structures is defined between the remote Socket calling client component and the remote Socket calling server, and the function name and function parameters of the Socket API are encapsulated in the structures for transmitting the service client to call the Socket API. Function information.
  • the structure of the data structure is as follows:
  • the Channel lD corresponds to the Socket connection, and describes the identifier of the Socket connection between the remote Socket calling client and the remote Socket calling server.
  • the Channel ID supports up to 65536 Socket connections, which is equivalent to the number of ports. Channe l lD is 2 bytes in length.
  • Socket API functions for network data interaction can be: send O function, sendto O function, recv () function, recvf rom () function, sel ect () function.
  • Length indicates the length of the Socket API function to encapsulate data, which can describe up to 2048 bytes. The length is 11 bits long.
  • Type represents the enumeration value of the name of the function. Type is 5 digits long. Type can indicate 32 operations, and currently 18 can be used, as shown below:
  • Data represents the content of the data encapsulated by the function.
  • the data length is up to 2048 bytes.
  • the remote socket calls the client component to encapsulate the function as a message structure like this:
  • 11012 is the identifier of the Socket connection; 3 is the length of the Data part, which is the length of "AAA"; 9 is the enumeration value of the send () function; AAA is the message content sent by the send () function.
  • Step 303 The remote Socket calling client component sends the message structure, so that the remote socket Socket call server executes a second Socket API function corresponding to the first Socket API function in the message structure.
  • first Socket API function is a function of the business client
  • second Socket API function is a function corresponding to the first Socket API function of the business client in the business server.
  • the first Socket API function and the second Socket API function have the same functions and the same parameters.
  • the remote Socket calling client component packages the message structure in the first HTTP data packet, and calls the Socket API in the operating system to send the first HTTP data packet; the Socket API will use the first HTTP packet
  • the data packet is generated as a first IP packet; the operating system calls a physical network card, and sends the first IP packet to a NAT (Network Address Translation) gateway; the NAT gateway modifies a source address and a source of the first IP packet
  • the port is the public IP address of the NAT gateway and a new one.
  • the port generates a second IP packet; the second IP packet passes through a public network route and reaches a public network address of the remote Socket calling server.
  • the remote Socket calls the server to unlock the second IP packet received on the public network, and then unpacks the message structure encapsulated by the remote Socket client component, and obtains the Socket API function information that the service client originally wants to call.
  • the remote Socket call server calls the Socket API function that the business client wants to call, calls the local operating system, generates a third IP packet, and sends the third IP packet to the service server.
  • the business server returns the return value to the business client via the remote Socket call server.
  • the remote Socket call server encapsulates the content to be returned in a message structure and returns it to the business client through the HTTP tunnel.
  • the embodiment of the present invention adds a TC-Socket API layer between the service client and the operating system for encapsulating the Socket API.
  • the corresponding relationship between the business client host hierarchy and the network hierarchy is shown in Figure 4:
  • the business client and the TC_Socket API layer correspond to an application layer protocol
  • the operating system is used to process the transport layer and the network layer, and the operating system also provides a Socket API interface for developing a specific application protocol for the service client;
  • the physical NIC corresponds to the data link layer and the physical layer.
  • the first Socket API function in step 301 is specifically: a Socket API function for creating a Socket connection; or a Socket API for obtaining an idle IP address and port of the local area network where the remote socket is called.
  • a Socket API function for associating a source IP address, a source port, a destination IP address, a destination port, and a Socket connection created by the remote socket calling server, the source IP address and the source port being
  • the remote Socket calls the idle IP address and port of the local area network where the server is located, and the destination IP address and the destination port are IP addresses and ports of the service server in the same local area network as the remote Socket calling server; or Used for Socket connection created by the remote socket calling server a function of the data exchange, the source IP address and the source port of the Socket connection are the IP address and port of the local area network where the remote socket is called, and the destination IP address and the destination port of the Socket connection are the remote The Socket calls the IP address and port of the service server in the same LAN on the server.
  • the method further includes receiving a return value of the second Socket API function returned by the remote Socket call server and transmitting the return value to the service client.
  • the return value includes the second Socket API function created by the remote Socket calling server executing the first Socket API function.
  • the Socket connection identifier of the Socket connection when the first Socket API function is specifically a Socket API function for obtaining an idle IP address and a port of the local area where the remote Socket call server is located, the return value includes The remote Socket calling server executes the free IP address and port of the local area network where the remote socket is acquired by the second Socket API function corresponding to the first Socket API function; when the first Socket API When the function is specifically a function for receiving network data through the Socket connection, the return value includes the remote Socket calling server executing a second Socket API function corresponding to the first Socket API function, and receiving the second Socket API function from the service server. Network data.
  • the remote Socket calling server After executing the second creation function to create a Socket connection, the remote Socket calling server returns a Socket connection identifier (Socket ID) of the Socket connection to the remote Socket calling client, and may also record the Channel ID and The association relationship of the Socket ID. After receiving the Socket ID, the remote Socket calling client returns the Socket ID to the service client. Preferably, the remote Socket calling client may further record an association relationship between the Channel ID and the Socket ID.
  • Socket ID Socket connection identifier
  • the remote Socket calling client acquires a first acquiring function invoked by the service client, where the first obtaining function is a Socket API function for acquiring an idle IP address and a port of the local area where the remote Socket calling server is located; Encapsulating the information of the first acquisition function as a second message structure; sending the second message structure to the remote Socket calling server, so that the remote Socket calling server executes the second message structure a second obtaining function corresponding to the first obtaining function to obtain an idle IP address and a port of the local area network where the remote Socket calling server is located; receiving the remote Socket called by the remote Socket calling server to call the idle area of the local area network where the server is located
  • the IP address and the port are sent to the service client;
  • the second message structure may include a Channel ID and a Type field, where the Channel ID field records may be a Channel ID in the first message structure, or Is empty.
  • the name of the first acquisition function can also be directly recorded.
  • the remote Socket calling client acquires a first association function invoked by the service client, where the first association function is an associated source IP address, a source port, a destination IP address, a destination port, and the Socket connection identifier.
  • the Socket connection function, the source IP address and the source port are the returned IP address and port, and the destination IP address and the destination port are IP addresses of service servers in the same local area network as the remote Socket calling server.
  • the information encapsulating the first association function is a third message structure; sending the third message structure to the remote Socket calling server, so that the remote Socket calling server executes the third message a second association function corresponding to the first associated function in the structure is connected to the Socket by associating the source IP address, the source port, the destination IP address, and the destination port; the first association function includes the Socket ID,
  • the third message structure may include a Channel ID, a Type field, and a Data field, where the Channel ID field records may be a Channel ID in the first message structure, or may be from the first association.
  • the Socket ID read in the function if the channel ID is recorded, the remote Socket calling client acquires the Socket ID in the first association function by using the recorded relationship between the Channel ID and the Socket ID.
  • the Type record is 1 .
  • the name of the first association function may also be directly recorded; the source IP address, the source port, the destination IP address, and the destination may be included in the Data field. mouth.
  • the remote socket calling server can obtain the message by using the recorded relationship between the Channel ID and the Socket ID. a Socket ID associated with the Channel ID in the structure, and executing the second association function to associate the source IP address, the source port, the destination IP address, and the destination port with the Socket identified by the Socket ID.
  • the remote Socket calling client acquires a first transfer function invoked by the service client, and the first transfer function is a function for performing network data interaction by using the Socket connection identified by the Socket connection identifier;
  • the information of the first transfer function is a fourth message structure; the fourth message structure is sent to the remote Socket call server, so that the remote Socket call server executes the fourth message structure
  • a second transfer function corresponding to a transfer function performs network data interaction with the service server through the Socket connection.
  • the first transfer function includes the Socket ID
  • the fourth message structure may include a Channel ID and a Type field, where the Channel ID field records may be a Channel ID in the first message structure, or Is the Socket ID read from the first transfer function. If the channel ID is recorded, the remote Socket calling client obtains the first use of the relationship between the recorded Channel ID and the Socket ID.
  • the name of the first transfer function can also be directly recorded.
  • the first transfer function may be a function for sending network data by using the Socke t connection, where the first transfer function further includes network data, and accordingly, the encapsulated fourth message structure also includes The network data. Transmitting, by the remote Socket client, the fourth message structure to the remote Socket call server, so that the remote Socket call server executes a first transfer function corresponding to the first transfer function in the fourth message structure And a second transfer function to send the network data to the service server through the Socket connection.
  • the fourth message structure may further include a Da ta field, and the transmission data may be carried in the Da ta field.
  • the first transfer function may further be a function for receiving network data by using the Socket connection; the remote Socke t calling client sends the fourth message structure to the remote Socke t call server, So that the remote Socket calling server executes a second transfer function corresponding to the first transfer function in the fourth message structure to receive network data from the service server through the Socket connection, and receive the remote Socket call
  • the server executes the first
  • the remote Socket calling client initiates a Hypertext Transfer Protocol HTTP tunnel establishment connection to the remote Socket calling server to establish an HTTP tunnel; and when performing the above steps, through the HTTP
  • the tunnel sends the first message structure, the second message structure, the third message structure, and the fourth message structure.
  • the remote Socket calling client may further receive, by using the HTTP tunnel, the data returned by the remote Socket calling server, such as the Socket connection identifier, the free IP address and port of the local area network where the remote Socket calls the server, and
  • the remote Sockset invokes the server to execute the network data received by the second transfer function.
  • FIG. 5 is a schematic diagram of an implementation of an interconnection according to Embodiment 2 of the present invention. As shown in FIG. 5, the embodiment of the present invention includes the following steps:
  • Step 501 The service client sends a UDP packet, the source address of the UDP packet is 10. 10. 2. 2, the source port is 5060; the destination address is 10. 10. 2. 1 , the destination port is 5060, and the data is "" AAA".
  • the destination address and the destination port may be an IP address and a port configured by the service client in advance.
  • the source address of the UDP packet is not the local IP address of the service client, but the IP address of the server side, that is, the intranet IP address of the remote socket calling the server.
  • the business client when the business client starts, the business client initializes the remote Socket calling client component.
  • the remote Socket call client component starts, an HTTP tunnel is established to the remote Socket calling server device address of the pre-configured server side to establish a connection, and the remote socket calling client component and the remote Socket calling server transmit the network data through the HTTP tunnel.
  • the service client can create a Socket connection by calling a function for creating a Socket connection; calling the free IP address and port of the local area network where the remote Socket call server is located; using the free IP address and port as the source address and the source port; And calling a function that associates the source address, the source port, the destination address, and the destination port with the Socket.
  • Step 502 The remote Socket calling client component encapsulates the Socket API function invoked by the application layer, encapsulates it into an internal message structure, and includes all information of the function in the structure. This information includes the source address 10. 10. 2. 2. Source port 5060, destination address 10. 10. 2. 1. Destination port 5060, message content "AAA”.
  • the remote Socket calls the client component to package the message structure in the first HTTP packet.
  • Step 503 The remote Socket calls the client component to invoke the Socket API in the operating system, and generates the first IP packet by using the packaged first HTTP data packet.
  • the Socket API calls the function of the operating system to generate the first HTTP packet as the first IP packet.
  • the first IP packet includes the client IP address and port, as well as the server's IP address and port.
  • the client source address is 192. 168. 2. 1
  • the source port is 1080
  • the public network address of the server is 202. 204. 65. 3
  • the destination port is 80.
  • Step 504 The operating system invokes a physical network card, and sends the first IP packet to the NAT gateway through the local area network.
  • Step 505 The NAT gateway modifies the source address and port of the first IP packet, and routes the modified second IP packet public network to the public address of the remote Socket calling server.
  • the NAT gateway has two network IP addresses, one is the external network IP address, that is, the public network IP address; the other is the internal IP address, that is, the LAN IP address.
  • the NAT gateway After receiving the first IP packet sent by the local area network, the NAT gateway changes the local area network IP address 192. 168. 2. 1 ⁇ to the public IP address of the NAT gateway 202. 204. 65. 1 , and changes the port 1080 i For a new port 11111.
  • the modified second IP packet has no information on the local area network at all, and can be completely routed on the public network.
  • the NAT gateway routes the second IP packet to the destination host through the public network.
  • the NAT gateway sends the second IP packet, it simultaneously records a message internally, and records the correspondence between 202.204.65. 1 11111 and 192.168. 2. 1 1080.
  • Step 506 The remote Socket calling server unpacks the second IP packet received on the public network, obtains a message structure encapsulated by the remote Socket calling client component, and unpacks the message structure to obtain a service client originally intended to invoke.
  • Socket API function name Send
  • parameter information source address 10. 10. 2. 2, source port 5060, destination address 10. 10. 2. 1 , destination port 5060, and message content "AAA").
  • Step 507 the remote Socket calling server calls the Socket API in the local operating system to generate a third IP packet, and the third IP includes the source IP address 10. 10. 2. 2. Source port 5060, destination IP Address 10. 10. 2. 1. Destination port 5060, message content "AAA”. The third IP packet is sent to the service server corresponding to the destination IP address 10. 10. 2. 1.
  • FIG. 6 is a flowchart of a method for interconnecting according to Embodiment 3 of the present invention. As shown in Figure 6, this embodiment includes the following steps:
  • Step 601 The remote Socket calls the client component to initiate an HTTP tunnel to establish a connection, and establishes an HTTP tunnel.
  • Step 602 The business client invokes the remote socket to call the tc_socket () method of the client component, and creates a Socket connection in the remote socket calling network.
  • the service client calls the remote socket to call the client component method tc_ socket () to establish a Socket connection, and the identifier of the Socket connection is associated with the source IP address, the source port, the destination IP address, and the destination port.
  • Step 603 The remote Socket invokes the client component to obtain information about the first Socket API function invoked by the business client.
  • the business client sends data by calling the remote socket to call the TC_Socket API interface of the client component, and the data content to be sent is included in the first Socket API function.
  • Step 604 The remote Socket calls the client component to encapsulate the function information of the first Socket API as a message structure.
  • the remote Socket call client component encapsulates all the information of the first Socket API function to be called by the business client into a message structure.
  • the information includes: source IP address, source port, destination IP address, destination port, and content of the message.
  • the message structure is then packaged in a first HTTP packet.
  • Step 605 The remote socket calls the client component to call the Socket API to send the first HTTP data packet, and the Socket API generates the HTTP data packet as the first IP packet.
  • the Socket API calls the function of the operating system to generate the first HTTP packet as the first IP packet.
  • the first IP packet includes the client IP address and port, as well as the server's IP address and port.
  • Step 606 The operating system invokes the physical network card to send the first IP packet to the NAT gateway through the local area network.
  • Step 607 The NAT gateway modifies the source IP address and port of the first IP packet, and sends the tampered second IP packet.
  • the NAT gateway After receiving the first IP packet sent by the local area network, the NAT gateway modifies the LAN IP address to the public IP address of the NAT gateway, and modifies the port to an idle port on the public network. In this way, the second IP packet has no information in the LAN, and can be completely routed in the public network.
  • Step 608 The remote Socket invokes the server to decapsulate the message structure in the received second IP packet.
  • the remote Socket call server unpacks the second IP packet received on the public network, obtains the message structure encapsulated by the remote Socket calling client component, and unpacks the message structure to obtain the Socket API function that the business client originally wants to call. Name and parameter information.
  • Step 609 the remote Socket calling server calls the local Socket API function to generate a third IP packet, and sends it to the service server.
  • the remote Socket calls the Socket API in the local operating system to generate a third IP packet, and sends the IP packet to the corresponding service server according to the destination IP address and port information in the third IP packet.
  • FIG. 7 is a schematic diagram of a process of a complete remote Socket call provided in Embodiment 4 of the present invention. As shown in FIG. 7, this embodiment includes the following steps:
  • Step 701 When the business client is started, the business client loads and initializes the remote Socket calling business component.
  • Step 702 starting a remote Socket call business component.
  • Step 703 When the remote Socket call service component starts, initiate a connection establishing an HTTP tunnel to the remote Socket call server address of the pre-configured server.
  • Steps 701 to 703 are tunnel establishment processes.
  • Step 704 The business client invokes a remote socket to call the client component method tc.socket (), and establishes a Socket connection inside the remote socket calling server network.
  • Step 705 The remote Socket calling client component encapsulates the function name and parameters of the tc_socket () in a message structure, and transmits the message structure to the remote Socket calling server through an HTTP tunnel.
  • Step 706 The remote Socket calls the server to unlock the message structure in the data packet received on the public network, restores the message structure to a local call, and obtains a return value of the Socket connection.
  • Step 707 The remote Socket calling server encapsulates the result of calling the socket() function in a message structure, and returns the message structure to the remote Socket calling client component through an HTTP tunnel.
  • Step 708 The remote Socket calls the client component to unpack the received message structure, and returns the result returned by the remote socket call server to the service client by using the return value of tc_socket().
  • the business client gets the result of tc_socket(), which is the result of the remote call to socket().
  • Steps 704 to 708 are procedures for establishing a Socket connection.
  • Step 709 The business client invokes a remote Socket call method of the client component tc-GetlPAddress().
  • Step 710 The remote Socket call client component encapsulates the function name and parameters of tc.GetlPAddress() in a message structure, and transmits the message structure to the remote Socket calling server through an HTTP tunnel.
  • Step 711 The remote Socket calls the server to unlock the message structure in the data packet received on the public network, and restores the message structure to a local function GetlPAddressO, and obtains a local idle IP address and port.
  • Step 712 The remote Socket calling server encapsulates the obtained free IP address and port as a return value of the function GetlPAddress() into a message structure, and returns through an HTTP tunnel. Call the client component to the remote socket.
  • Step 713 The remote Socket calls the client component to unpack the received message structure, and returns the result returned by the remote Socket call server to the service client by using the return value of tc_Get IPAddres s ().
  • the business client gets the result of tc_Get IPAddres s (), which is the IP address and port returned by the remote Socket call server.
  • the service client uses the IP address as the source IP address and uses the port as the source port.
  • Step 709 to step 713 are a process of acquiring a source IP address and a port of the service client.
  • Step 714 the business client calls the remote Socket to call the client component function tc_bind ().
  • the source IP address, the source port, the destination IP address, and the destination port are bound to the Socket connection established in step 704 to step 708.
  • Step 715 The remote Socket calling client component encapsulates the function name and parameter of tc_bind () into a message structure, and transmits the message structure to the remote Socket calling server through an HTTP tunnel.
  • Step 716 The remote Socket calls the server to unlock the message structure in the data packet received on the public network, and restores the message structure to a local function bind(), and the source IP address, the source port, and the destination IP address are used.
  • the address and destination port are associated with the Socket identifier.
  • Step 717 The remote Socket calling server encapsulates the return value of the bind O function into a message structure, and returns the client component to the remote socket through the HTTP tunnel.
  • Step 718 The remote Socket calls the client component to unpack the received message structure, and returns the return value of the bind() function to the service client.
  • Steps 714 to 718 are procedures for binding the Socekt connection with the source IP address, source port, destination IP address, and destination port.
  • Step 719 The business client invokes the remote socket to call the tc_send() function in the client component to send network data to the service server.
  • Step 720 The remote Socket call client component encapsulates the tc_send() function into a message structure, and transmits the message structure to the remote Socket calling server through an HTTP tunnel.
  • Step 721 The remote Socket invokes the server to unpack the message structure in the data packet received on the public network, and restores the message structure to a call to a local function send().
  • Step 722 The remote Socket calls the server to send the network data to the service server.
  • Steps 719 to 722 are processes for transmitting network data.
  • step 723 the business client invokes the remote socket to call the tc_select() function in the client component.
  • the tc.selcet() function is used to listen for data on the socket connection.
  • Step 724 The remote Socket call client component encapsulates the tc_select() function into a message structure, and transmits the message structure to the remote Socket calling server through an HTTP tunnel.
  • Step 725 The remote Socket calls the server to unlock the message structure in the data packet received on the public network, and restores the message structure to a call to a local function select ().
  • Step 726 The service server sends a network data packet to the service client.
  • Step 727 The remote Socket calling server detects that a data packet arrives, and calls the recv() function to receive the data packet.
  • Step 728 The remote Socket calling server encapsulates the received data packet into a message structure, and transmits the message structure to the remote Socket calling client component through an HTTP tunnel connection.
  • Step 729 The remote Socket calls the client component to parse the network data packet from the message structure, and finds that the data arrives, and sends a message that the data arrives to the service client.
  • Step 730 The service client knows that a data packet arrives from the return result of the tc_selcet () function, and calls the remote socket to call the tc_recv() function of the client component to receive the data packet.
  • Step 731 The remote Socket calling client component returns the obtained data packet to the service client in the tc_recv () function.
  • Steps 723 to 731 are processes for monitoring and receiving network data packets returned by the service server.
  • FIG. 8 is a schematic diagram of an apparatus for interconnection according to Embodiment 5 of the present invention. As shown in FIG. 8, this embodiment includes the following units:
  • the obtaining unit 801 is configured to obtain information about the first Socket API function invoked by the service client.
  • the business client invokes an interface of the TC Socket API to send network data, and the network data content is included in the first Socket API function.
  • the obtaining unit 801 is configured to obtain first Socket API function information including network data content.
  • the encapsulating unit 802 the information for encapsulating the first Socket API function is a message structure.
  • encapsulation unit 802 encapsulates all information of the first Socket API function to be invoked by the service client into a message structure. This information includes: source IP address, source port, destination IP address, destination port, and the content of the message.
  • the message structure is then packaged in a first HTTP packet
  • the sending unit 803 is configured to send the message structure, so that the remote socket Socekt call server executes the second Socket API function corresponding to the first Socket API function in the message structure.
  • the sending unit 803 specifically packages the message structure in the first HTTP data packet, and calls the Socket API in the operating system to send the first HTTP data packet; the Socket API sends the first HTTP data packet.
  • the operating system calls a physical network card, and sends the first IP packet to a NAT (Network Address Translation) gateway; the NAT gateway modifies a source address and a source port of the first IP packet as The public IP address of the NAT gateway and a new port generate a second IP packet; the second IP packet passes through a public network route and reaches a public network address of the remote Socket calling server.
  • NAT Network Address Translation
  • the remote Socket calling server unpacks the second IP packet received on the public network, obtains the message structure encapsulated by the remote Socket calling client component, and unpacks the message structure to obtain the service client originally wants to invoke.
  • Socket API function name and parameter information The remote Socket call server calls the Socket API in the local operating system to generate a third IP packet, and according to the third The destination IP address and port information in the IP packet sends the IP packet to the corresponding service server.
  • the service server then calls the server through the remote Socket to return the returned result to the remote Socket calling client component through the HTTP tunnel.
  • the sending unit is specifically configured to send the message structure to the remote Socket calling server; the first Socket API function acquired by the acquiring unit may be specifically configured to be used to invoke the server by using the remote Socket.
  • Socket connection Socket API function for network data interaction, the source IP address and source port of the Socket connection are the IP address and port of the local area network where the remote Socket call server is located, and the destination IP address and destination of the Socket connection The port is the IP address and port of the service server in the same local area network as the remote Socket call server.
  • the function for performing network data interaction by using the Socket connection created by the remote Socket call server may be a function for sending network data through the Socket connection, where the first transfer function further includes network data. Specifically, it may also be a function for receiving network data through the Socket connection;
  • the device further includes a return value receiving unit and a return value sending unit; the return value receiving unit is specifically configured to receive the second remote execution of the remote Socket call server
  • the return value sending unit is specifically configured to send the return value received by the return value receiving unit to the service client.
  • the return value receiving unit is specifically configured to receive the execution returned by the remote Socket calling server.
  • the device further includes: an HTTP tunnel establishing unit 804, configured to send the remote Socket The calling server initiates an HTTP tunnel to establish a connection and establishes an HTTP tunnel.
  • HTTP tunnel establishing unit 804 configured to send the remote Socket The calling server initiates an HTTP tunnel to establish a connection and establishes an HTTP tunnel.
  • the remote Socket call client component When the remote Socket call client component starts, it sends an HTTP tunnel to the remote Socket call server to establish a connection and establish an HTTP tunnel.
  • the remote Socket calling client communicates with the remote Socket calling server through the HTTP tunnel.
  • the device further includes: a Socket connection creating unit 805, configured to initiate a Socket connection creation request to the remote Socket calling server, and create a Socket connection.
  • a Socket connection creating unit 805 configured to initiate a Socket connection creation request to the remote Socket calling server, and create a Socket connection.
  • the service client calls the remote socket to call the function tc. socket () of the client component, and establishes a Socket connection on the remote socket calling server.
  • the remote socket calls the server to use the established Socket connection identifier as the socket connection identifier.
  • the return value is returned to the business client.
  • the device further includes: a source address information obtaining unit 806, configured to obtain an idle IP address and a port of the local area network where the remote Socket calls the server, and use the source IP address and the source port as the source IP address and the source port.
  • a source address information obtaining unit 806, configured to obtain an idle IP address and a port of the local area network where the remote Socket calls the server, and use the source IP address and the source port as the source IP address and the source port.
  • the remote socket is called to call the client component function tc-Get lPAddres s () to obtain the free IP address and port in the intranet of the remote socket.
  • the remote Socket calls the server to return the IP address and port to the business client.
  • the service client sends a network packet to the service server, the IP address and port are used as the source IP address and port.
  • the device further includes: an association unit 807, configured to associate the source IP address, the source port, the destination IP address, and the destination port with the Socket connection.
  • an association unit 807 configured to associate the source IP address, the source port, the destination IP address, and the destination port with the Socket connection.
  • FIG. 9 is a schematic diagram of another interconnected device according to Embodiment 6 of the present invention. As shown in FIG. 9, this embodiment includes the following units:
  • the remote Socket connection creation unit 901 is configured to acquire a first creation letter invoked by the service client.
  • the first creation function is a Socket API function for creating a Socket connection;
  • the information encapsulating the first creation function is a first message structure; and the first message structure is sent to the remote Socket call server So that the remote Socket call server executes a second create function corresponding to the first create function in the first message structure to create a Socket connection; and receives the Socket of the Socket connection returned by the remote Socket call server. Connecting an identifier and transmitting to the business client;
  • the remote source address information obtaining unit 902 is configured to acquire a first acquiring function that is invoked by the service client, where the first acquiring function is a socket for obtaining an idle IP address and a port of the local area where the remote Socket calling server is located.
  • An API function; the information encapsulating the first acquisition function is a second message structure; and the second message structure is sent to the remote Socket calling server, so that the remote Socket calling server executes the second message structure a second acquisition function corresponding to the first acquisition function in the body to obtain an idle IP address and a port of the local area network where the remote Socket call server is located; and receiving the remote Socket call server returned by the remote Socket server to locate the local area network of the server
  • the idle IP address and port are sent to the service client; the remote association unit 903 is configured to acquire a first association function invoked by the service client, where the first association function is an associated source IP address and a source port.
  • the destination IP address, the destination port, and the remote Socket connection creation unit a function of the Socket connection identified by the received Socket connection identifier, the source IP address and the source port being the IP address and port obtained by the remote source address information obtaining unit, and the destination IP address and the destination port are
  • the remote Socket calls the IP address and port of the service server in the same local area network;
  • the information encapsulating the first associated function is a third message structure; and the third message structure is sent to the remote Socket calling server So that the remote Socket call server executes a second association function corresponding to the first association function in the third message structure to associate the source IP address, the source port, the destination IP address, the destination port, and the location Socket connection;
  • the data transmission unit 904 is configured to acquire a first transfer function that is invoked by the service client, where the first transfer function is used to perform a Socket connection identified by the Socket connection identifier. a function of the network data interaction; the information encapsulating the first transfer function is a fourth message structure; and the fourth message structure is sent to the remote Socket call server, so that the remote Socket call server executes the And a second transfer function corresponding to the first transfer function in the four message structure to perform network data interaction with the service server through the Socket connection.
  • the first transfer function may be a function for sending network data by using the Socke t connection, and the first transfer function further includes network data;
  • the data transmission unit is specifically configured to be used to invoke the remote Socket Sending, by the server, the fourth message structure, so that the remote Socket call server performs a second transfer function corresponding to the first transfer function in the fourth message structure to connect to the service through the Socket connection
  • the server sends the network data;
  • the first transfer function may further be a function for receiving network data by using the Socket connection;
  • the data transmission unit is specifically configured to send the fourth message structure to the remote Socket call server, to Causing the remote Socket calling server to execute a second transfer function corresponding to the first transfer function in the fourth message structure to receive network data from the service server through the Socket connection, where the data transfer unit further uses Receiving, by the remote Socket calling server, the network data received by the second transfer function and transmitting the network data to the service client.
  • the device further includes: an HTTP tunnel establishing unit 905, configured to establish an HTTP tunnel with the remote Socket calling server, and the device and the remote Socket calling server communicate through the HTTP tunnel, the device
  • the first message structure, the second message structure, the third message structure, and the fourth message structure may be sent by using the HTTP tunnel, where the remote Socket calling server may send the device to the device through the HTTP tunnel Executing the return value of the second creation function (such as the Socket connection identifier of the created Socket connection), the second acquisition function (such as the obtained IP address and port), the second correlation function, and the return value of the second transfer function ( Such as network data received from the service server).
  • An embodiment of the present invention provides an interconnection system, where the system includes the fifth embodiment of the present invention.
  • the interconnection system provided by the embodiment of the present invention establishes an HTTP tunnel and a Socket connection between the remote socket calling client component and the remote socket calling server, and realizes the interconnection of the remote socket calling client component and the remote socket calling server, and Since the remote Socket calling client component is a component on the business client, the remote Socket calling server runs in the business server network, thus realizing the interconnection between the business client and the business server, that is, realizing the business client in the local area network and The service server in the same local area network as the remote Socket calling server is interconnected on the public network.
  • the remote Socket calling client and the remote Socket calling server implement remote Socket calling based on the application layer, without changing the operating system, network characteristics, and without paying attention to the network protocol, achieving a very simple order.
  • the interconnection method, device and system provided by the embodiments of the present invention implement remote Socket calling based on the application layer, do not change the operating system and network characteristics, and do not need to pay attention to the network protocol, thereby saving port resources and reducing the complexity of networking.
  • the present invention can be used as a software SVN (SSL Vi r tua l Pr ivate Network) solution, which can replace the hardware SVN device and realize the single-sheet, which is low in cost.
  • RAM random access memory
  • ROM read only memory
  • electrically programmable ROM electrically erasable programmable ROM
  • registers hard disk, removable disk, CD-ROM, or any other form of storage known in the art. In the medium.

Landscapes

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

Abstract

本发明实施例公开了一种互联方法、装置和***。其中,远程Socket调用客户端组件获取业务客户端调用的第一套接字编程接口Socket API函数的信息;封装所述第一Socket API函数的信息为一个消息结构体;发送所述消息结构体,以使得远程套接字Socekt调用服务器执行所述消息结构体中第一Socket API函数所对应的第二Socket API函数。本发明实施例解决了第一局域网中的业务客户端与第二局域网中的业务服务器在公网上互联的问题。

Description

一种互联方法、 装置和*** 本申请要求于 2011 年 12 月 13 日提交中国专利局、 申请号为 201110415004.2, 发明名称为 "一种互联方法、 装置和***" 的中国专利申请 的优先权, 在先申请文件的内容通过引用结合在本申请中。
技术领域
本发明涉及通信领域, 尤其涉及一种互联方法、 装置和***。
背景技术
将两台机器通过交换机设备连接起来, 实现两台以上机器的相互访问, 即构成了局域网络。 在局域网中, 由于机器数量较少, 因此可以很容易配置 每台机器的 IP地址, 而且很少发生沖突。 在局域网中, 两台机器可以直接根 据 IP地址相互访问。
公网是基于全球或者跨国、 跨省的网络, 在公网中, 运行着大量的机器, 如果每台机器需要占用一个 IP地址, 则会消耗大量的 IP地址资源。
目前通常使用网络地址转换 ( Network Addres s Trans lat ion , NAT )技 术实现在有限的 IP资源情况下支持大量的机器接入公网。
对于收发 IP包的源端机器和目的端机器来说, 其***层次与 TCP/IP协 议之间存在一定的对应关系。 例如: 物理网卡对应处理数据链路层和物理层; 操作***(Operat ion Sys tem)用于处理传输层和网络层; 操作***同时提供 套接字编程接口 (Socket API )给业务客户端开发具体的应用协议; 业务客 户端对应的是应用层协议。
Socket API是操作***提供给应用程序用于开发网络应用的一组函数。 在现有技术下, 通常使用虚拟网卡技术实现一个局域网中的业务客户端 与另一个局域网中的业务服务器在公网上的互联。 虚拟网卡技术在客户机和 服务器的操作***层加载 IP包钩子, 将特定目的地址的 IP包钩取后经隧道 发送。 虚拟网卡技术在操作***和物理网卡之间增加一个虚拟网卡层, 用于 截获操作***下发给网卡的 IP包, 并对特定的 IP包进行转换, 从而实现业 务客户端与业务服务器的互联。
使用虚拟网卡技术可以实现一个局域网中的业务客户端与另一个局域网 中的业务服务器在公网上的互联, 但是该技术存在以下技术缺陷:
1、 虚拟网卡是运行在内核的进程, 软件沖突性比较大, ***的兼容性、 稳定性不佳。
2、 发生故障时, 会导致机器蓝屏等严重问题。
3、 改变了操作***底层逻辑, 容易被杀毒软件识别为病毒。
4、 需要开发多种操作***(Linux、 MAC, iOS等)的虚拟网卡技术。
针对现有技术的缺陷, 本发明提供了一种基于 Socket远程调用的局域网 穿越技术方案, 实现业务客户端远程调用服务器局域网内的 Socket , 与服务 器如同在同一个局域网内通信。
发明内容 本发明实施例提供了一种互联方法、 装置和***, 可以实现一个局域网 中的业务客户端与另一个局域网中的业务服务器在公网上的互联。
一方面, 本发明实施例提供了一种互联方法, 其特征在于, 所述方法包 括:
获取业务客户端调用的第一套接字编程接口 Socket API函数的信息; 封装所述第一 Socket API函数的信息为一个消息结构体;
发送所述消息结构体, 以使得远程套接字 Socekt调用服务器执行所述消 息结构体中第一 Socket API函数所对应的第二 Socket API函数。
另一方面, 本发明实施例提供了一种互联装置, 其特征在于, 所述装置 包括:
获取单元, 用于获取业务客户端调用的第一套接字编程接口 Socket API 函数的信息;
封装单元,用于封装所述第一 Socket API函数的信息为一个消息结构体; 发送单元, 用于发送所述消息结构体, 以使得远程套接字 Socekt调用服 务器执行所述消息结构体中第一 Socket API 函数所对应的第二 Socket API 函数。
再一方面, 本发明实施例提供了一种互联***, 所述***包括上述互联 装置, 远程 Socket调用服务器, 业务客户端, 业务服务器; 所述远程 Socket 调用服务器执行所述互联装置发送的消息结构体中第一 Socket API函数所对 应的第二 Socket API函数, 以使得第一局域网中的拥有所述互联装置的所述 业务客户端与第二局域网中的所述业务服务器在公网上互联, 所述远程 Socket调用服务器在所述第二局域网中, 所述第二局域网在所述公网中。
本发明实施例提供了一种互联方法、 装置和***, 其中, 在远程 Socket 调用客户端组件与远程 Socket调用服务器之间建立 HTTP隧道和 Socket连接, 实现了远程 Socket调用客户端组件与远程 Socket调用 务器的互联, 又由 于远程 Socket调用客户端组件是业务客户端上的一个组件, 远程 Socket调 用服务器运行在业务服务器网络内, 因此便实现了局域网中的业务客户端与 与所述远程 Socket调用服务器在同一局域网内的所述业务服务器的互联。 远 程 Socket调用客户端和远程 Socket调用月良务器基于应用层实现远程 Socket 调用, 不改变操作***, 网络特性, 而且不需要关注网络协议, 实现非常筒 单。
附图说明 为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对实 施例或现有技术描述中所需要使用的附图作筒单地介绍, 显而易见地, 下面 描述中的附图仅仅是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动的前提下, 还可以根据这些附图获得其他的附图。
图 2为虚拟网卡技术下业务客户端与业务服务器互联的实现原理示意图; 图 3为本发明实施例一提供的一种互联的方法流程图;
图 4为本发明实施例远程 Socket技术下主机分层结构和网络分层结构的 对应关系示意图;
图 5为本发明实施例二提供的一种互联的实现原理图;
图 6为本发明实施例三提供的一种互联的方法流程图;
图 Ί 为本发明实施例四提供的一个完整的远程 Socke t 调用的过程示意 图;
图 8为本发明实施例五提供的一种互联的装置示意图;
图 9为本发明实施例六提供的另一种互联的装置示意图。
具体实施方式
如图 1 所示, 虚拟网卡技术是在操作***中实现的, 在操作***和物理网卡 之间增加了一个虚拟网卡。 虚拟网卡用于截获操作***下发给物理网卡的 IP 包, 并对特定的 ip包进行转换。
图 2为虚拟网卡技术下业务客户端与业务服务器互联的实现原理示意图。 如图 1所示:
步骤 1、 业务客户端调用操作***发送一个 RTP (实时传输协议) 包时, 操作***将其打包成 I P包。
操作***将该 IP包发送到物理网卡时, 被虚拟网卡截获。 虚拟网卡构造 一个新的 IP包(在应用层可以是 HTTP包) , 将原来的 IP包信息放在 HTTP 包内。新的 IP包的目的地址为虚拟网卡服务器的公网地址 ( 202. 204. 65. 3 )。
步骤 2、 虚拟网卡调用物理网卡将新的 IP包发送到网络上。
步骤 3、 物理网卡将新的 IP包经局域网路由到 NAT网关上。
步骤 4、 NAT网关爹改新的 IP包的源地址和源端口, 以便接收虚拟网卡 服务器下发的 IP包。
步骤 5、 虚拟网卡服务器收到一个 HTTP包时, 将 HTTP包承载的原始 IP 包提取出来, 并 爹改原始 IP包的源 IP地址和端口, 将其^ ίι爹改为自己内网 地址和端口(1 0. 1 0. 2. 1 1 080) , 然后将该 IP包发送到业务服务器上。 业务服务器返回一个 IP包时, 经过原通道返回。
通过虚拟网卡技术, 使用 NAT网关时, 可以减少业务客户端对 NAT端口 资源的占用量;也可以解决使用 NAT网关实现局域网络与公网互联时, SIP (会 话发起协议)无法正确协商的问题; 还可以解决防火墙背后的业务客户端连 接公网服务器的问题。 但是, 虚拟网卡方式存在以下技术缺陷:
1、 虚拟网卡是运行在内核的进程, 软件沖突性比较大, ***的兼容性、 稳定性不佳。
2、 故障时, 导致机器蓝屏等严重问题。
3、 改变了操作***底层逻辑, 容易被杀毒软件识别为病毒。
4、 需要开发多种操作***(Linux、 MAC, iOS等)的虚拟网卡技术。
针对现有技术的缺陷, 本发明实施例提供了一种互联方法、 装置和***, 其中,在远程 Socket调用客户端组件与远程 Socket调用服务器之间建立 HTTP 隧道和 Socket连接, 实现了远程 Socket调用客户端组件与远程 Socket调用 服务器的互联, 又由于远程 Socket调用客户端组件是业务客户端上的一个组 件, 远程 Socket调用服务器运行在业务服务器所在的局域网内, 因此便实现 了第一局域网中的拥有所述远程 Socket调用服务器的所述业务客户端与第二 局域网中的所述业务服务器在公网上互联, 所述远程 Socket调用服务器在所 述第二局域网中, 所述第二局域网在所述公网中。 远程 Socket调用客户端和 远程 Socket调用服务器基于应用层实现远程 Socket调用, 不改变操作***, 网络特性, 而且不需要关注网络协议, 实现非常筒单。
下面通过附图和实施例, 对本发明的技术方案 #文进一步的详细描述。 图 3为本发明实施例一提供的一种互联的方法流程图。 如图 1所示, 本 实施例包括以下步骤:
步骤 301 , 远程 Socket 调用客户端组件获取业务客户端调用的第一 Socket API函数的信息。
业务客户端调用远程 Socket调用客户端组件中的 Socket API函数。 优选地, 在业务客户端启动时, 业务客户端会初始化远程 Socket调用客 户端组件。 远程 Socket调用客户端组件启动时, 向事先配置的服务器侧的远 程 Socket调用服务器设备地址发起一个 HTTP隧道建立连接, 远程 Socket调 用客户端组件与远程 Socket调用服务器通过该 HTTP隧道进行网络数据的传 输。
优选地, 所述 Socket API 函数可以为创建 Socket连接的函数; 或获取 远程 Socket调用服务器所在局域网的空闲的 IP地址和端口的函数; 或关联 源 IP地址、 源端口、 目的 IP地址、 目的端口与所述 Socket连接的函数, 所 述源 IP地址和所述源端口为所述空闲的 IP地址和端口。
需要说明的是, 所述目的地址和目的端口可以是业务客户端事先配置的 一个 IP地址和端口。
优选地, 所述 Socket API 函数还可以为通过所述 Socket连接进行网络 数据交互的函数; 或用于设置或获取所述 Socket连接的参数的函数; 或关闭 所述 Socket连接的函数。
步骤 302 , 远程 Socket调用客户端组件封装所述第一 Socket API函数的 信息为一个消息结构体。
优选地, 远程 Socket调用客户端组件将应用层调用的 Socket API 函数 信息封装为内部的一个消息结构体。 所述 Socket API函数的所有信息都包含 在该消息结构体中。 这些信息包括: 函数名、 源 IP地址、 源端口、 目的 IP 地址、 目的端口、 消息的内容。
优选地, 在远程 Socket调用客户端组件和远程 Socket调用服务器之间 定义了一套数据结构体, 将 Socket API的函数名、 函数参数封装在这些结构 体中, 用于传输业务客户端调用 Socket API的函数信息。 所述数据结构体的 结构如下:
Channel ID Length Type Data
2字节 11位 5位 最大 2048字节 其中, Channel lD与 Socket连接对应, 描述远程 Socket调用客户端与远 程 Socket调用服务器之间的 Socket连接的标识符。 Channel ID最大支持 65536 个 Socket连接, 与端口数相当。 Channe l lD长度为 2字节。 在业务客户端与 业务服务器通过 Socket连接进行网络数据交互时, 由于 Socket 连接标识符 与源 IP地址、 源端口、 目的 IP地址、 目的端口已经关联在一起, 因此携带 Channel ID即相当于携带了源 IP地址、 源端口、 目的 IP地址、 目的端口。
需要说明的是, 进行网络数据交互的 Socket API 函数可以为: send O 函数、 sendto O函数、 recv ()函数、 recvf rom ()函数、 sel ect ()函数。
Length表示 Socket API函数封装数据的长度, 最大可以描述 2048个字 节。 Length长度为 11位。
Type表示函数的名称的枚举值。 Type长度为 5位。 Type可以指示 32种 操作, 目前可以使用到 18种, 如下所示:
en画 Type
SOCKET=0,
BIND=1,
LISTEN=2,
ACCEPT=3,
CO謹 CT=4,
CL0SE=5,
SHUTD0WN=6,
RECV=7,
RECVF廳 =8,
SEND=9,
SENDTO=10,
TCPSEND=11 , SETS0CK0PT=12,
GETS0CK0PT=13,
GETS0CKNAME=14,
GETPEERNAME=15,
GETH0STBYNAME=16
I0CTL=17,
GETIPANDP0RT=18
Data表示函数封装的数据的内容。 Data长度最大为 2048字节。
例如: 业务客户端调用远程 Socket调用客户端组件中的 tc_ send ()函数 时, 远程 Socket调用客户端组件将该函数封装为一个如下的消息结构体:
Figure imgf000009_0001
其中, 11012为 Socket连接的标识符; 3为 Data部分的长度, 即为 "AAA" 的长度; 9为 send ()函数的枚举值; AAA为 send ()函数发送的消息内容。
步骤 303 , 远程 Socket调用客户端组件发送所述消息结构体, 以使得远 程套接字 Socket调用服务器执行所述消息结构体中第一 Socket API 函数所 对应的第二 Socket API函数。
需要说明的是, 第一 Socket API函数是业务客户端的函数, 第二 Socket API函数是业务服务器中的与业务客户端的第一 Socket API函数对应的函数。 第一 Socket API函数和第二 Socket API函数所实现的功能相同, 参数相同。
优选地,远程 Socket调用客户端组件将所述消息结构体打包在第一 HTTP 数据包中, 调用操作***中的 Socket API发送所述第一 HTTP数据包; 所述 Socket API将所述第一 HTTP数据包生成为第一 IP包; 所述操作***调用物 理网卡, 将所述第一 IP包发送到 NAT (网络地址转换) 网关; 所述 NAT网关 修改所述第一 IP包的源地址和源端口为 NAT网关的公网 IP地址和一个新的 端口, 生成第二 IP包; 所述第二 IP包经过公网路由, 到达远程 Socket调用 服务器的公网地址。
优选地, 远程 Socket调用服务器解开公网上收到的第二 IP包, 再解开 远程 Socket客户端组件封装的消息结构体, 得到业务客户端原本希望调用的 Socket API函数信息。
远程 Socket调用服务器调用业务客户端希望调用的 Socket API 函数, 再调用本地的操作***, 生成第三 IP包, 将所述第三 IP包发送到业务服务 器。 业务服务器将返回值通过远程 Socket调用服务器返回给业务客户端。 远 程 Socket 调用服务器将要返回的内容封装在一个消息结构体中, 通过 HTTP 隧道返回给业务客户端。
优选地, 本发明实施例在业务客户端和操作***之间增加了一个 TC-Socket API 层, 用于封装 Socket API。 业务客户端主机分层结构和网络 分层结构的对应关系示意图如图 4所示:
业务客户端和 TC_Socket API层对应的是应用层协议;
操作***用于处理传输层和网络层,操作***同时提供 Socket API接口, 用于给业务客户端开发具体的应用协议;
物理网卡对应处理数据链路层和物理层。 优选地, 步骤 301 中的第一 Socket API 函数具体为: 用于创建 Socket 连接的 Socket API 函数; 或用于获取所述远程 Socket调用月良务器所在局域 网的空闲的 IP地址和端口的 Socket API函数; 或用于关联源 IP地址、 源端 口、 目的 IP地址、 目的端口与所述远程 Socket调用月良务器创建的 Socket连 接的 Socket API函数, 所述源 IP地址和所述源端口为所述远程 Socket调用 月良务器所在局域网的空闲的 IP地址和端口, 所述目的 IP地址和所述目的端 口为与所述远程 Socket调用服务器在同一局域网内的业务服务器的 IP地址 和端口; 或用于通过所述远程 Socket调用 良务器创建的 Socket连接进行网 络数据交互的函数,所述 Socket连接的源 IP地址和源端口为所述远程 Socket 调用 良务器所在局域网的 IP地址和端口, 所述 Socket连接的目的 IP地址和 目的端口为与所述远程 Socket调用服务器在同一局域网内的业务服务器的 IP 地址和端口。
所述方法还包括, 接收所述远程 Socket调用服务器返回的执行所述第二 Socket API函数的返回值并发送给所述业务客户端。 当所述第一 Socket API 函数具体为用于创建 Socket连接的 Socket API 函数时, 所述返回值包括所 述远程 Socket调用服务器执行所述第一 Socket API函数所对应的第二 Socket API函数所创建的所述 Socket连接的 Socket连接标识符;当所述第一 Socket API函数具体为用于获取所述远程 Socket调用服务器所在局域网的空闲的 IP 地址和端口的 Socket API 函数时, 所述返回值包括所述远程 Socket调用服 务器执行所述第一 Socket API 函数对应的第二 Socket API 函数所获取的所 述远程 Socket调用月良务器所在局域网的空闲的 IP地址和端口; 当所述第一 Socket API函数具体为用于通过所述 Socket连接接收网络数据的函数时, 所 述返回值包括所述远程 Socket调用服务器执行所述第一 Socket API 函数对 应的第二 Socket API函数从所述业务服务器接收的网络数据。
下面提供一种示例实施方式: 远程 Socket调用客户端获取业务客户端调用的第一创建函数, 所述第一 创建函数为用于创建 Socket连接的 Socket API 函数; 封装所述第一创建函 数的信息为第一消息结构体; 向所述远程 Socket调用服务器发送所述第一消 息结构体, 以使得所述远程 Socket调用服务器执行所述第一消息结构体中的 第一创建函数所对应的第二创建函数以创建 Socket 连接; 接收所述远程 Socket调用服务器返回的所述 Socket连接的 Socket连接标识符并发送给所 述业务客户端; 所述第一消息结构体可以包括 Channel ID和 Type字段, 所述 Channel ID 字段记录的可以是所述远程 Socket调用客户端生成的一个标识符; 所述 Type 字段记录的可以是所述第一创建函数的名称的枚举值, 如, 如果在枚举类型 定义中为第一创建函数定义了枚举项 "SOCKET=0,,,则此处 Type记录的是 0, 当然, 也可以直接记录所述第一创建函数的名称。
所述远程 Socket调用服务器在执行所述第二创建函数创建 Socket连接 后, 向所述远程 Socket调用客户端返回所述 Socket连接的 Socket连接标识 符 ( Socket ID ), 还可以记录所述 Channel ID和所述 Socket ID的关联关系。 所述远程 Socket调用客户端接收所述 Socket ID后将所述 Socket ID返回给 所述业务客户端。 优选地, 所述远程 Socket 调用客户端还可以记录所述 Channel ID和所述 Socket I D的关联关系。 所述远程 Socket调用客户端获取所述业务客户端调用的第一获取函数, 所述第一获取函数为用于获取所述远程 Socket调用服务器所在局域网的空闲 的 IP地址和端口的 Socket API 函数; 封装所述第一获取函数的信息为第二 消息结构体; 向所述远程 Socket调用服务器发送所述第二消息结构体, 以使 得所述远程 Socket调用服务器执行所述第二消息结构体中的第一获取函数所 对应的第二获取函数以获取所述远程 Socket调用服务器所在局域网的空闲的 IP地址和端口; 接收所述远程 Socket调用 务器返回的所述远程 Socket调 用服务器所在局域网的空闲的 IP地址和端口并发送给所述业务客户端; 所述第二消息结构体可以包括 Channel ID和 Type字段, 所述 Channel ID 字段记录的可以是所述第一消息结构体中的 Channel ID, 或者为空。 Type记 录的可以是所述第一获取函数的名称的枚举值, 如, 如果在枚举类型定义中 为第一获取函数定义了枚举项 "GETIPANDP0RT=18,,, 则此处 Type记录的 是 18, 当然, 也可以直接记录所述第一获取函数的名称。
所述远程 Socket调用客户端获取所述业务客户端调用的第一关联函数, 所述第一关联函数为关联源 IP地址、 源端口、 目的 IP地址、 目的端口与所 述 Socket连接标识符所标识的 Socket连接的函数, 所述源 IP地址、 源端口 为所述返回的 IP 地址和端口, 所述目的 IP 地址、 目的端口为与所述远程 Socket调用服务器在同一局域网内的业务服务器的 IP地址和端口;封装所述 第一关联函数的信息为第三消息结构体; 向所述远程 Socket调用服务器发送 所述第三消息结构体, 以使得所述远程 Socket调用服务器执行所述第三消息 结构体中的第一关联函数所对应的第二关联函数以关联所述源 IP地址、 源端 口、 目的 IP地址、 目的端口与所述 Socket连接; 所述第一关联函数包括所述 Socket ID , 所述第三消息结构体可以包括 Channel ID, Type字段和 Data字段, 其中, 所述 Channel ID字段记录的可以 是所述第一消息结构体中的 Channel ID,也可以是从所述第一关联函数中读取 的所述 Socket ID, 如果记录的是 Channel ID, 所述远程 Socket调用客户端利 用记录的所述 Channel ID和所述 Socket ID的关联关系获取所述第一关联函数 中的 Socket ID所关联的 Channel ID;所述 Type字段记录的是所述第一关联函 数的名称的枚举值, 如, 如果在枚举类型定义中为第一关联函数定义了枚举 项 "BIND=1" , 则此处 Type记录的是 1 , 当然, 也可以直接记录所述第一关 联函数的名称; 可以在所述 Data字段中包括所述源 IP地址、 源端口、 目的 IP地址、 目的端口。
如果所述 Channel ID记录的是所述第一消息结构体中的 Channel ID, 则 所述远程 Socket调用月良务器可以利用记录的所述 Channel ID和所述 Socket ID的关联关系获取所述消息结构体中的 Channel ID所关联的 Socket ID, 并 执行所述第二关联函数以关联所述源 IP地址、 源端口、 目的 IP地址、 目的 端口与所述 Socket ID所标识的 Socket连接。 所述远程 Socket调用客户端获取所述业务客户端调用的第一传输函数, 所述第一传输函数为用于通过所述 Socket连接标识符所标识的 Socket连接 进行网络数据交互的函数; 封装所述第一传输函数的信息为第四消息结构体; 向所述远程 Socket 调用服务器发送所述第四消息结构体, 以使得所述远程 Socke t调用服务器执行所述第四消息结构体中的第一传输函数所对应的第二 传输函数以通过所述 Socket连接与所述业务服务器进行网络数据交互。
所述第一传输函数包括所述 Socket ID, 所述第四消息结构体可以包括 Channel ID和 Type字段, 所述 Channel ID字段记录的可以是所述第一消息 结构体中的 Channel ID, 也可以是从所述第一传输函数中读取的所述 Socket ID, 如果记录的是 Channel ID, 所述远程 Socket调用客户端利用记录的所述 Channel ID和所述 Socket ID的关联关系获取所述第一传输函数中的 Socket ID所关联的 Channel ID; 所述 Type字段记录的是所述第一传输函数的名称 的枚举值, 如, 如果所述第一传输函数为 send函数, 且在枚举类型定义中为 send函数定义了枚举项 "SEND=9,,, 则此处 Type记录的是 9 , 当然, 也可以 直接记录所述第一传输函数的名称。
具体地, 所述第一传输函数可以为用于通过所述 Socke t连接发送网络数 据的函数, 所述第一传输函数还包括网络数据, 相应地, 所述封装的第四消 息结构体也包括所述网络数据。 所述远程 Socke t 调用客户端向所述远程 Socket调用服务器发送所述第四消息结构体,以使得所述远程 Socket调用服 务器执行所述第四消息结构体中的第一传输函数所对应的第二传输函数以通 过所述 Socket连接向所述业务服务器发送所述网络数据。 所述第四消息结构 体还可以包括 Da ta字段, 可以在所述 Da ta字段携带所述传输数据。
具体地, 所述第一传输函数还可以为用于通过所述 Socket连接接收网络 数据的函数; 所述远程 Socke t调用客户端向所述远程 Socke t调用服务器发 送所述第四消息结构体, 以使得所述远程 Socket调用服务器执行所述第四消 息结构体中的第一传输函数所对应的第二传输函数以通过所述 Socket连接从 所述业务服务器接收网络数据, 接收所述远程 Socket调用服务器执行所述第
端。 优选地, 在执行上述步骤之前, 所述远程 Socket调用客户端向所述远程 Socket 调用服务器发起一个超文本传输协议 HTTP 隧道建立连接, 建立一个 HTTP隧道; 则在执行上述步骤时, 通过所述 HTTP隧道发送所述第一消息结构 体、 第二消息结构体、 第三消息结构体和第四消息结构体。 所述远程 Socket 调用客户端还可以通过所述 HTTP隧道接收所述远程 Socket调用服务器返回 的数据, 如所述 Socket连接标识符、 所述远程 Socket调用服务器所在局域 网的空闲的 IP地址和端口、 以及所述远程 Socke t调用月良务器执行所述第二 传输函数所接收的所述网络数据。
需要说明的是, 上述步骤可以采用其他顺序或者同时进行, 如, 所述远 程 Socket调用客户端也可以先获取所述第一获取函数、 封装所述第一获取函 数为所述第二消息结构体并发送所述第二消息结构体, 然后获取所述第一创 建函数、 封装所述第一创建函数为所述第一消息结构体并发送所述第一消息 结构体。 图 5为本发明实施例二提供的一种互联的实现原理图。 如图 5所示, 本 发明实施例包括以下步骤:
步骤 501 ,业务客户端发送一个 UDP包,该 UDP包的源地址是 10. 10. 2. 2 , 源端口是 5060; 目的地址是 10. 10. 2. 1 , 目的端口是 5060, 数据是 "AAA" 。
需要说明的是, 所述目的地址和目的端口可以是业务客户端事先配置的 一个 IP地址和端口。
优选地, 所述 UDP包的源地址不是业务客户端的本机 IP地址, 而是服务 器侧的 IP地址, 即为远程 Socket调用月良务器的内网 IP地址。
优选地, 在业务客户端启动时, 业务客户端会初始化远程 Socket调用客 户端组件。 远程 Socket调用客户端组件启动时, 向事先配置的服务器侧的远 程 Socket调用服务器设备地址发起一个 HTTP隧道建立连接, 远程 Socket调 用客户端组件与远程 Socket调用服务器通过该 HTTP隧道进行网络数据的传 输。
优选地, 业务客户端可以调用创建 Socket 连接的函数创建一个 Socket 连接; 调用获取远程 Socket调用服务器所在局域网的空闲的 IP地址和端口; 将所述空闲的 IP地址和端口作为源地址和源端口; 并调用关联所述源地址、 所述源端口、 目的地址、 目的端口与所述 Socket连接的函数。
步骤 502 , 远程 Socket调用客户端组件将应用层调用的 Socket API函数 进行封装, 封装为一个内部的消息结构体, 将函数的所有信息包含在该结构 体中。 这些信息包括源地址 10. 10. 2. 2、 源端口 5060、 目的地址 10. 10. 2. 1、 目的端口 5060、 消息的内容 "AAA" 。 然后远程 Socket调用客户端组件将消 息结构体打包在第一 HTTP数据包内。 步骤 503 , 远程 Socket调用客户端组件调用操作***中的 Socket API , 将打包后的第一 HTTP数据包生成第一 IP包。
Socket API调用操作***的功能, 将第一 HTTP数据包生成为第一 IP包。 第一 IP包中包括客户端 IP地址和端口, 以及服务器端的 IP地址和端口。 图 5中, 客户端源地址为 192. 168. 2. 1 , 源端口为 1080; 服务器端的公网地址为 202. 204. 65. 3 , 目的端口为 80。
步骤 504 , 操作***调用物理网卡, 将第一 IP包通过局域网发送到 NAT 网关。
步骤 505 , NAT网关修改第一 IP包的源地址和端口, 并将修改后的第二 IP包公网路由到远程 Socket调用服务器的公网地址上。
NAT网关有两个网络 IP地址, 一个是外网 IP地址, 即公网 IP地址; 另 一个是内部 IP地址, 即局域网 IP地址。
NAT网关在接收到上述局域网发送过来的第一 IP包后,将局域网 IP地址 192. 168. 2. 1 爹改为 NAT网关的公网 IP地址 202. 204. 65. 1 , 将端口 1080 i 改为一个新的端口 11111。
修改后的第二 IP包已经完全没有局域网络的信息, 可以完全在公网上路 由了。 NAT网关将第二 IP包经公网路由到目的主机。 NAT网关在发送第二 IP 包时, 同时在内部记录一条信息, 记录 202. 204. 65. 1 11111与 192. 168. 2. 1 1080的对应关系。
步骤 506 , 远程 Socket调用服务器将公网上收到的第二 IP包解开, 得到 远程 Socket调用客户端组件封装的消息结构体, 并将该消息结构体解开, 得 到业务客户端原本希望调用的 Socket API函数名 (Send ) 以及参数信息(源 地址 10. 10. 2. 2 , 源端口 5060, 目的地址 10. 10. 2. 1 , 目的端口 5060, 以及 消息的内容 "AAA" ) 。
步骤 507 , 远程 Socket调用服务器调用本地操作***中的 Socket API , 生成第三 IP包, 第三 IP包括源 IP地址 10. 10. 2. 2、 源端口 5060、 目的 IP 地址 10. 10. 2. 1、 目的端口 5060、 消息内容 "AAA" 。 将第三 IP包发送到目 的 IP地址 10. 10. 2. 1对应的业务服务器。
图 6为本发明实施例三提供的一种互联的方法流程图。 如图 6所示, 本 实施例包括以下步骤:
步骤 601 , 远程 Socket调用客户端组件发起 HTTP隧道建立连接, 建立 HTTP隧道。
业务客户端启动时, 首先初始化远程 Socket 调用客户端组件, 在远程 Socket调用客户端组件启动时,向事先配置的服务器的远程 Socket调用服务 器地址发起一个建立 HTTP隧道的连接, 双方之间建立一个 HTTP隧道。
步骤 602 , 业务客户端调用远程 Socket调用客户端组件的 tc_ socket () 方法, 在远程 Socket调用月良务器网络中创建一个 Socket连接。
业务客户端调用远程 Socket调用客户端组件的方法 tc_ socket () , 建立 一个 Socket连接, 所述 Socket连接的标识符号关联了源 IP地址、 源端口、 目的 IP地址、 目的端口等信息。
步骤 603 , 远程 Socket 调用客户端组件获取业务客户端调用的第一 Socket API函数的信息。
业务客户端通过调用远程 Socket调用客户端组件的 TC_Socket API接口 发送数据, 要发送的数据内容包含在第一 Socket API函数内。
步骤 604 , 远程 Socket调用客户端组件封装第一 Socket API的函数信息 为消息结构体。
远程 Socket 调用客户端组件将业务客户端要调用的第一 Socket API函 数的所有信息封装成一个消息结构体中。这些信息包括: 源 IP地址、 源端口、 目的 IP地址、目的端口、消息的内容。然后将所述消息结构体打包在第一 HTTP 数据包中。
步骤 605 , 远程 Socket调用客户端组件调用 Socket API发送第一 HTTP 数据包, Socket API将 HTTP数据包生成为第一 IP包。 Socket API调用操作***的功能, 将第一 HTTP数据包生成为第一 IP包。 第一 IP包中包括客户端 IP地址和端口, 以及服务器端的 IP地址和端口。
步骤 606 , 操作***调用物理网卡将第一 IP包通过局域网发送到 NAT网 关。
步骤 607 , NAT网关^ ίι爹改第一 IP包的源 IP地址和端口, 并发送爹改后的 第二 IP包。
NAT网关在接收到上述局域网发送过来的第一 IP包后,将局域网 IP地址 修改为 NAT网关的公网 IP地址, 将端口修改为公网上的一个空闲端口。 这样 第二 IP包中便没有局域网中的信息了, 可以完全在公网中路由。
步骤 608 ,远程 Socke t调用服务器解封收到的第二 IP包中的消息结构体。 远程 Socket调用服务器将公网上收到的第二 IP包解开,得到远程 Socket 调用客户端组件封装的消息结构体, 并将该消息结构体解开, 得到业务客户 端原本希望调用的 Socket API函数名及参数信息。
步骤 609,远程 Socket调用服务器调用本地的 Socket API函数生成第三 IP包, 并将其发送到业务服务器。
远程 Socket 调用月良务器调用本地操作***中的 Socket API , 生成第三 IP包, 并根据第三 IP 包中的目的 IP地址和端口信息将 IP包发送到对应的 业务服务器。
图 Ί 为本发明实施例四提供的一个完整的远程 Socket 调用的过程示意 图。 如图 7所示, 本实施例包括以下步骤:
步骤 701 , 启动业务客户端时, 业务客户端加载并且初始化远程 Socket 调用业务端组件。
步骤 702 , 启动远程 Socket调用业务端组件。
步骤 703 , 远程 Socket调用业务端组件启动时, 向事先配置的服务器的 远程 Socket调用服务器地址发起一个建立 HTTP隧道的连接。
步骤 701至步骤 703为隧道建立过程。 步骤 704 , 业务客户端调用远程 Socket 调用客户端组件的方法 tc.socket () , 在远程 Socket调用服务器网络内侧建立一个 Socket连接。
步骤 705, 远程 Socket调用客户端组件将 tc_socket ()的函数名和参数 封装在一个消息结构体中, 并将该消息结构体通过 HTTP 隧道传输到远程 Socket调用服务器。
步骤 706, 远程 Socket调用服务器解开公网上收到的数据包中的消息结 构体, 将该消息结构体还原为对本地的一个调用, 并且获取到一个 Socket连 接的返回值。
步骤 707, 远程 Socket调用服务器将调用 socket ()函数的结果封装在一 个消息结构体中, 并将该消息结构体通过 HTTP隧道返回给远程 Socket调用 客户端组件。
步骤 708, 远程 Socket调用客户端组件解开接收到的消息结构体, 通过 tc_socket()的返回值将远程 Socket调用服务器返回的结果返回给业务客户 端。 业务客户端得到 tc_socket()的返回结果, 即得到远程调用 socket ()的 返回结果。
步骤 704至步骤 708为 Socket连接建立过程。
步骤 709 , 业务客户端调用远程 Socket 调用客户端组件的方法 tc-GetlPAddress ()。
步骤 710, 远程 Socket调用客户端组件将 tc.GetlPAddress ()的函数名 和参数封装在一个消息结构体中, 并将该消息结构体通过 HTTP隧道传输到远 程 Socket调用服务器。
步骤 711, 远程 Socket调用服务器解开公网上收到的数据包中的消息结 构体, 将该消息结构体还原为对本地的一个函数 GetlPAddressO的调用, 获 得本地空闲的 IP地址和端口。
步骤 712,远程 Socket调用服务器将获取到的空闲的 IP地址和端口作为 函数 GetlPAddress ()的返回值封装成一个消息结构体,并通过 HTTP隧道返回 给远程 Socket调用客户端组件。
步骤 713 , 远程 Socket调用客户端组件解开接收到的消息结构体, 通过 tc_Get IPAddres s ()的返回值将远程 Socket调用服务器返回的结果返回给业 务客户端。 业务客户端得到 tc_Get IPAddres s ()的返回结果, 即得到远程 Socket调用 良务器返回的 IP地址和端口。 业务客户端将该 IP地址作为源 IP 地址, 将该端口作为源端口。
步骤 709至步骤 713为业务客户端的源 IP地址和端口的获取过程。
步骤 714 , 业务客户端调用远程 Socket 调用客户端组件的函数 tc_bind ()。 将源 IP地址、 源端口、 目的 IP地址、 目的端口与步骤 704至步 骤 708建立的 Socket连接进行绑定。
步骤 715 , 远程 Socket调用客户端组件将 tc_bind ()的函数名和参数封 装成一个消息结构体, 并将该消息结构体通过 HTTP 隧道传输到远程 Socket 调用服务器。
步骤 716 , 远程 Socket调用服务器解开公网上收到的数据包中的消息结 构体,将该消息结构体还原为对本地的一个函数 bind ()的调用,将源 IP地址、 源端口、 目的 IP地址、 目的端口与 Socket标识符进行关联。
步骤 717 , 远程 Socket调用服务器将 bind O函数的返回值封装成一个消 息结构体, 并通过 HTTP隧道返回给远程 Socket调用客户端组件。
步骤 718 , 远程 Socket 调用客户端组件解开接收到的消息结构体, 将 bind ()函数的返回值返回给业务客户端。
步骤 714至步骤 718为绑定 Socekt连接和源 IP地址、 源端口、 目的 IP 地址和目的端口的过程。
步骤 719 , 业务客户端调用远程 Socket调用客户端组件中的 tc_ send () 函数, 发送网络数据到业务服务器。
步骤 720, 远程 Socket调用客户端组件将 tc_ send ()函数封装成消息结 构体, 并将该消息结构体通过 HTTP隧道传输给远程 Socket调用服务器。 步骤 721, 远程 Socket调用服务器解开公网上收到的数据包中的消息结 构体, 将该消息结构体还原为对本地的一个函数 send ()的调用。
步骤 722, 远程 Socket调用服务器将网络数据发送到业务服务器。
业务服务器收到数据后, 会向业务客户端返回一个数据发送成功的结果。 步骤 719至步骤 722为发送网络数据的过程。
步骤 723,业务客户端调用远程 Socket调用客户端组件 中的 tc_select() 函数。
tc.selcet ()函数用来监听 socket连接上是否有数据到达。
步骤 724, 远程 Socket调用客户端组件将 tc_select ()函数封装成消息 结构体, 并将该消息结构体通过 HTTP隧道传输给远程 Socket调用服务器。
步骤 725, 远程 Socket调用服务器解开公网上收到的数据包中的消息结 构体, 将该消息结构体还原为对本地的一个函数 select ()的调用。
步骤 726, 业务服务器向业务客户端下发一个网络数据包。
步骤 727, 远程 Socket调用服务器检测到有数据包到达, 调用 recv()函 数接收该数据包。
步骤 728, 远程 Socket调用服务器将接收到的数据包封装成一个消息结 构体, 并通过 HTTP隧道连接将该消息结构体传给远程 Socket调用客户端组 件。
步骤 729, 远程 Socket调用客户端组件从消息结构体中解析出网络数据 包, 发现有数据到达, 给业务客户端发送数据到达的消息。
步骤 730,业务客户端从 tc_selcet ()函数的返回结果知道有数据包到达, 调用远程 Socket调用客户端组件的 tc_recv()函数, 接收该数据包。
步骤 731, 远程 Socket调用客户端组件在 tc_recv ()函数中将获取到的 数据包返回给业务客户端。
步骤 723 至步骤 731 为监听并接收业务服务器返回的网络数据包的过 程。 图 8为本发明实施例五提供的一种互联的装置示意图。 如图 8所示, 本 实施例包括以下单元:
获取单元 801 , 用于获取业务客户端调用的第一 Socket API函数信息。 优选地, 业务客户端调用 TC Socket API 的接口来发送网络数据, 网络 数据内容包含在第一 Socket API函数内。 获取单元 801用于获取包含网络数 据内容的第一 Socket API函数信息。
封装单元 802 , 用于封装所述第一 Socket API函数的信息为一个消息结 构体。
优选地, 封装单元 802将业务客户端要调用的第一 Socket API函数的所 有信息封装成一个消息结构体中。 这些信息包括: 源 IP地址、 源端口、 目的 IP地址、 目的端口、 消息的内容。 然后将所述消息结构体打包在第一 HTTP数 据包中
发送单元 803 , 用于发送所述消息结构体, 以使得远程套接字 Socekt调 用服务器执行所述消息结构体中第一 Socket API 函数所对应的第二 Socket API函数。
优选地,发送单元 803具体将所述消息结构体打包在第一 HTTP数据包中, 调用操作***中的 Socket API发送所述第一 HTTP数据包; 所述 Socket API 将所述第一 HTTP数据包生成为第一 IP包; 所述操作***调用物理网卡, 将 所述第一 IP包发送到 NAT (网络地址转换) 网关; 所述 NAT网关修改所述第 一 IP包的源地址和源端口为所述 NAT网关的公网 IP地址和一个新端口, 生 成第二 IP包; 所述第二 IP包经过公网路由, 到达远程 Socket调用服务器的 公网地址。
优选地, 远程 Socket调用服务器将公网上收到的第二 IP包解开, 得到 远程 Socket调用客户端组件封装的消息结构体, 并将该消息结构体解开, 得 到业务客户端原本希望调用的 Socket API 函数名及参数信息。 远程 Socket 调用服务器调用本地操作***中的 Socket API , 生成第三 IP包, 并根据第三 IP 包中的目的 IP地址和端口信息将 IP包发送到对应的业务服务器。 业务服 务器再通过远程 Socket调用服务器将返回的结果通过 HTTP隧道返回给远程 Socket调用客户端组件。
可选地, 所述发送单元, 具体用于向远程 Socket调用服务器发送所述消 息结构体; 所述获取单元获取的所述第一 Socket API函数具体可以为用于通 过所述远程 Socket 调用服务器创建的 Socket 连接进行网络数据交互的 Socket API函数, 所述 Socket连接的源 IP地址和源端口为所述远程 Socket 调用 良务器所在局域网的 IP地址和端口, 所述 Socket连接的目的 IP地址和 目的端口为与所述远程 Socket调用服务器在同一局域网内的业务服务器的 IP 地址和端口。 所述用于通过所述远程 Socket调用 良务器创建的 Socket连接进行网络 数据交互的函数,具体可以为用于通过所述 Socket连接发送网络数据的函数, 所述第一传输函数还包括网络数据; 具体还可以为用于通过所述 Socket连接 接收网络数据的函数;
进一步地, 所述装置还包括返回值接收单元和返回值发送单元; 所述返 回值接收单元具体用于接收所述远程 Socket调用服务器返回的执行所述第二
Socket API函数的返回值, 所述返回值发送单元具体用于向所述业务客户端 发送所述返回值接收单元接收的所述返回值。 当所述获取单元获取的所述第 一 Socket API函数具体为用于通过所述 Socket连接接收网络数据的函数时, 所述返回值接收单元, 具体用于接收所述远程 Socket调用服务器返回的执行 所述第一 Socket API 函数对应的第二 Socket API 函数从所述业务服务器接 收的网络数据; 所述返回值发送单元具体用于将所述返回值接收单元接收的 所述网络数据发送给所述业务客户端。
优选地,所述装置还包括: HTTP隧道建立单元 804 ,用于向所述远程 Socket 调用服务器发起一个 HTTP隧道建立连接, 建立一个 HTTP隧道。
远程 Socket调用客户端组件启动时, 会向远程 Socket调用服务器发送 一个 HTTP隧道建立连接, 建立一个 HTTP隧道。 远程 Socket调用客户端和远 程 Socket调用服务器之间通过该 HTTP隧道进行通信。
优选地, 所述装置还包括: Socket 连接创建单元 805 , 用于向所述远程 Socket调用服务器发起 Socket连接创建请求, 创建一个 Socket连接。
建立 HTTP隧道后, 业务客户端调用远程 Socket调用客户端组件的函数 tc. socket () ,在远程 Socket调用月良务器上建立一个 Socket连接,远程 Socket 调用服务器将所建立的 Socket连接标识符作为返回值返回给业务客户端。
优选地,所述装置还包括:源地址信息获取单元 806 ,用于获取远程 Socket 调用服务器所在局域网的空闲的 IP地址和端口, 将其作为源 IP地址和源端 口。
业务客户端获取 Socket连接的标识符后, 调用远程 Socket调用客户端 组件的函数 tc-Get lPAddres s () , 获取远程 Socket调用服务器内网中的空闲 IP地址和端口。 远程 Socket调用月良务器将所述 IP地址和端口返回给业务客 户端。 业务客户端向业务服务器发送网络数据包时, 将所述 IP地址和端口作 为源 IP地址和端口。
优选地, 所述装置还包括: 关联单元 807 , 用于关联所述源 IP地址、 所 述源端口、 目的 IP地址、 目的端口与所述 Socket连接。
业务客户端调用远程 Socket调用客户端组件的函数 tc.bind () , 绑定源 IP地址、 源端口、 目的 IP地址、 目的端口与所建立的 Socket连接, 即与所 建立的 Socket连接的标识符进行关联。 图 9为本发明实施例六提供的另一种互联的装置示意图。 如图 9所示, 本实施例包括以下单元:
远程 Socket连接创建单元 901 , 用于获取业务客户端调用的第一创建函 数, 所述第一创建函数为用于创建 Socket连接的 Socket API 函数; 封装所 述第一创建函数的信息为第一消息结构体; 向所述远程 Socket调用服务器发 送所述第一消息结构体, 以使得所述远程 Socket调用服务器执行所述第一消 息结构体中的第一创建函数所对应的第二创建函数以创建 Socket连接; 接收 所述远程 Socket调用服务器返回的所述 Socket连接的 Socket连接标识符并 发送给所述业务客户端;
远程源地址信息获取单元 902 ,用于获取所述业务客户端调用的第一获取 函数, 所述第一获取函数为用于获取所述远程 Socket调用服务器所在局域网 的空闲的 IP地址和端口的 Socket API 函数; 封装所述第一获取函数的信息 为第二消息结构体;向所述远程 Socket调用服务器发送所述第二消息结构体, 以使得所述远程 Socket调用服务器执行所述第二消息结构体中的第一获取函 数所对应的第二获取函数以获取所述远程 Socket调用服务器所在局域网的空 闲的 IP地址和端口;接收所述远程 Socket调用 务器返回的所述远程 Socket 调用服务器所在局域网的空闲的 IP地址和端口并发送给所述业务客户端; 远程关联单元 903 , 用于获取所述业务客户端调用的第一关联函数, 所述 第一关联函数为关联源 IP地址、 源端口、 目的 IP地址、 目的端口与所述远 程 Socket连接创建单元所接收的 Socket连接标识符所标识的 Socket连接的 函数, 所述源 IP地址、 源端口为所述远程源地址信息获取单元获取的 IP地 址和端口, 所述目的 IP地址、 目的端口为与所述远程 Socket调用 良务器在 同一局域网内的业务服务器的 IP地址和端口; 封装所述第一关联函数的信息 为第三消息结构体;向所述远程 Socket调用服务器发送所述第三消息结构体, 以使得所述远程 Socket调用服务器执行所述第三消息结构体中的第一关联函 数所对应的第二关联函数以关联所述源 IP地址、 源端口、 目的 IP地址、 目 的端口与所述 Socket连接;
数据传输单元 904 , 用于获取所述业务客户端调用的第一传输函数, 所述 第一传输函数为用于通过所述 Socket连接标识符所标识的 Socket连接进行 网络数据交互的函数; 封装所述第一传输函数的信息为第四消息结构体; 向 所述远程 Socket 调用服务器发送所述第四消息结构体, 以使得所述远程 Socket调用服务器执行所述第四消息结构体中的第一传输函数所对应的第二 传输函数以通过所述 Socket连接与所述业务服务器进行网络数据交互。
具体地, 所述第一传输函数可以为用于通过所述 Socke t连接发送网络数 据的函数, 所述第一传输函数还包括网络数据; 所述数据传输单元具体用于 向所述远程 Socket 调用服务器发送所述第四消息结构体, 以使得所述远程 Socke t调用服务器执行所述第四消息结构体中的第一传输函数所对应的第二 传输函数以通过所述 Socket连接向所述业务服务器发送所述网络数据;
具体地, 所述第一传输函数还可以为用于通过所述 Socket连接接收网络 数据的函数; 所述数据传输单元具体用于向所述远程 Socket调用服务器发送 所述第四消息结构体, 以使得所述远程 Socket调用服务器执行所述第四消息 结构体中的第一传输函数所对应的第二传输函数以通过所述 Socket连接从所 述业务服务器接收网络数据, 所述数据传输单元还用于接收所述远程 Socket 调用服务器执行所述第二传输函数所接收的所述网络数据并将所述网络数据 发送给所述业务客户端。
优选地,所述装置还包括: HTTP隧道建立单元 905 ,用于与所述远程 Socket 调用服务器建立 HTTP隧道, 所述装置和所述远程 Socket调用服务器之间通 过该 HTTP隧道进行通信, 所述装置可以通过所述 HTTP隧道发送所述第一消 息结构体、 第二消息结构体、 第三消息结构体和第四消息结构体, 所述远程 Socket调用服务器可以通过所述 HTTP隧道向所述装置发送执行所述第二创建 函数的返回值(如创建的 Socket连接的 Socket连接标识符) 、 第二获取函 数(如获取的 IP地址和端口 ) 、 第二关联函数、 第二传输函数的返回值(如 从所述业务服务器接收的网络数据 ) 。 本发明实施例提供了一种互联***, 所述***包括如本发明实施例五和 六所述的互联装置, 远程 Socket调用服务器, 业务客户端, 业务服务器; 所 述远程 Socket调用服务器执行所述互联装置发送的消息结构体中第一 Socket API函数所对应的第二 Socket API函数, 以使得第一局域网中的拥有所述互 联装置的所述业务客户端与第二局域网中的所述业务服务器在公网上互联, 所述远程 Socket调用服务器在所述第二局域网中, 所述第二局域网在所述公 网中。 本发明实施例所提供的互联***在远程 Socket调用客户端组件与远程 Socket调用月良务器之间建立 HTTP隧道和 Socket连接,实现了远程 Socket调 用客户端组件与远程 Socket调用服务器的互联, 又由于远程 Socket调用客 户端组件是业务客户端上的一个组件, 远程 Socket调用服务器运行在业务服 务器网络内, 因此便实现了业务客户端和业务服务器的互联, 即实现了局域 网中的业务客户端与与所述远程 Socket调用服务器在同一局域网内的所述业 务服务器在公网上的互联。 远程 Socket调用客户端和远程 Socket调用服务 器基于应用层实现远程 Socket调用, 不改变操作***, 网络特性, 而且不需 要关注网络协议, 实现非常筒单。
本发明实施例提供的互联方法、 装置和***基于应用层实现远程 Socket 调用, 不改变操作***和网络特性, 而且不需要关注网络协议, 节省了端口 资源,降低了组网复杂程度。另外,本发明作为软件 SVN ( SSL Vi r tua l Pr ivate Network , 加密虚拟专用网)方案, 可以替代硬件 SVN设备, 实现筒单, 成本 低廉。
专业人员应该还可以进一步意识到, 结合本文中所公开的实施例描述的 各示例的单元及算法步骤, 能够以电子硬件、 计算机软件或者二者的结合来 实现, 为了清楚地说明硬件和软件的可互换性, 在上述说明中已经按照功能 一般性地描述了各示例的组成及步骤。 这些功能究竟以硬件还是软件方式来 执行, 取决于技术方案的特定应用和设计约束条件。 专业技术人员可以对每 个特定的应用来使用不同方法来实现所描述的功能, 但是这种实现不应认为 超出本发明的范围。 结合本文中所公开的实施例描述的方法或算法的步骤可以用硬件、 处理 器执行的软件模块, 或者二者的结合来实施。 软件模块可以置于随机存储器
( RAM ) 、 内存、 只读存储器(ROM ) 、 电可编程 R0M、 电可擦除可编程 R0M、 寄存器、 硬盘、 可移动磁盘、 CD-ROM, 或技术领域内所公知的任意其它形式 的存储介质中。
以上所述的具体实施方式, 对本发明的目的、 技术方案和有益效果进行 了进一步详细说明, 所应理解的是, 以上所述仅为本发明的具体实施方式而 已, 并不用于限定本发明的保护范围, 凡在本发明的精神和原则之内, 所做 的任何修改、 等同替换、 改进等, 均应包含在本发明的保护范围之内。

Claims

权利要求书
1、 一种互联方法, 其特征在于, 所述方法包括:
获取业务客户端调用的第一套接字编程接口 Socket API函数的信息; 封装所述第一 Socket API函数的信息为一个消息结构体;
发送所述消息结构体, 以使得接收方执行所述消息结构体中第一 Socket API函数所对应的第二 Socket API函数。
2、 如权利要求 1所述的互联方法, 其特征在于, 所述方法还包括: 接收 所述第二 Socket API函数的返回值。
3、 如权利要求 1所述的互联方法, 其特征在于, 所述方法还包括: 向所 述远程 Socket调用服务器发起一个超文本传输协议 HTTP隧道建立连接,建立 一个 HTTP隧道;
所述发送消息结构体具体为: 通过所述 HTTP隧道发送所述消息结构体。
4、 如权利要求 1 所述的互联方法, 其特征在于, 所述第一 Socket API 函数可以为创建 Socket连接的函数; 或获取远程 Socket调用服务器所在局域 网的空闲的 IP地址和端口的函数; 或关联源 IP地址、 源端口、 目的 IP地址、 目的端口与所述 Socket连接的函数, 所述源 IP地址和所述源端口为所述空闲 的 IP地址和端口。
5、 如权利要求 4所述的互联方法, 其特征在于, 所述第一 Socket API 函数还可以为通过所述 Socket连接进行网络数据交互的函数; 或用于设置或获 取所述 Socket连接的参数的函数; 或关闭所述 Socket连接的函数。
6、 如权利要求 3所述的互联方法, 其特征在于, 所述通过所述 HTTP隧 道发送所述消息结构体具体为:
将所述消息结构体打包在第一 HTTP数据包中, 调用操作***中的 Socket
API发送所述第一 HTTP数据包;
所述 Socket API将所述第一 HTTP数据包生成为第一 IP包;
所述操作***调用物理网卡, 将所述第一 IP 包发送到网络地址转换 NAT 网关; 所述 NAT网关^ ίι爹改所述第一 IP包的源地址和源端口为公网 IP地址和一个 新端口, 生成第二 IP包;
所述第二 IP包经过公网路由, 到达远程 Socket调用服务器的公网地址。
7、 如权利要求 1 -3和 6中任意一项所述的互联方法, 其特征在于, 所述 接收方为远程 Socket调用服务器; 所述第一 Socket API 函数具体为: 用于创 建 Socket连接的 Socket API函数; 或用于获取所述远程 Socket调用月良务器所 在局域网的空闲的 IP地址和端口的 Socket API函数; 或用于关联源 IP地址、 源端口、 目的 IP地址、 目的端口与所述远程 Socket调用月良务器创建的 Socket 连接的 Socket API函数, 所述源 IP地址和所述源端口为所述远程 Socket调用 月良务器所在局域网的空闲的 IP地址和端口, 所述目的 IP地址和所述目的端口 为与所述远程 Socket调用服务器在同一局域网内的业务服务器的 IP地址和端 口; 或用于通过所述远程 Socket调用服务器创建的 Socket连接进行网络数据 交互的 Socket API 函数, 所述 Socket连接的源 IP地址和源端口为所述远程 Socket调用月良务器所在局域网的 IP地址和端口,所述 Socket连接的目的 IP地 址和目的端口为与所述远程 Socket调用服务器在同一局域网内的业务服务器的 IP地址和端口。
8、 一种互联方法, 其特征在于, 所述方法包括: 远程 Socket调用客户端获取业务客户端调用的第一创建函数, 所述第一创 建函数为用于创建 Socket连接的 Socket API 函数; 封装所述第一创建函数的 信息为第一消息结构体; 向所述远程 Socket调用服务器发送所述第一消息结构 体, 以使得所述远程 Socket调用服务器执行所述第一消息结构体中的第一创建 函数所对应的第二创建函数以创建 Socket连接; 接收所述远程 Socket调用服 务器返回的所述 Socket连接的 Socket连接标识符并发送给所述业务客户端; 所述远程 Socket调用客户端获取所述业务客户端调用的第一获取函数, 所 述第一获取函数为用于获取所述远程 Socket调用服务器所在局域网的空闲的 IP 地址和端口的 Socket API函数; 封装所述第一获取函数的信息为第二消息结构 体; 向所述远程 Socket调用服务器发送所述第二消息结构体, 以使得所述远程 Socket调用服务器执行所述第二消息结构体中的第一获取函数所对应的第二获 取函数以获取所述远程 Socket调用月良务器所在局域网的空闲的 IP地址和端口; 接收所述远程 Socket调用服务器返回的所述远程 Socket调用服务器所在局域 网的空闲的 IP地址和端口并发送给所述业务客户端; 所述远程 Socket调用客户端获取所述业务客户端调用的第一关联函数, 所 述第一关联函数为关联源 IP地址、源端口、目的 IP地址、目的端口与所述 Socket 连接标识符所标识的 Socket连接的函数, 所述源 IP地址、 源端口为所述返回 的 IP地址和端口, 所述目的 IP地址、 目的端口为与所述远程 Socket调用 务 器在同一局域网内的业务服务器的 IP地址和端口; 封装所述第一关联函数的信 息为第三消息结构体;向所述远程 Socket调用服务器发送所述第三消息结构体, 以使得所述远程 Socket调用服务器执行所述第三消息结构体中的第一关联函数 所对应的第二关联函数以关联所述源 IP地址、 源端口、 目的 IP地址、 目的端 口与所述 Socket连接; 所述远程 Socket调用客户端获取所述业务客户端调用的第一传输函数, 所 述第一传输函数为用于通过所述 Socket连接标识符所标识的 Socket连接进行 网络数据交互的函数; 封装所述第一传输函数的信息为第四消息结构体; 向所 述远程 Socket 调用服务器发送所述第四消息结构体, 以使得所述远程 Socket 调用服务器执行所述第四消息结构体中的第一传输函数所对应的第二传输函数 以通过所述 Socket连接与所述业务服务器进行网络数据交互。
9、 如权利要求 8所述的互联方法, 其特征在于,
所述第一传输函数为用于通过所述 Socket连接发送网络数据的函数, 所述 第一传输函数还包括网络数据;所述远程 Socket调用客户端向所述远程 Socket 调用服务器发送所述第四消息结构体, 以使得所述远程 Socket调用服务器执行 所述第四消息结构体中的第一传输函数所对应的第二传输函数以通过所述
Socket连接向所述业务服务器发送所述网络数据; 或者,
所述第一传输函数为用于通过所述 Socket连接接收网络数据的函数; 所述 远程 Socket调用客户端向所述远程 Socket调用服务器发送所述第四消息结构 体, 以使得所述远程 Socket调用服务器执行所述第四消息结构体中的第一传输 函数所对应的第二传输函数以通过所述 Socket连接从所述业务服务器接收网络 数据, 接收所述远程 Socket调用服务器执行所述第二传输函数所接收的所述网 络数据并将所述网络数据发送给所述业务客户端。
10、 如权利要求 8或 9所述的互联方法, 其特征在于, 所述方法还包括: 向所述远程 Socket调用服务器发起一个超文本传输协议 HTTP隧道建立连接, 建立一个 HTTP隧道; 所述远程 Socket调用客户端通过所述 HTTP隧道发送所述 第一消息结构体、 第二消息结构体、 第三消息结构体和第四消息结构体。
1 1、 一种互联装置, 其特征在于, 所述装置包括:
获取单元, 用于获取业务客户端调用的第一套接字编程接口 Socket API函 数的信息;
封装单元, 用于封装所述第一 Socket API函数的信息为一个消息结构体; 发送单元, 用于发送所述消息结构体, 以使得接收方执行所述消息结构体 中第一 Socket API函数所对应的第二 Socket API函数。
12、 如权利要求 1 1所述的互联装置,其特征在于,所述装置还包括: HTTP 隧道建立单元, 用于向所述远程 Socket调用服务器发起一个超文本传输协议 HTTP隧道建立连接, 建立一个 HTTP隧道;
所述发送单元具体用于通过所述 HTTP隧道发送所述消息结构体。
13、 如权利要求 1 1所述的互联装置, 其特征在于,
所述发送单元, 具体用于向远程 Socket调用服务器发送所述消息结构体; 所述获取单元获取的所述第一 Socket API函数, 具体为用于通过所述远程 Socket调用服务器创建的 Socket连接进行网络数据交互的 Socket API函数, 所述 Socket连接的源 IP地址和源端口为所述远程 Socket调用 务器所在局域 网的 IP地址和端口, 所述 Socket连接的目的 IP地址和目的端口为与所述远程 Socket调用服务器在同一局域网内的业务服务器的 IP地址和端口。
14、 如权利要求 1 1 -13任一所述的互联装置, 其特征在于, 所述装置还包 括: Socket连接创建单元, 用于向所述远程 Socket调用服务器发起 Socket连 接创建请求, 创建一个 Socket连接。
15、 如权利要求 14所述的互联装置, 其特征在于, 所述装置还包括: 源 地址信息获取单元, 用于获取远程 Socket调用服务器所在局域网的空闲的 IP 地址和端口, 将其作为源 I P地址和源端口。
16、 如权利要求 15所述的互联装置, 其特征在于, 所述装置还包括: 关 联单元, 用于关联所述源 IP地址、 所述源端口、 目的 IP地址、 目的端口与所述 Socket连接。
17、 一种互联装置, 其特征在于, 所述装置包括:
远程 Socket连接创建单元, 用于获取业务客户端调用的第一创建函数, 所 述第一创建函数为用于创建 Socket连接的 Socket API 函数; 封装所述第一创 建函数的信息为第一消息结构体; 向所述远程 Socket调用服务器发送所述第一 消息结构体, 以使得所述远程 Socket调用服务器执行所述第一消息结构体中的 第一创建函数所对应的第二创建函数以创建 Socket连接;接收所述远程 Socket 调用服务器返回的所述 Socket连接的 Socket连接标识符并发送给所述业务客 户端;
远程源地址信息获取单元, 用于获取所述业务客户端调用的第一获取函数, 所述第一获取函数为用于获取所述远程 Socket调用服务器所在局域网的空闲的 IP地址和端口的 Socket API函数; 封装所述第一获取函数的信息为第二消息结 构体; 向所述远程 Socket调用服务器发送所述第二消息结构体, 以使得所述远 程 Socket调用服务器执行所述第二消息结构体中的第一获取函数所对应的第二 获取函数以获取所述远程 Socket调用服务器所在局域网的空闲的 IP地址和端 口; 接收所述远程 Socket调用服务器返回的所述远程 Socket调用服务器所在 局域网的空闲的 IP地址和端口并发送给所述业务客户端;
远程关联单元, 用于获取所述业务客户端调用的第一关联函数, 所述第一 关联函数为关联源 IP地址、源端口、 目的 IP地址、 目的端口与所述远程 Socket 连接创建单元所接收的 Socket连接标识符所标识的 Socket连接的函数, 所述 源 IP地址、 源端口为所述远程源地址信息获取单元获取的 IP地址和端口, 所 述目的 IP地址、 目的端口为与所述远程 Socket调用月良务器在同一局域网内的 业务服务器的 IP地址和端口;封装所述第一关联函数的信息为第三消息结构体; 向所述远程 Socket 调用服务器发送所述第三消息结构体, 以使得所述远程 Socket调用服务器执行所述第三消息结构体中的第一关联函数所对应的第二关 联函数以关联所述源 IP地址、 源端口、 目的 IP地址、 目的端口与所述 Socket 连接;
数据传输单元, 用于获取所述业务客户端调用的第一传输函数, 所述第一 传输函数为用于通过所述 Socket连接标识符所标识的 Socket连接进行网络数 据交互的函数; 封装所述第一传输函数的信息为第四消息结构体; 向所述远程 Socket调用服务器发送所述第四消息结构体,以使得所述远程 Socket调用服务 器执行所述第四消息结构体中的第一传输函数所对应的第二传输函数以通过所 述 Socket连接与所述业务服务器进行网络数据交互。
18、 如权利要求 17所述的互联装置, 其特征在于,
所述第一传输函数具体为用于通过所述 Socket连接发送网络数据的函数, 所述第一传输函数还包括网络数据; 所述数据传输单元具体用于向所述远程 Socket调用服务器发送所述第四消息结构体,以使得所述远程 Socket调用服务 器执行所述第四消息结构体中的第一传输函数所对应的第二传输函数以通过所 述 Socket连接向所述业务服务器发送所述网络数据; 或者,
所述第一传输函数具体为用于通过所述 Socket连接接收网络数据的函数; 所述数据传输单元具体用于向所述远程 Socket调用服务器发送所述第四消息结 构体, 以使得所述远程 Socket调用服务器执行所述第四消息结构体中的第一传 输函数所对应的第二传输函数以通过所述 Socket连接从所述业务服务器接收网 络数据, 所述数据传输单元还用于接收所述远程 Socket调用服务器执行所述第 二传输函数所接收的所述网络数据并将所述网络数据发送给所述业务客户端。
19、 如权利要求 17或 18所述的互联装置, 其特征在于,
所述装置还包括: HTTP隧道建立单元, 用于与所述远程 Socket调用服务器 建立 HTTP隧道, 所述远程 Socket连接创建单元通过所述 HTTP隧道发送所述第 一消息结构体, 所述远程源地址信息获取单元通过所述 HTTP隧道发送所述第二 消息结构体, 所述远程关联单元通过所述 HTTP隧道发送所述第三消息结构体, 所述数据传输单元通过所述 HTTP隧道发送所述第四消息结构体。
20、 一种互联***, 其特征在于, 所述***包括如权利要求 1 1 -19任意一 项所述的互联装置, 以及远程 Socket调用服务器, 业务客户端, 业务服务器; 所述远程 Socket 调用服务器执行所述互联装置发送的消息结构体中第一 Socket API函数所对应的第二 Socket API函数, 以使得第一局域网中的拥有所 述互联装置的所述业务客户端与第二局域网中的所述业务服务器在公网上互 联, 所述远程 Socket调用服务器在所述第二局域网中, 所述第二局域网在所述 公网中。
PCT/CN2012/085060 2011-12-13 2012-11-22 一种互联方法、装置和*** WO2013086928A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP12857411.8A EP2712127A4 (en) 2011-12-13 2012-11-22 METHOD, DEVICE AND INTERCONNECTION SYSTEM
US14/143,433 US9137334B2 (en) 2011-12-13 2013-12-30 Interconnection method, apparatus, and system based on socket remote invocation

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110415004.2A CN103166824B (zh) 2011-12-13 2011-12-13 一种互联方法、装置和***
CN201110415004.2 2011-12-13

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/143,433 Continuation US9137334B2 (en) 2011-12-13 2013-12-30 Interconnection method, apparatus, and system based on socket remote invocation

Publications (1)

Publication Number Publication Date
WO2013086928A1 true WO2013086928A1 (zh) 2013-06-20

Family

ID=48589576

Family Applications (2)

Application Number Title Priority Date Filing Date
PCT/CN2012/080439 WO2013086869A1 (zh) 2011-12-13 2012-08-22 一种互联方法、装置和***
PCT/CN2012/085060 WO2013086928A1 (zh) 2011-12-13 2012-11-22 一种互联方法、装置和***

Family Applications Before (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/080439 WO2013086869A1 (zh) 2011-12-13 2012-08-22 一种互联方法、装置和***

Country Status (4)

Country Link
US (1) US9137334B2 (zh)
EP (1) EP2712127A4 (zh)
CN (1) CN103166824B (zh)
WO (2) WO2013086869A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105721473A (zh) * 2016-02-24 2016-06-29 锐达互动科技股份有限公司 一种web端远程调用优化的方法及***

Families Citing this family (56)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9292248B2 (en) * 2011-06-22 2016-03-22 Microsoft Technology Licensing, Llc Span out load balancing model
US10749711B2 (en) 2013-07-10 2020-08-18 Nicira, Inc. Network-link method useful for a last-mile connectivity in an edge-gateway multipath system
US10454714B2 (en) 2013-07-10 2019-10-22 Nicira, Inc. Method and system of overlay flow control
CN103442224A (zh) * 2013-09-09 2013-12-11 杭州巨峰科技有限公司 一种基于nat穿透的视频监控访问策略和实现方法
US20160072764A1 (en) * 2014-09-10 2016-03-10 T-Mobile Usa, Inc. Dynamic double network address translator
US10425382B2 (en) 2015-04-13 2019-09-24 Nicira, Inc. Method and system of a cloud-based multipath routing protocol
US10498652B2 (en) 2015-04-13 2019-12-03 Nicira, Inc. Method and system of application-aware routing with crowdsourcing
US10135789B2 (en) 2015-04-13 2018-11-20 Nicira, Inc. Method and system of establishing a virtual private network in a cloud service for branch networking
US10608985B2 (en) * 2015-08-14 2020-03-31 Oracle International Corporation Multihoming for tunneled encapsulated media
CN105208041B (zh) * 2015-10-15 2018-09-21 厦门大学 基于hook的云存储应用加密数据包破解方法
CN106027489B (zh) * 2016-04-28 2019-05-31 腾讯科技(深圳)有限公司 互联网联机的方法、装置及***
US9614917B1 (en) 2016-10-24 2017-04-04 Signiant Inc. System and method of providing secure data transfer
US11252079B2 (en) 2017-01-31 2022-02-15 Vmware, Inc. High performance software-defined core network
US20200036624A1 (en) 2017-01-31 2020-01-30 The Mode Group High performance software-defined core network
US11706127B2 (en) 2017-01-31 2023-07-18 Vmware, Inc. High performance software-defined core network
US10992568B2 (en) 2017-01-31 2021-04-27 Vmware, Inc. High performance software-defined core network
US10992558B1 (en) 2017-11-06 2021-04-27 Vmware, Inc. Method and apparatus for distributed data network traffic optimization
US20180219765A1 (en) 2017-01-31 2018-08-02 Waltz Networks Method and Apparatus for Network Traffic Control Optimization
US11121962B2 (en) 2017-01-31 2021-09-14 Vmware, Inc. High performance software-defined core network
US10778528B2 (en) 2017-02-11 2020-09-15 Nicira, Inc. Method and system of connecting to a multipath hub in a cluster
US10523539B2 (en) 2017-06-22 2019-12-31 Nicira, Inc. Method and system of resiliency in cloud-delivered SD-WAN
CN107426233A (zh) * 2017-08-08 2017-12-01 深圳先进技术研究院 基于B/S架构的数据通信***、方法、Web服务器及监控***
CN107544799A (zh) * 2017-08-21 2018-01-05 深圳市清显科技有限公司 一种对库函数进行封装的方法
US10999100B2 (en) 2017-10-02 2021-05-04 Vmware, Inc. Identifying multiple nodes in a virtual network defined over a set of public clouds to connect to an external SAAS provider
US11089111B2 (en) * 2017-10-02 2021-08-10 Vmware, Inc. Layer four optimization for a virtual network defined over public cloud
US10999165B2 (en) 2017-10-02 2021-05-04 Vmware, Inc. Three tiers of SaaS providers for deploying compute and network infrastructure in the public cloud
US10686625B2 (en) 2017-10-02 2020-06-16 Vmware, Inc. Defining and distributing routes for a virtual network
US11115480B2 (en) 2017-10-02 2021-09-07 Vmware, Inc. Layer four optimization for a virtual network defined over public cloud
US11223514B2 (en) 2017-11-09 2022-01-11 Nicira, Inc. Method and system of a dynamic high-availability mode based on current wide area network connectivity
CN109218203A (zh) * 2018-09-20 2019-01-15 上海龙弈信息科技有限公司 一种金融管理及风险控制处理***及其运行方法
CN110166479B (zh) * 2019-05-31 2022-02-01 深圳市瑞云科技有限公司 一种传输***提升udp发送效率的方法
CN110519232A (zh) * 2019-07-30 2019-11-29 裴小根 基于Android OS二维对称加密算法的文件远距离加密传输***
US11121985B2 (en) 2019-08-27 2021-09-14 Vmware, Inc. Defining different public cloud virtual networks for different entities based on different sets of measurements
US11044190B2 (en) 2019-10-28 2021-06-22 Vmware, Inc. Managing forwarding elements at edge nodes connected to a virtual network
US11394640B2 (en) 2019-12-12 2022-07-19 Vmware, Inc. Collecting and analyzing data regarding flows associated with DPI parameters
US11489783B2 (en) 2019-12-12 2022-11-01 Vmware, Inc. Performing deep packet inspection in a software defined wide area network
US11722925B2 (en) 2020-01-24 2023-08-08 Vmware, Inc. Performing service class aware load balancing to distribute packets of a flow among multiple network links
US11477127B2 (en) 2020-07-02 2022-10-18 Vmware, Inc. Methods and apparatus for application aware hub clustering techniques for a hyper scale SD-WAN
US11709710B2 (en) 2020-07-30 2023-07-25 Vmware, Inc. Memory allocator for I/O operations
US11838375B2 (en) * 2020-11-12 2023-12-05 Harman International Industries, Incorporated Universal software communication bus
US11575591B2 (en) 2020-11-17 2023-02-07 Vmware, Inc. Autonomous distributed forwarding plane traceability based anomaly detection in application traffic for hyper-scale SD-WAN
US11575600B2 (en) 2020-11-24 2023-02-07 Vmware, Inc. Tunnel-less SD-WAN
US11929903B2 (en) 2020-12-29 2024-03-12 VMware LLC Emulating packet flows to assess network links for SD-WAN
US11792127B2 (en) 2021-01-18 2023-10-17 Vmware, Inc. Network-aware load balancing
US11979325B2 (en) 2021-01-28 2024-05-07 VMware LLC Dynamic SD-WAN hub cluster scaling with machine learning
US11388086B1 (en) 2021-05-03 2022-07-12 Vmware, Inc. On demand routing mesh for dynamically adjusting SD-WAN edge forwarding node roles to facilitate routing through an SD-WAN
US12009987B2 (en) 2021-05-03 2024-06-11 VMware LLC Methods to support dynamic transit paths through hub clustering across branches in SD-WAN
US11729065B2 (en) 2021-05-06 2023-08-15 Vmware, Inc. Methods for application defined virtual network service among multiple transport in SD-WAN
US12015536B2 (en) 2021-06-18 2024-06-18 VMware LLC Method and apparatus for deploying tenant deployable elements across public clouds based on harvested performance metrics of types of resource elements in the public clouds
US11489720B1 (en) 2021-06-18 2022-11-01 Vmware, Inc. Method and apparatus to evaluate resource elements and public clouds for deploying tenant deployable elements based on harvested performance metrics
US12047282B2 (en) 2021-07-22 2024-07-23 VMware LLC Methods for smart bandwidth aggregation based dynamic overlay selection among preferred exits in SD-WAN
US11375005B1 (en) 2021-07-24 2022-06-28 Vmware, Inc. High availability solutions for a secure access service edge application
US11943146B2 (en) 2021-10-01 2024-03-26 VMware LLC Traffic prioritization in SD-WAN
CN114125574A (zh) * 2021-11-19 2022-03-01 浩云科技股份有限公司 一种单向的流媒体传输方法及***
US11909815B2 (en) 2022-06-06 2024-02-20 VMware LLC Routing based on geolocation costs
US12034587B1 (en) 2023-03-27 2024-07-09 VMware LLC Identifying and remediating anomalies in a self-healing network

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101159657A (zh) * 2007-10-16 2008-04-09 华为技术有限公司 一种实现私网穿越的方法、设备及服务器
CN101206590A (zh) * 2006-12-21 2008-06-25 国际商业机器公司 用于扩展用于通信的Unix域套接字的方法、装置和***

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7117267B2 (en) * 2001-06-28 2006-10-03 Sun Microsystems, Inc. System and method for providing tunnel connections between entities in a messaging system
US6895590B2 (en) * 2001-09-26 2005-05-17 Intel Corporation Method and system enabling both legacy and new applications to access an InfiniBand fabric via a socket API
CN100344122C (zh) * 2003-04-22 2007-10-17 华为技术有限公司 一种实现从指定端口发送数据报类型报文的方法
US7529812B2 (en) * 2004-02-09 2009-05-05 Sun Microsystems, Inc. Socket connections over a serial link
US8954590B2 (en) * 2004-04-27 2015-02-10 Sap Ag Tunneling apparatus and method for client-server communication
US7457849B2 (en) * 2004-06-08 2008-11-25 Printronix, Inc. Controlled firewall penetration for management of discrete devices
US7738468B2 (en) * 2005-03-22 2010-06-15 Logitech Europe S.A. Method and apparatus for packet traversal of a network address translation device
JP2009230269A (ja) * 2008-03-19 2009-10-08 Sony Corp 情報処理装置、情報処理方法、リモートサーバ、情報処理システム
CN102215243A (zh) * 2010-04-12 2011-10-12 华为技术有限公司 事件同步的方法、***、客户端和服务端

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101206590A (zh) * 2006-12-21 2008-06-25 国际商业机器公司 用于扩展用于通信的Unix域套接字的方法、装置和***
CN101159657A (zh) * 2007-10-16 2008-04-09 华为技术有限公司 一种实现私网穿越的方法、设备及服务器

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP2712127A4 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105721473A (zh) * 2016-02-24 2016-06-29 锐达互动科技股份有限公司 一种web端远程调用优化的方法及***

Also Published As

Publication number Publication date
EP2712127A1 (en) 2014-03-26
EP2712127A4 (en) 2015-02-18
WO2013086869A1 (zh) 2013-06-20
US20140115047A1 (en) 2014-04-24
US9137334B2 (en) 2015-09-15
CN103166824A (zh) 2013-06-19
CN103166824B (zh) 2016-09-28

Similar Documents

Publication Publication Date Title
WO2013086928A1 (zh) 一种互联方法、装置和***
JP4708376B2 (ja) プライベートネットワークへのアクセスを安全にする方法およびシステム
WO2021073565A1 (zh) 业务服务提供方法及***
RU2533063C2 (ru) Способ установления соединения (варианты), способ передачи пакета данных и система удаленного доступа
JP4794312B2 (ja) イーサネット・ベースのネットワーク内の擬似ワイヤ・ピア・アドレスの自動検出
JP4146886B2 (ja) 通信モジュール及びこの通信モジュールを備えたアプリケーションプログラム
WO2015143802A1 (zh) 业务功能链处理方法及装置
WO2020033493A1 (en) Application transmission control protocol tunneling over the public internet
WO2021073555A1 (zh) 业务服务提供方法及***、远端加速网关
WO2007036160A1 (fr) Appareil, systeme et procede assurant la communication entre un client et un serveur
US20180270084A1 (en) Technique for exchanging datagrams between application modules
WO2019041332A1 (zh) 一种加速网络传输优化方法以及***
CN111158864B (zh) 数据处理方法、装置、***、介质和程序
CN107483369A (zh) 一种报文处理方法及虚拟交换机
JP6403450B2 (ja) トンネル接続装置、通信ネットワーク、データ通信方法、及びプログラム
JP5438230B2 (ja) インターネット接続システム
WO2023274146A1 (zh) 远程接入方法、电子设备及存储介质
CN103391271A (zh) 数据包转发方法和装置
CN117176678A (zh) 一种数据处理的方法及装置、电子设备、存储介质
CN113067911A (zh) 一种nat穿越方法、装置、电子设备和存储介质
JP2007110266A (ja) ルータ、パケットフォワード方法、およびパケットフォワードプログラム

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: 12857411

Country of ref document: EP

Kind code of ref document: A1

REEP Request for entry into the european phase

Ref document number: 2012857411

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2012857411

Country of ref document: EP

NENP Non-entry into the national phase

Ref country code: DE