[go: up one dir, main page]

CN109587083B - Data transmission method and related device - Google Patents

Data transmission method and related device Download PDF

Info

Publication number
CN109587083B
CN109587083B CN201811470222.4A CN201811470222A CN109587083B CN 109587083 B CN109587083 B CN 109587083B CN 201811470222 A CN201811470222 A CN 201811470222A CN 109587083 B CN109587083 B CN 109587083B
Authority
CN
China
Prior art keywords
virtual router
switch
buffer
data packet
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811470222.4A
Other languages
Chinese (zh)
Other versions
CN109587083A (en
Inventor
匡光彩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811470222.4A priority Critical patent/CN109587083B/en
Publication of CN109587083A publication Critical patent/CN109587083A/en
Application granted granted Critical
Publication of CN109587083B publication Critical patent/CN109587083B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/25Routing or path finding in a switch fabric
    • H04L49/252Store and forward routing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/58Association of routers
    • H04L45/586Association of routers of virtual routers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/70Virtual switches

Landscapes

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

Abstract

The application provides a data transmission method and a data transmission device, which are applied to a switch, wherein the switch comprises a virtual router, a virtual router switchboard and a first buffer area, and the method comprises the following steps: a virtual router of the switch receives a first data packet from a terminal device; the virtual router of the switch replaces the source Internet Protocol (IP) address of the first data packet with a preset IP address to obtain a second data packet; the virtual router of the switch stores the second data packet in the first buffer area, and the first buffer area is used for storing data sent to a virtual router switchboard of the switch by the virtual router of the switch; and the virtual router switchboard of the switch reads the second data packet from the first buffer area. By implementing the method and the device, the hardware cost can be reduced, and the efficiency and the stability of data transmission are improved.

Description

Data transmission method and related device
Technical Field
The present invention relates to the field of computers, and in particular, to a data transmission method and apparatus.
Background
At present, the internet has become an indispensable part of people's daily life. Virtual Private Cloud (VPC) is an important component of internet communication. A plurality of VPCs can be divided from a public cloud through a VPC technology, each VPC is logically and thoroughly isolated from each other, and a user can set an Internet Protocol (IP) address range, a network segment and a routing table in the VPC. In order to ensure network security and facilitate management of different hosts, multiple VPC subnets may be partitioned from the VPC.
In the actual use process, each VPC subnet is connected with one router in a butt joint mode, the router receives a data packet of the VPC subnet, then the IP address of the data packet is converted, and the data packet after the IP address is converted is forwarded to the router switchboard. The router switchboard collects the data packets from the routers and forwards the data packets to the public server, so that the communication between the terminal equipment under the VPC subnet and the public server is realized. On one hand, the data transmission system needs to consume a large amount of hardware equipment, and the hardware cost is too high; on the other hand, the plurality of routers and the router switchboard transmit data through the access line, so that the data transmission efficiency is low.
At present, a plurality of virtual routers are usually deployed on one switch, and after receiving data packets, the virtual routers forward the data packets to a router switchboard, so that the hardware cost can be effectively reduced.
The execution scheme needs to deploy a router switchboard of an entity, and the virtual router needs to send data to the router switchboard through an access line, so that the problems of high hardware cost, low data transmission efficiency and the like exist.
Disclosure of Invention
The application provides a data transmission method and a related device, which can reduce hardware cost and improve data transmission efficiency and stability.
In a first aspect, the present application provides a data transmission method applied to a switch, where the switch includes a virtual router, a virtual router switchboard, and a first buffer, and the method includes:
a virtual router of the switch receives a first data packet from a terminal device;
the virtual router of the switch replaces the source Internet Protocol (IP) address of the first data packet with a preset IP address to obtain a second data packet;
the virtual router of the switch stores the second data packet in the first buffer area, and the first buffer area is used for storing data sent to a virtual router switchboard of the switch by the virtual router of the switch;
and the virtual router switchboard of the switch reads the second data packet from the first buffer area.
By implementing the embodiment of the application, the virtual router and the virtual router switchboard are deployed on the same switch, and the virtual router rapidly sends the data packet to the virtual router switchboard through the buffer area, so that the hardware cost can be reduced, and the data transmission efficiency can be improved.
With reference to the first aspect, in a possible implementation manner, before the virtual router of the switch sends the second packet to the first buffer, the method further includes:
determining, by the virtual router of the switch, whether a remaining storage space of the first buffer is below a first threshold;
if the value is lower than a first threshold value, suspending a storage process, wherein the storage process is a process used for storing data into the first buffer area in a virtual router of the switch;
otherwise, starting the storage process;
the virtual router of the switch storing the second packet in a first buffer, comprising:
and the virtual router of the switch stores the second data packet into the first buffer area through the storage process.
With reference to the first aspect, in a possible implementation manner, before the reading, by the virtual router host of the switch, the second packet from the first buffer, the method further includes:
the virtual router switchboard of the switch determines whether the residual storage space of the data packet in the first buffer area is higher than a second threshold value;
if the value is higher than a second threshold value, suspending a reading process, wherein the reading process is a process for reading data from the first buffer area in a virtual router switchboard of the switch;
otherwise, starting a reading process;
the virtual router host of the switch reads the second packet from the first buffer, and includes:
and the virtual router switchboard of the switch reads the second data packet from the first buffer area through the reading process.
In a possible implementation manner, the switch further includes a second buffer, where the second buffer is configured to store data sent by the virtual router host of the switch to the virtual router of the switch, and after the virtual router host of the switch reads the second data packet from the first buffer, the method further includes:
the virtual router switchboard of the switch checks the received second data packet to obtain check information;
and the virtual router switchboard of the switch sends the check information to the second buffer area.
In a possible implementation manner, after the virtual router host of the switch sends the check information to the second buffer, the method further includes:
reading the check information from the second buffer by the virtual router of the switch;
the virtual router of the switch determines whether the second data packet received by the virtual router switchboard of the switch is wrong or not according to the check information;
and if the error occurs, the second data packet is sent to the first buffer again.
In a possible implementation manner, before retransmitting the second packet to the first buffer, the method further includes:
and the virtual router of the switch sends the second data packet to a backup area, wherein the backup area is a storage area used for backing up the data packet in the virtual router of the switch.
With reference to the second aspect, in a possible implementation manner, the determining, by the virtual router of the switch, whether the remaining storage space of the first buffer is lower than a first threshold includes:
the virtual router may acquire the remaining storage space of the first buffer area with a preset time as a period, and determine whether the remaining storage space of the first buffer area is lower than a first threshold.
In a possible implementation manner, the method further includes:
reading fault information from the second buffer by the virtual router of the switch, wherein the fault information is used for indicating that a virtual router switchboard of the switch is in a fault state;
and if the virtual router of the switch reads the fault information, closing the storage process.
By implementing the embodiment of the application, the sending port can be closed in time when the virtual router switchboard breaks down, data loss and transmission errors are avoided, the stability of data transmission is improved, and the resources of the switch are saved.
In a second aspect, the present application provides a data transmission apparatus, comprising:
a receiving unit, configured to receive a first data packet from a terminal device;
a conversion unit, configured to replace a source internet protocol IP address of the first data packet with a preset IP address to obtain a second data packet;
a storage unit, configured to store the second packet in the first buffer, where the first buffer is used to store data sent by the virtual router of the switch to the virtual router switchboard of the switch;
a reading unit, configured to read the second data packet from the first buffer.
With reference to the second aspect, in a possible implementation manner, the apparatus further includes:
a first determining unit, configured to determine whether a remaining storage space of the first buffer is lower than a first threshold;
a first suspending unit, configured to suspend a storage process when a remaining storage space of the first buffer is lower than a first threshold, where the storage process is a process in a virtual router of a switch, where the process is used to store data in the first buffer;
a first starting unit, configured to start the storage process when a remaining storage space of the first buffer is not lower than a first threshold;
the storage unit is specifically configured to store the second data packet into the first buffer through the storage process.
With reference to the second aspect, in a possible implementation manner, the apparatus further includes:
a second determining unit, configured to determine whether a remaining storage space in the first buffer is higher than a second threshold;
a second suspending unit, configured to suspend a reading process when a remaining storage space in the first buffer is higher than a second threshold, where the reading process is a process used for reading data from the first buffer in a virtual router switchboard of the switch;
a second starting unit, configured to start the reading process when a remaining storage space in the first buffer is not higher than a second threshold;
the reading unit is specifically configured to read the second data packet from the first buffer through the reading process.
With reference to the second aspect, in a possible implementation manner, the apparatus further includes:
the checking unit is used for checking the second data packet read from the first buffer area to obtain checking information;
and the second storage unit is used for storing the verification information into a second buffer area.
In a possible implementation manner, the apparatus further includes:
a second reading unit, configured to read the check information from the second buffer;
a third determining unit, configured to determine whether the second packet received by the virtual router host of the switch is incorrect according to the check information;
and a closing unit, configured to close the storage process when it is determined that the second packet received by the virtual router host of the switch is an error.
In a third aspect, the present application provides a data transmission apparatus, including a processor, a memory, and a transceiver; the processor, the memory and the transceiver are connected with each other through a bus; wherein the transceiver is configured to receive and transmit data packets, the memory is configured to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to perform the method of the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program comprises program instructions, which, when executed by a processor, cause the processor to perform the method according to the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program product comprising program instructions which, when run on a computer, cause the computer to perform the method according to the first aspect.
By implementing the method and the device, the hardware cost can be reduced, and the efficiency and the stability of data transmission are improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments or the background art of the present application, the drawings required to be used in the embodiments or the background art of the present application will be described below.
Fig. 1 is a schematic structural diagram of a data transmission system proposed in the present application;
FIG. 2 is a flow chart of a data transmission method proposed in the present application;
FIG. 3 is a flow chart of another data transmission method proposed in the present application;
FIG. 4 is a flow chart of another data transmission method proposed in the present application;
fig. 5 is a schematic structural diagram of a data transmission device proposed in the present application;
fig. 6 is a schematic structural diagram of another data transmission device proposed in the present application;
fig. 7 is a schematic structural diagram of another data transmission device proposed in the present application;
fig. 8 is a schematic structural diagram of another data transmission device proposed in the present application.
Detailed Description
The terms "first," "second," and the like in the description and claims of the present application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, or apparatus.
The application provides a data transmission method and device, which can reduce hardware cost and improve data transmission efficiency and stability. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 1 is a block diagram of a data transmission system proposed in the present application. As can be seen from fig. 1, the system comprises at least one terminal device 101, a switch 102 and a common server 103. The switch 102 includes at least one virtual router 102A, at least one first buffer 102B, at least one second buffer 102D, and a virtual router switchboard 102C. The virtual router 102A of the switch 102 receives a first data packet sent by the terminal device 101, replaces a source IP address of the first data packet with a preset IP address to obtain a second data packet, and stores the second data packet in the first buffer 102B. The virtual router host 102C of the switch 102 reads the data packet from the first buffer 102B, and forwards the data packet to the public server 103.
In one possible implementation, the virtual router host 102C may send the data information to the virtual router 102B through the second buffer 102D. The virtual router switchboard 102C may store data information into the second buffer 102D, and the virtual router 102A may read the data information from the second buffer 102D. The data information may include one or more of a data packet from a common server, check information of the second data packet, and failure information of the virtual router host 102C.
By implementing the embodiment of the application, the virtual router and the virtual router switchboard are deployed in the same switch, so that the hardware cost can be reduced; data exchange is carried out between the virtual router and the virtual router switchboard through the buffer area, so that the data transmission efficiency can be accelerated, and the stability of data transmission is improved.
Fig. 2 is a flowchart of a data transmission method proposed in the present application. The method is applied to a switch, wherein the switch comprises a virtual router, a virtual router switchboard and a first buffer area, and the method comprises the following steps:
201. the virtual router of the switch receives a first packet from the end device.
The switch is a hardware device that provides a signal communication channel for two network nodes, and the switch can be loaded with a suitable operating system and various software. The terminal device may include a handheld device having a wireless communication function, a vehicle-mounted device, a wearable device, a computing device or other processing device connected to a wireless modem, and various forms of User Equipment (UE), a Mobile Station (MS), and the like. Wherein, the terminal devices may be located in the same VPC subnet.
The virtual router is deployed on a switch, has an independent routing table, an Input/output (I/O) port, a cache, an address space and the like, and can realize packet forwarding and packet IP address replacement. In a possible implementation manner, there may be multiple virtual routers, and each virtual router may respectively interface with terminal devices under different VPC subnets.
Specifically, the header of the first data packet may include one or more of an Internet Protocol (IP) address of a virtual router, an IP address of a terminal device, and an IP address of a target device, and a payload of the first data packet is data information to be transmitted.
In a possible implementation manner, if there are multiple terminal devices under the same VPC subnet to send data packets to the virtual router, the virtual router may establish connection with each terminal device in sequence, and receive the data packets of the terminal devices in sequence. Or, the virtual router may start a plurality of receiving threads, and receive the data packets from each terminal device through different receiving ports, where the threads correspond to the receiving ports and the terminal devices one to one.
202. And the virtual router of the switch replaces the source internet protocol IP address of the first data packet with a preset IP address to obtain a second data packet.
When the user sets the network segment of the VPC subnet, the network segment can be the same as the network segments of other VPC subnets. After the VPC subnet allocates an IP address to the terminal device, the IP address of the terminal device may have the same IP address as that of the terminal device in other VPC subnets, so that the server may not recognize the IP address of the terminal device. The virtual router may replace an IP address of the packet sent by the terminal device with a preset IP address, so that the server may identify the terminal device.
Specifically, the virtual router may replace the source IP address of the first packet with a unique public IP address. For example, the IP address of the first packet may be replaced with an IP address between 1.0.0.0 and 9.255.255.255.
Specifically, the virtual router may reserve a part of the source IP address of the first packet, and replace another part according to a preset rule to obtain a preset IP address. In a possible implementation manner, the virtual router may replace the network number of the source IP address of the first packet with the network number of the public IP address, and reserve the host number. Namely, the host number of the source IP address is combined with the network number of the public IP address to obtain a preset IP address, and then the source IP address is replaced by the preset IP address.
203. And the virtual router of the switch stores the second data packet into the first buffer area, and the first buffer area is used for storing data sent to a virtual router switchboard of the switch by the virtual router of the switch.
Optionally, the first buffer may be a queue data structure. The queue data structure satisfies the principle of first-in first-out, that is, the data packet stored in the queue first is taken out first. In a possible implementation manner, the queue data structure may be a ring queue, that is, the virtual router may write data circularly along the ring queue, and the virtual router reads data circularly along the ring queue. The first buffer is disposed on the switch, and preferably disposed in a memory of the switch, where the memory may be a Random Access Memory (RAM).
In a possible implementation manner, before sending the second packet to the first buffer, the virtual router may determine whether the first buffer is full. If the first buffer area is filled up, the process of sending the data packet is suspended, and after the data packet in the buffer area is read, the data is continuously written into the buffer area. Specifically, the virtual router may calculate a remaining storage space of the first buffer, and suspend the process of writing data if the remaining storage space of the first buffer is zero. More specifically, if the first buffer is a circular queue data structure, when the virtual router accesses a storage space corresponding to a next address of the circular queue, if the storage space corresponding to the next address is written with data, it is determined that the circular queue is full, and the virtual router may suspend a process of writing data.
204. And the virtual router switchboard of the switch reads the second data packet from the first buffer area.
The virtual router switchboard is deployed in the switch, and can read the second data packet from the virtual router from the first buffer area and send the second data packet to the public server.
In a possible implementation manner, if a plurality of virtual routers are deployed in the switch, the plurality of virtual routers may respectively correspond to one first buffer, and the virtual router switchboard may respectively read the data packets sent by each virtual router from the plurality of first buffers. Specifically, the virtual router switchboard may create a plurality of reading threads, and the plurality of reading threads respectively read the data packet through each reading port, that is, one reading process corresponds to one reading port and one first buffer. Optionally, in order to reduce the resource overhead of the switch, the virtual router host may start a read thread, and read the data packet from each first buffer in a polling manner. And after the virtual router switchboard reads the data packets from the plurality of first buffer areas, sending the data packets of the plurality of first buffer areas to a public server.
By implementing the embodiment of the application, the hardware cost can be reduced, and the efficiency and the stability of data transmission can be improved.
Fig. 3 is a flow chart of another data transmission method proposed in the present application. The method is applied to a switch, and the switch comprises a virtual router, a virtual router switchboard, a first buffer area and a second buffer area. The method comprises the following steps:
301. a virtual router of a switch receives a first packet from an end device.
302. And the virtual router of the switch replaces the source IP address of the first data packet with a preset IP address to obtain a second data packet.
303. Determining, by the virtual router of the switch, whether a remaining storage space of the first buffer is below a first threshold; if the value is lower than a first threshold value, suspending a storage process, wherein the storage process is a process used for storing data into the first buffer area in a virtual router of the switch; otherwise, starting the storage process.
In actual operation, when the first buffer is filled with data, if the virtual router continues to write data into the first buffer, the original data in the first buffer may be overwritten, which causes a data loss problem. When the remaining storage space of the first buffer area is lower than the first threshold value, the data packet storage to the first buffer area is suspended in time, so that the original data can be prevented from being covered.
In a possible implementation manner, before the virtual router of the switch stores the data packet in the first buffer, the method further includes: the virtual router creates a storage process.
Specifically, the first threshold may be a specified proportion of the total storage space of the first buffer. For example, the first threshold may be 5% of the total storage space of the first buffer, and the storage process is suspended when the virtual router determines that the remaining storage space of the first buffer is less than 5% of the total storage space. In one possible implementation, the virtual router may suspend the storage process when the first buffer is filled (i.e., the remaining storage space is zero).
In a possible implementation manner, the virtual router may suspend the storage process for a preset time, that is, if the virtual router detects that the remaining storage space of the first buffer is lower than a first threshold, the virtual router waits for the preset time and then continues to store the data packet to the first buffer.
In a possible implementation manner, the virtual router may obtain the remaining storage space of the first buffer area with a preset time as a period, and determine whether the remaining storage space of the first buffer area is lower than a first threshold; if the first threshold value is lower than the first threshold value, the storage process is suspended; otherwise, starting the storage process.
304. And the virtual router of the switch stores the second data packet into the first buffer area through the storage process.
305. Determining whether the remaining storage space of the first buffer is higher than a second threshold by a virtual router switchboard of the switch; if the threshold value is higher than the second threshold value, suspending the reading process; the reading process is a process for reading data from the first buffer area in a virtual router switchboard of the switch; otherwise, the read process is started.
In a possible implementation manner, before the virtual router host of the switch starts the reading process, the method further includes: the virtual router switchboard creates a reading process.
Specifically, the second threshold may be a specified proportion of the total storage space of the first buffer. For example, the second threshold may be 5% of the total storage space of the first buffer, and the storage process is suspended when the virtual router determines that the storage space of the first buffer is less than 5% of the total storage space. In a possible implementation manner, the virtual router may suspend the storage process when the first buffer is completely read (i.e., the remaining storage space is the total storage space).
In a possible implementation manner, the virtual router host may suspend the reading process for a preset time, that is, if the virtual router host detects that the remaining storage space of the first buffer is higher than a second threshold, the virtual router host waits for the preset time and then continues to store the data packet in the second buffer.
In a possible implementation manner, the virtual router switchboard may obtain the remaining storage space of the first buffer area with a preset time as a period, and determine whether the remaining storage space of the first buffer area is higher than a second threshold; if the threshold value is higher than the second threshold value, suspending the reading process; otherwise, the reading process is started.
In this embodiment of the application, when the data in the first buffer is completely read, if the virtual router host continues to read the data from the first buffer, on one hand, a read pointer and a write pointer may intersect, which may cause the virtual router and the virtual router host to fail to correctly read and store the data, and on the other hand, resources of the switch may be wasted. And starting the reading process when the residual storage space of the first buffer area is lower than the second threshold value, so that the problem caused by the intersection of a reading pointer and a writing pointer of the reading process can be avoided, and the switch resource can be saved.
306. And the virtual router switchboard of the switch reads the second data packet from the first buffer area through the reading process.
307. The virtual router switchboard of the switch checks the received second data packet to obtain check information; and the virtual router switchboard of the switch stores the check information into the second buffer area.
After receiving the second data packet, the virtual router switchboard may check the data packet to obtain check information, where the check information may be used to determine whether the data packet received by the virtual router switchboard is correct. Specifically, the checking technique for checking the second data packet may include an accumulation check, an exclusive-or check, a parity check, and the like.
Taking the accumulative check technology as an example, the virtual router host may add the data of the data packet in units of bytes, and perform a modulo operation on the sum pair 256 to obtain a result, which is the accumulative check code. And after the target gateway calculates and obtains the accumulated check code, sending the accumulated check code to the second buffer area so that the virtual router can verify the accumulated check code.
308. Reading the check information from the second buffer by the virtual router of the switch; the virtual router of the switch determines whether the second data packet received by the virtual router switchboard of the switch is wrong or not according to the check information; and if the error occurs, the second data packet is sent to the first buffer again.
The data read from the second buffer by the virtual router includes the check information, and after the virtual router obtains the check information, the check information may be compared with a preset check information template to determine whether the second data packet received by the virtual router switchboard is erroneous.
Taking the accumulative verification technique as an example, before the virtual router sends the second data packet, the virtual router may use the obtained accumulative verification code of the second data packet as a preset verification information template. And after reading the check information from the second buffer area, the virtual router compares the check information with a preset check information template, and judges whether the check information is matched with the preset check information template. If the data packets are matched with the data packets, the data packets received by the virtual router switchboard are correct; otherwise, the data packet received by the virtual router switchboard is incorrect.
And if the virtual router determines that the second data packet received by the virtual router switchboard is incorrect, the second data packet is stored in the second buffer area again. Before the second packet is restored in the second buffer, the virtual router may backup the second packet in a backup area of the virtual router, where the backup area may be a queue data structure.
By implementing the embodiment of the application, the hardware cost can be reduced, the efficiency and the stability of data transmission can be improved, and the error rate of data transmission can be reduced.
Fig. 4 is a flow chart of another data transmission method proposed in the present application. The method is applied to a switch, and the switch comprises a virtual router, a virtual router switchboard, a first buffer area and a second buffer area. The method comprises the following steps:
401. a virtual router of a switch receives a first packet from an end device.
402. And the virtual router of the switch replaces the source IP address of the first data packet with the public IP address to obtain a second data packet.
403. Determining, by the virtual router of the switch, whether the first buffer is filled; if the virtual router is filled with the data, suspending a storage process, wherein the storage process is a process used for storing the data into the first buffer area in the virtual router of the switch; otherwise, starting the storage process.
For example, the virtual router may read the byte number of the first buffer, and if the byte number of the first buffer is equal to the byte number of the total storage space of the first buffer, the first buffer is full; if the number of bytes of the first buffer area is less than the number of bytes of the total storage space of the first buffer area, it indicates that the first buffer area is full.
For another example, if the first buffer is a ring queue, the virtual router may determine whether a next address of the ring queue is written with data. If the data is written, the first buffer area is filled.
404. And the virtual router of the switch stores the second data packet into the first buffer area through the storage process.
405. Determining whether the data volume of the first buffer area is zero or not by a virtual router switchboard of the switch; if the value is zero, suspending the reading process; otherwise, the storage process is started.
The virtual router switchboard can read the byte number of the data stored in the first buffer area, and the reading process is suspended if the byte number is zero; otherwise, the reading process is started.
In a possible implementation manner, the virtual router host may read the number of bytes of the data stored in the first buffer in a cycle of a preset time, and determine whether the data amount of the first buffer is zero; if the value is zero, suspending the reading process; otherwise, the read process is started.
406. And the virtual router switchboard of the switch reads the second data packet from the first buffer area through the reading process.
407. The virtual router switchboard of the switch performs accumulation check on the received second data packet to obtain an accumulation check code; and the virtual router switchboard of the switch stores the accumulated check code into the second buffer area.
The virtual router switchboard may add the data of the second data packet in units of bytes, and perform modulo operation on the sum obtained by the adding of 256, so that the obtained result is the accumulated check code. And after the virtual router switchboard obtains the accumulated check code, storing the accumulated check code into the second buffer area.
408. Reading the accumulated check code from the second buffer by the virtual router of the switch; the virtual router of the switch determines whether the second data packet received by the virtual router switchboard of the switch is wrong or not according to the accumulated check code; and if the error occurs, the second data packet is stored in the first buffer area again.
Before the virtual router stores the second data packet in the first buffer, the virtual router may acquire an accumulated check code of the second data packet as a check information template. The virtual router may compare the accumulated checksum with a check information template after reading the accumulated checksum from the second buffer. If the accumulated check code is matched with the check information template, determining that the second data packet received by the virtual router switchboard is correct; otherwise, the second data packet received by the virtual router switchboard is determined to be wrong.
409. Reading, by the virtual router of the switch, failure information from the second buffer, the failure information indicating that the virtual router exchange is in a failure state; and if the virtual router of the switch reads the fault information, closing the reading process.
When the virtual router exchange fails, failure information may be sent to the second buffer. Or, when the second buffer detects that the read port or the write port of the virtual router switchboard is abnormally closed, generating fault information.
If the virtual router reads the fault information, the reading process is closed, data loss is avoided, and meanwhile resources of the switch are saved.
By implementing the embodiment of the application, the hardware cost can be reduced, the efficiency and the stability of data transmission are improved, the error rate of data transmission is reduced, and the resources of the switch are saved.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a data transmission device according to an embodiment of the present application, where the data transmission device includes:
a receiving unit 501, configured to receive a first data packet from a terminal device;
a conversion unit 502, configured to replace a source IP address of the first data packet with a preset IP address to obtain a second data packet;
a storage unit 503, configured to store the second packet in the first buffer, where the first buffer is used to store data sent by the virtual router of the switch to the virtual router switchboard of the switch;
a reading unit 504, configured to read the second data packet from the first buffer.
As shown in fig. 6, the above apparatus further includes:
a first determining unit 505, configured to determine whether a remaining storage space of the first buffer is lower than a first threshold;
a first suspending unit 506, configured to suspend a storage process when a remaining storage space of the first buffer is lower than a first threshold, where the storage process is a process in a virtual router of a switch, where the process is used to store data in the first buffer;
a first starting unit 507, configured to start the storage process when the remaining storage space of the first buffer is not lower than a first threshold;
a second determining unit 508, configured to determine whether the remaining storage space in the first buffer is higher than a second threshold;
a second suspending unit 509, configured to suspend a reading process when a remaining storage space in the first buffer is higher than a second threshold, where the reading process is a process in a virtual router switchboard of the switch, where the reading process is used to read data from the first buffer;
a second starting unit 510, configured to start a reading process when the remaining storage space in the first buffer is not higher than a second threshold.
In a possible implementation manner, the storage unit 503 is specifically configured to store the second data packet in the first buffer through the storage process.
In a possible implementation manner, the reading unit 504 is specifically configured to read the second data packet from the first buffer through the reading process.
As shown in fig. 7, the above apparatus further includes:
a checking unit 511, configured to check the second data packet read from the first buffer to obtain check information;
a second storage unit 512, configured to store the check information in a second buffer.
In a possible implementation manner, the apparatus further includes:
a second reading unit 513, configured to read the check information from the second buffer;
a third determining unit 514, configured to determine whether the second packet received by the virtual router host of the switch is erroneous according to the check information;
a closing unit 515, configured to close the storage process when the second packet received by the virtual router host of the switch is an error.
It is understood that the specific implementation of the data transmission apparatus shown in fig. 5, 6 and 7 can also refer to the methods shown in fig. 2, 3 and 4, and detailed description thereof is omitted here.
By implementing the embodiment of the application, the hardware cost can be reduced, the efficiency and the stability of data transmission are improved, the error rate of data transmission is reduced, and the hardware resources are saved.
Referring to fig. 8, fig. 8 is a schematic structural diagram of another data transmission device according to an embodiment of the present disclosure. The device includes: at least one processor 801, such as a Central Processing Unit (CPU), at least one memory 802, at least one transceiver 803, and at least one bus 804. The bus 804 may be a set of parallel data lines for interconnecting the processor 801, the memory 802, and the transceiver 803; the memory 802 may be a Random Access Memory (RAM) or a non-volatile memory (ROM), such as at least one Read Only Memory (ROM).
Specifically, the transceiver 803 may be configured to receive a data packet sent by a terminal device; for sending the data packet to the public server.
In a possible implementation manner, the transceiver 803 is further configured to receive a data packet sent by a common server, and forward the data packet to a terminal device, so as to implement communication between the terminal device and the server.
In one possible implementation, the memory 802 may store program instructions, and the processor 801 may be configured to call the program instructions to perform the methods shown in fig. 2, 3, and 4.
It will be understood by those of ordinary skill in the art that all or part of the steps in the methods of the above embodiments may be performed by associated hardware instructed by a program, and the program may be stored in a computer-readable storage medium, which includes Read Only Memory (ROM), Random Access Memory (RAM), Programmable Read Only Memory (PROM), Erasable Programmable Read Only Memory (EPROM), one-time programmable read only memory (OTPROM), Electrically Erasable Programmable Read Only Memory (EEPROM), compact disc read only memory (CD-ROM), or other memories, CD-ROM, magnetic disks, or magnetic tapes, Or any other medium which can be used to carry or store data and which can be read by a computer.
The data transmission method and apparatus disclosed in the embodiments of the present application are described in detail above, and specific examples are applied in the description to explain the principle and the implementation of the present application, and the description of the embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, the specific embodiments and the application range may be changed. In view of the above, the description should not be taken as limiting the application.

Claims (10)

1. A data transmission method applied to a switch, wherein the switch comprises a virtual router, a virtual router switchboard and a first buffer, and the method comprises:
a virtual router of the switch receives a first data packet from a terminal device;
the virtual router of the switch replaces the source internet protocol IP address of the first data packet with a unique public IP address, or replaces the network number of the source internet protocol IP address of the first data packet with the network number of the public IP address and reserves the host number to obtain a second data packet;
the virtual router of the switch stores the second data packet into the first buffer area, and the first buffer area is used for storing data sent by the virtual router of the switch to a virtual router switchboard of the switch;
and the virtual router switchboard of the switch reads the second data packet from the first buffer area and sends the second data packet to a public server.
2. The method of claim 1, further comprising, before the virtual router of the switch stores the second packet in the first buffer:
determining, by a virtual router of the switch, whether a remaining storage space of the first buffer is below a first threshold;
if the data is lower than the first threshold value, suspending a storage process, wherein the storage process is a process used for storing data into the first buffer area in a virtual router of the switch;
otherwise, starting the storage process;
storing, by the virtual router of the switch, the second packet to a first buffer, comprising:
the virtual router of the switch stores the second data packet to the first buffer area through the storage process.
3. The method of claim 1, further comprising, before the virtual router host of the switch reads the second packet from the first buffer:
determining, by a virtual router switchboard of the switch, whether a remaining storage space in the first buffer is below a second threshold;
if the value is lower than a second threshold value, suspending a reading process, wherein the reading process is a process used for reading data from the first buffer area in a virtual router switchboard of the switch;
otherwise, starting a reading process;
the virtual router switchboard of the switch reads the second data packet from the first buffer area, and the method comprises the following steps:
and the virtual router switchboard of the switch reads the second data packet from the first buffer area through the reading process.
4. The method of any of claims 1 to 3, wherein the switch further comprises a second buffer for storing data sent by the virtual router aggregate of the switch to the virtual router of the switch, and wherein after the virtual router aggregate of the switch reads the second packet from the first buffer, the method further comprises:
the virtual router switchboard of the switch verifies the read second data packet to obtain verification information;
and the virtual router switchboard of the switch stores the check information into the second buffer area.
5. The method of claim 4, wherein after the virtual router switchboard of the switch sends the check information to the second buffer, the method further comprises:
reading the check information from the second buffer area by the virtual router of the switch;
the virtual router of the switch determines whether the second data packet read by the virtual router switchboard of the switch is wrong or not according to the check information;
and if the second data packet is wrong, the second data packet is sent to the first buffer again.
6. A data transmission apparatus, comprising:
a receiving unit, configured to receive a first data packet from a terminal device;
a conversion unit, configured to replace a source internet protocol IP address of the first packet with a public IP address having uniqueness, or replace a network number of the source internet protocol IP address of the first packet with a network number of the public IP address and reserve a host number, to obtain a second packet;
the storage unit is used for storing the second data packet into a first buffer area, and the first buffer area is used for storing data sent to a virtual router switchboard of the switch by a virtual router of the switch;
and the reading unit is used for reading the second data packet from the first buffer area and sending the second data packet to a public server.
7. The apparatus of claim 6, further comprising:
a first determination unit configured to determine whether a remaining storage space of the first buffer is lower than a first threshold;
a first suspending unit, configured to suspend a storage process when a remaining storage space of the first buffer is lower than a first threshold, where the storage process is a process in a virtual router of a switch, and the process is used to store data in the first buffer;
the first starting unit is used for starting the storage process when the residual storage space of the first buffer zone is not lower than a first threshold value;
the storage unit is specifically configured to store the second data packet in the first buffer through the storage process.
8. The apparatus of claim 6, further comprising:
a second determination unit configured to determine whether a remaining storage space in the first buffer is lower than a second threshold;
a second suspending unit, configured to suspend a reading process when a remaining storage space in the first buffer is lower than a second threshold, where the reading process is a process in a virtual router switchboard of the switch, and the reading process is used for reading data from the first buffer;
the second starting unit is used for starting a reading process when the residual storage space in the first buffer zone is not lower than a second threshold value;
the reading unit is specifically configured to read the second data packet from the first buffer by the reading process.
9. A data transmission apparatus comprising a processor, a memory and a transceiver; the processor, the memory and the transceiver are connected to each other by a bus; wherein the transceiver is configured to receive and transmit data packets, the memory is configured to store a computer program comprising program instructions, and the processor is configured to invoke the program instructions to perform the method of any of claims 1 to 5.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions that, when executed by a processor, cause the processor to carry out the method according to any one of claims 1 to 5.
CN201811470222.4A 2018-11-30 2018-11-30 Data transmission method and related device Active CN109587083B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811470222.4A CN109587083B (en) 2018-11-30 2018-11-30 Data transmission method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811470222.4A CN109587083B (en) 2018-11-30 2018-11-30 Data transmission method and related device

Publications (2)

Publication Number Publication Date
CN109587083A CN109587083A (en) 2019-04-05
CN109587083B true CN109587083B (en) 2022-04-29

Family

ID=65927138

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811470222.4A Active CN109587083B (en) 2018-11-30 2018-11-30 Data transmission method and related device

Country Status (1)

Country Link
CN (1) CN109587083B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110493227B (en) * 2019-08-20 2021-12-24 上海集成电路研发中心有限公司 Data frame transmission method and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8094659B1 (en) * 2007-07-09 2012-01-10 Marvell Israel (M.I.S.L) Ltd. Policy-based virtual routing and forwarding (VRF) assignment
CN103595772A (en) * 2013-11-01 2014-02-19 浪潮电子信息产业股份有限公司 Cloud data center network deployment scheme based on virtual router
CN107229492A (en) * 2017-05-17 2017-10-03 东软集团股份有限公司 Installation method, device, system, storage medium and the equipment of server system
CN107846358A (en) * 2016-09-19 2018-03-27 北京金山云网络技术有限公司 A kind of data transmission method, device and network system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8094659B1 (en) * 2007-07-09 2012-01-10 Marvell Israel (M.I.S.L) Ltd. Policy-based virtual routing and forwarding (VRF) assignment
CN103595772A (en) * 2013-11-01 2014-02-19 浪潮电子信息产业股份有限公司 Cloud data center network deployment scheme based on virtual router
CN107846358A (en) * 2016-09-19 2018-03-27 北京金山云网络技术有限公司 A kind of data transmission method, device and network system
CN107229492A (en) * 2017-05-17 2017-10-03 东软集团股份有限公司 Installation method, device, system, storage medium and the equipment of server system

Also Published As

Publication number Publication date
CN109587083A (en) 2019-04-05

Similar Documents

Publication Publication Date Title
JP7029471B2 (en) Uplink data decompression, compression method and equipment
US11902139B2 (en) Diagnosing and resolving issues in a network using probe packets
US8892982B2 (en) Method and system for network latency virtualization in a cloud transport environment
CN105634937B (en) A kind for the treatment of method and apparatus of message
TW201743205A (en) Firmware updating method
US20140160952A1 (en) Detecting and isolating dropped or out-of-order packets in communication networks
CN103188059A (en) Method, device and system for data packet retransmission in quick path interconnect system
US20220217093A1 (en) Sequence Number Synchronization Method and Apparatus
CN109587083B (en) Data transmission method and related device
US6339796B1 (en) System for logical connection resynchronization
CN116594948A (en) USB data transmission method, device, computer equipment and storage medium
JP5070125B2 (en) Reception device and method, communication system and method, and program
CN113259989A (en) Data retransmission method and device and electronic equipment
CN111131224B (en) Method for maintaining connection and storage device
JP3569149B2 (en) Communication control device
US20160261719A1 (en) Information processing system, control program, and control method
CN110169023A (en) A kind of data transmission method, data receiver and data transmitting equipment
US6230283B1 (en) Logical connection resynchronization
JP2005258632A (en) Method for checking continuity of network storage device and host computer
RU2383067C2 (en) Method of storing data packets using pointer technique
CN113626139B (en) High-availability virtual machine storage method and device
CN104615564A (en) Data transmission method based on QPI bus and computer system
CN108733598B (en) A data transmission method and data transmission device
CN109474693B (en) Data transmission method and related device
CN105391589A (en) Message transmission method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant