CN117093533B - Communication method and device for realizing multi-CPU architecture based on ubus framework - Google Patents

Communication method and device for realizing multi-CPU architecture based on ubus framework Download PDF

Info

Publication number
CN117093533B
CN117093533B CN202311051537.6A CN202311051537A CN117093533B CN 117093533 B CN117093533 B CN 117093533B CN 202311051537 A CN202311051537 A CN 202311051537A CN 117093533 B CN117093533 B CN 117093533B
Authority
CN
China
Prior art keywords
communication object
message
data
sent
communication
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
CN202311051537.6A
Other languages
Chinese (zh)
Other versions
CN117093533A (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.)
Jiangsu Xinzhi Information Technology Co ltd
Original Assignee
Jiangsu Xinzhi Information Technology 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 Jiangsu Xinzhi Information Technology Co ltd filed Critical Jiangsu Xinzhi Information Technology Co ltd
Priority to CN202311051537.6A priority Critical patent/CN117093533B/en
Publication of CN117093533A publication Critical patent/CN117093533A/en
Application granted granted Critical
Publication of CN117093533B publication Critical patent/CN117093533B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F15/00Digital computers in general; Data processing equipment in general
    • G06F15/16Combinations of two or more digital computers each having at least an arithmetic unit, a program unit and a register, e.g. for a simultaneous processing of several programs
    • G06F15/163Interprocessor communication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Computer And Data Communications (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The communication method and the device for realizing the multi-CPU architecture based on ubus framework are characterized in that parameters and data which are input by a user are packaged into a message in a preset format by using an API interface, and the message is sent to a ubusd process for processing through a UNIX domain socket; ubusd process analyzes the data attribute of the communication object name or the communication object ID in the message; if the communication object name and the communication object ID are not found in the local information, traversing all opposite end information of the routing table for comparison, if the comparison is successful, indicating that the message is sent to another CPU, and sending the message through a corresponding kcp session. The invention makes the business software not need to modify codes when the system of the multi-CPU architecture is transplanted, shields the bottom hardware architecture for the business software, and the business software is not affected by the change of the hardware structure; and the kcp protocol is used for communication, and the system protocol stack is not relied on, so that the system security is improved.

Description

Communication method and device for realizing multi-CPU architecture based on ubus framework
Technical Field
The invention belongs to the technical field of communication, and particularly relates to a communication method and device for realizing a multi-CPU architecture based on ubus framework.
Background
At present, the architecture of multiple CPUs in an embedded system is gradually increased, so that the reusability of software is reduced, and the difficulty of software transplanting and maintenance is increased; at the same time, the use of the system protocol stack for intra-system communication for security devices may expose the system to a risk of penetration attacks.
In the prior art, the communication framework is generally implemented by the following steps:
supporting communication between two or a fixed number of CPUs, this approach limits the use scenarios, requiring modification of software source code if a new system requires multiplexing of software modules, or requiring a change in software deployment location;
The TCP/IP protocol communication is usually needed to rely on a system protocol stack, the system protocol stack has long service time and wide range, the disclosed holes are more, and the equipment is easy to penetrate from the outside by utilizing the holes, so that isolation failure is caused, and functional modules in the equipment are attacked.
Disclosure of Invention
Therefore, the invention provides a communication method and a device for realizing a multi-CPU architecture based on ubus framework, which solve the problems that the traditional technology needs to modify software source codes and relies on the security of a system protocol stack to be poor.
In order to achieve the above object, the present invention provides the following technical solutions: in a first aspect, a communications method for implementing a multi-CPU architecture based on ubus framework is provided, including:
encapsulating parameters and data input by a user into a message in a preset format by using an API interface, wherein the message comprises data attributes and data objects, and the data attributes comprise a communication object name or a communication object ID;
the message is sent to ubusd processes for processing through UNIX domain sockets;
ubusd process parses the data attributes of the "communication object name" or "communication object ID" in the message:
If the analyzed data attribute is communication object name data, comparing the communication object name data with a character string of a 'NAMESPACE' tag under the home terminal information in a routing table, if the character string started by the initial letter of the communication object name data is the same as the character string represented by 'NAMESPACE', indicating that the message is sent to a home terminal CPU, searching a corresponding communication object name by a ubusd process through the communication object name data, if the names are the same, indicating that the message is sent to a communication object corresponding to the searched communication object name, and forwarding the message to the searched communication object;
If the analyzed data attribute is communication object ID data, the communication object ID data is compared with the numerical value of an ID label under the local end information in the routing table, if the number of the communication object ID data is within the range of the ID label, the message is sent to a local end CPU, a ubusd process searches a corresponding communication object ID through the communication object ID data, if the IDs are the same, the message is sent to a communication object corresponding to the searched communication object ID, and then the message is forwarded to the searched communication object;
If the communication object name and the communication object ID are not found in the local information, traversing all opposite end information of the routing table for comparison, if the comparison is successful, indicating that the message is sent to another CPU, and sending the message through a corresponding kcp session.
As a preferable scheme of the communication method for realizing the multi-CPU architecture based on ubus framework, the communication method further comprises the steps of configuring the routing table, wherein the routing table configuration comprises local end information and opposite end information;
the local information is stored under the label of the 'conf';
At least one set of opposite terminal information is stored under the labels of "[0]", "[1]", and "[2]", and the value of the label represents the number of the route.
As a preferable scheme for realizing the communication method of the multi-CPU architecture based on ubus framework, the process of traversing all opposite terminal information for comparison is as follows:
If the analyzed data attribute is communication object name data, comparing the communication object name data with a character string of a 'NAMESPACE' tag under opposite end information in a routing table, if the character string started by the initial letter of the communication object name data is the same as a character string represented by 'NAMESPACE', indicating that the message is sent to an opposite end CPU, searching a corresponding communication object name by a ubusd process through the communication object name data, if the names are the same, indicating that the message is sent to a communication object corresponding to the searched communication object name, and forwarding the message to the searched communication object;
If the analyzed data attribute is communication object ID data, the communication object ID data is compared with the numerical value of an ID label under opposite terminal information in the routing table, if the number of the communication object ID data is within the range of the ID label, the message is sent to an opposite terminal CPU, a ubusd process searches a corresponding communication object ID through the communication object ID data, if the IDs are the same, the message is sent to a communication object corresponding to the searched communication object ID, and then the message is forwarded to the searched communication object.
As a preferable scheme of the communication method for realizing the multi-CPU architecture based on ubus framework, if the "communication object name" and the "communication object ID" are not found in the home information and the opposite information of the routing table, the message is discarded.
As a preferred scheme of the communication method for realizing the multi-CPU architecture based on ubus framework, for the message communicated in the local CPU, a UNIX domain socket of a communication object is directly found, and then the message is sent to the corresponding communication object through a UNIX domain socket channel.
As a preferable scheme for realizing the communication method of the multi-CPU architecture based on ubus framework, for the message sent to the opposite-end CPU, after finding the matching item in the routing table of the opposite-end information, recording the index value, filling the ID of the sent data object into the head of the message to represent the message source, then obtaining the session of kcp through the index value of the matched opposite-end information, and sending out the data through the session of kcp.
In a second aspect, a communications apparatus for implementing a multi-CPU architecture based on ubus framework is provided, comprising:
A message assembly module, configured to encapsulate parameters and data entered by a user into a message in a predetermined format using an API interface, where the message includes a data attribute and a data object, and the data attribute includes a "communication object name" or a "communication object ID";
the message sending module is used for sending the message to the ubusd process for processing through the UNIX domain socket;
The message analysis module is used for analyzing the data attribute of the communication object name or the communication object ID in the message by ubusd processes;
the message parsing module includes:
The local terminal character string comparison sub-module is used for comparing the 'communication object name' data with the character string of the 'NAMESPACE' tag under the local terminal information in the routing table if the analyzed data attribute is the 'communication object name' data, and if the character string started by the initial letter of the 'communication object name' data is the same as the character string represented by 'NAMESPACE', the message is indicated to be sent to the local terminal CPU;
The first local communication object name searching sub-module is used for searching the corresponding communication object name through the data of the communication object name by ubusd processes, if the names are the same, the message is indicated to be sent to the communication object corresponding to the searched communication object name, and then the message is forwarded to the searched communication object;
The local end numerical value comparison sub-module is used for comparing the numerical value of the communication object ID data with the numerical value of the ID label under the local end information in the routing table if the analyzed data attribute is the communication object ID data, and indicating that the message is sent to the local end CPU if the numerical value of the communication object ID data is within the range of the ID label;
A second local communication object name searching sub-module, configured to search for a corresponding communication object ID by using "communication object ID" data by using the ubusd process, if the IDs are the same, indicate that the message is sent to a communication object corresponding to the searched communication object ID, and then forward the message to the searched communication object;
And the opposite terminal processing module is used for traversing all opposite terminal information of the routing table for comparison if the communication object name and the communication object ID are not found in the local terminal information, and sending the message out through a corresponding kcp session if the comparison is successful, which means that the message is sent to another CPU.
As a preferable scheme of the communication device for realizing the multi-CPU architecture based on ubus frames, the communication device further comprises a routing table configuration module, wherein the routing table configuration module is used for configuring the routing table, and the routing table configuration comprises local end information and opposite end information;
the local information is stored under the label of the 'conf';
At least one set of opposite terminal information is stored under the labels of "[0]", "[1]", and "[2]", and the value of the label represents the number of the route.
As a preferred embodiment of the communication device implementing the multi-CPU architecture based on ubus frames, the peer processing module includes:
The opposite terminal character string comparison sub-module compares the data of the communication object name with the character string of the NAMESPACE label under the opposite terminal information in the routing table if the analyzed data attribute is the data of the communication object name, and indicates that the message is sent to the opposite terminal CPU if the character string started by the initial letter of the data of the communication object name is the same as the character string represented by NAMESPACE;
The first opposite-end communication object name searching sub-module is used for searching the corresponding communication object name through the data of the communication object name by ubusd processes, if the names are the same, the message is indicated to be sent to the communication object corresponding to the searched communication object name, and then the message is forwarded to the searched communication object;
the opposite terminal numerical value comparison sub-module compares the numerical value of the communication object ID data with the numerical value of an ID label under opposite terminal information in the routing table if the analyzed data attribute is the communication object ID data, and indicates that the message is sent to an opposite terminal CPU if the numerical value of the communication object ID data is within the range of the ID label;
And the second opposite-end communication object name searching sub-module ubusd processes search the corresponding communication object ID through the communication object ID data, if the IDs are the same, the message is indicated to be sent to the communication object corresponding to the searched communication object ID, and then the message is forwarded to the searched communication object.
As a preferred scheme of the communication device for realizing the multi-CPU architecture based on ubus framework, the communication device further comprises a message discarding module for discarding the message if the communication object name and the communication object ID are not found in the local information and the opposite information of the routing table;
The first message forwarding module is used for directly finding a UNIX domain socket of a communication object for the message communicated in the CPU of the local terminal, and then sending the message to the corresponding communication object through a UNIX domain socket channel;
The second message forwarding module is used for searching a matching item in a routing table of opposite terminal information for a message sent to the opposite terminal CPU, recording an index value, filling an ID of a sent data object into a header of the message to represent a message source, acquiring a kcp session through the index value of the matched opposite terminal information, and sending out data through the kcp session.
A third aspect of the present invention provides a non-transitory computer readable storage medium having stored therein program code for implementing a multi-CPU architecture based on ubus framework communication method, the program code comprising instructions for executing the first aspect or any possible implementation thereof for implementing a multi-CPU architecture based on ubus framework communication method.
A fourth aspect of the present invention provides an electronic device, comprising: a memory and a processor; the processor and the memory complete communication with each other through a bus; the memory stores program instructions executable by the processor to invoke the program instructions to enable execution of the communication method of the first aspect or any possible implementation thereof implementing the multi-CPU architecture based on the ubus framework.
The method has the beneficial effects that parameters and data which are input by a user are encapsulated into a message in a preset format by using an API interface, wherein the message comprises data attributes and data objects, and the data attributes comprise a communication object name or a communication object ID; the message is sent to ubusd processes for processing through UNIX domain sockets; ubusd process parses the data attributes of the "communication object name" or "communication object ID" in the message: if the analyzed data attribute is communication object name data, comparing the communication object name data with a character string of a 'NAMESPACE' tag under the home terminal information in a routing table, if the character string started by the initial letter of the communication object name data is the same as the character string represented by 'NAMESPACE', indicating that the message is sent to a home terminal CPU, searching a corresponding communication object name by a ubusd process through the communication object name data, if the names are the same, indicating that the message is sent to a communication object corresponding to the searched communication object name, and forwarding the message to the searched communication object; if the analyzed data attribute is communication object ID data, the communication object ID data is compared with the numerical value of an ID label under the local end information in the routing table, if the number of the communication object ID data is within the range of the ID label, the message is sent to a local end CPU, a ubusd process searches a corresponding communication object ID through the communication object ID data, if the IDs are the same, the message is sent to a communication object corresponding to the searched communication object ID, and then the message is forwarded to the searched communication object; if the communication object name and the communication object ID are not found in the local information, traversing all opposite end information of the routing table for comparison, if the comparison is successful, indicating that the message is sent to another CPU, and sending the message through a corresponding kcp session. The invention can make the software support the communication among multiple CPUs by modifying the static route configuration file, and the service software is changed and deployed without modifying codes; the kcp protocol is used for communication, so that the system protocol stack is not relied on, and the system security is improved; the bottom hardware architecture is shielded for the business software, and the business software is not affected by the change of the hardware structure.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below. It will be apparent to those skilled in the art from this disclosure that the drawings described below are merely exemplary and that other embodiments may be derived from the drawings provided without undue effort.
The structures, proportions, sizes, etc. shown in the present specification are shown only for the purposes of illustration and description, and are not intended to limit the scope of the invention, which is defined by the claims, so that any structural modifications, changes in proportions, or adjustments of sizes, which do not affect the efficacy or the achievement of the present invention, should fall within the scope of the invention.
Fig. 1 is a schematic flow chart of a communication method for implementing a multi-CPU architecture based on ubus frames according to an embodiment of the present invention;
Fig. 2 is a schematic diagram of a communication process in a communication method for implementing a multi-CPU architecture based on ubus frames according to an embodiment of the present invention;
Fig. 3 is a schematic diagram of a communication device for implementing a multi-CPU architecture based on ubus frames according to an embodiment of the present invention.
Detailed Description
Other advantages and advantages of the present invention will become apparent to those skilled in the art from the following detailed description, which, by way of illustration, is to be read in connection with certain specific embodiments, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1
Referring to fig. 1, embodiment 1 of the present invention provides a communication method for implementing a multi-CPU architecture based on ubus frames, including the following steps:
s1, packaging parameters and data input by a user into a message in a preset format by using an API interface, wherein the message comprises data attributes and data objects, and the data attributes comprise a communication object name or a communication object ID;
S2, sending the message to ubusd processes for processing through UNIX domain sockets;
S3, ubusd processes analyze the data attribute of the communication object name or the communication object ID in the message:
S31, if the analyzed data attribute is 'communication object name' data, comparing the 'communication object name' data with a character string of a 'NAMESPACE' tag under the home terminal information in a routing table, if the character string started by the initial letter of the 'communication object name' data is the same as the character string represented by 'NAMESPACE', indicating that the message is sent to a home terminal CPU, and if the names are the same, indicating that the message is sent to a communication object corresponding to the searched communication object name by a ubusd process through the 'communication object name' data, and then forwarding the message to the searched communication object;
S32, if the analyzed data attribute is communication object ID data, comparing the communication object ID data with the numerical value of an ID label under the local end information in the routing table, if the numerical value of the communication object ID data is within the range of the ID label, indicating that the message is sent to a local end CPU, searching a corresponding communication object ID through the communication object ID data by ubusd processes, if the IDs are the same, indicating that the message is sent to a communication object corresponding to the searched communication object ID, and forwarding the message to the searched communication object;
And S33, if the communication object name and the communication object ID are not found in the local terminal information, traversing all opposite terminal information of the routing table for comparison, and if the comparison is successful, indicating that the message is sent to another CPU, and sending the message through a corresponding kcp session.
In this embodiment, the method further includes step S0 of configuring the routing table, where the routing table configuration includes home terminal information and peer terminal information;
the local information is stored under the label of the 'conf';
At least one set of opposite terminal information is stored under the labels of "[0]", "[1]", and "[2]", and the value of the label represents the number of the route.
Specifically, the routing table is composed of "home information" and "opposite information", the "home information" is stored under the label "[ conf ]" and only one group, the meaning of the "home information" is as follows:
a) The value of the "ID" tag indicates the number start value to which the present CPU communication object is assigned.
B) The "NAMESPACE" tag indicates the namespace of the communication object registered on the present CPU.
The "opposite-end information" may have a plurality of sets, and is stored under the labels "[0]," [1], "[2]," and the label value indicates the number of the route (from 0), and the "opposite-end information" has the following meaning:
a') ID, which indicates the assigned number start value of the CPU communication object;
b') NAMESPACE, which represents the namespace of the communication objects registered on the CPU;
c') SESSION, which represents the kcp SESSION number of the channel;
d') PROTOCOL, which represents the channel link layer PROTOCOL number;
e') DEV, the name of the communication network card used by the channel.
The routing table definition format is as follows:
“[conf]
ID=100000000
NAMESPACE=aaa
[0]
ID=200000000
NAMESPACE=bbb
SESSION=1
PROTOCOL=53274
DEV=ens33”。
Specifically, static routes are introduced through a routing table, each static route is set through a configuration file, each static route is composed of a name space, an ID initial value, a session number, a device name and a protocol number, wherein the name space is used for determining the name characteristic of a communication object on each CPU, the ID initial value is used for determining the ID number range of the communication object on each CPU, the session number is a unique identifier of each kcp communication channel, the device name is used for identifying network devices for communication between the CPUs, the protocol number is a custom protocol number of an original socket of a link layer, and all attributes of one CPU communication channel can be determined through the static routes through the information.
In this embodiment, in step S1, data needs to be encapsulated into a message with a specified format in the communication process, where the message is composed of data attributes and data, and there may be multiple data attributes in a message, and each message must be added with one data attribute of "communication object name" or "communication object ID", where the message format is as follows:
Message header Data attribute 1 Data 1 Data attribute 2 Data 2 Data attribute N Data N
In this embodiment, in step S2, the message is sent through an API interface, which assembles various parameters and data input by the user to generate the above-mentioned message format, and then sends the message to the ubusd process for processing through a UNIX domain socket.
After the objects to be communicated are defined as communication object names and methods, the data are formed into messages through an API interface module, wherein the communication object names are used as data of the attribute of the communication object names of the character string formed messages, then the messages are sent to a ubusd process, the ubusd process analyzes the messages to generate a communication object, the names of the communication object are recorded, an ID number is allocated to the object, and the range of the ID number is determined by the ID value of the local information in a routing table.
In this embodiment, in step S3, the ubusd process parses the message after receiving the message, and parses the data attribute of "communication object name" or "communication object ID" in the message:
if the attribute of the communication object name data is analyzed, the communication object name data is compared with the character string of the 'NAMESPACE' tag under the 'home information' in the routing table, if the character string started by the initial letter of the communication object name data is the same as the character string represented by the 'NAMESPACE', the message is indicated to be a message sent to the home CPU, the ubusd process searches the communication object name in the object management through the 'communication object name' data, if the names are the same, the message is indicated to be sent to the communication object, and then the message is forwarded to the object.
If the data attribute of the communication object ID is analyzed, the data of the communication object ID is compared with the numerical value of an ID label under the information of the local end in the routing table, if the numerical value of the data of the communication object ID is in the range of the ID, the message is indicated to be a message sent to the CPU of the local end, the ubusd process searches the communication object ID in the object management through the data of the communication object ID, if the IDs are the same, the message is indicated to be sent to the communication object, and then the message is forwarded to the object.
If the 'communication object name' and the 'communication object ID' are not found in the 'home terminal information', traversing all 'opposite terminal information', comparing by using the same method, and if the comparison is successful, indicating that the message is sent to another CPU, and sending the message through a corresponding kcp session. If the "communication object name" and the "communication object ID" are not found in both the "home information" and the "opposite information", the message is discarded.
Specifically, the process of traversing all opposite terminal information for comparison is as follows:
If the analyzed data attribute is communication object name data, comparing the communication object name data with a character string of a 'NAMESPACE' tag under opposite end information in a routing table, if the character string started by the initial letter of the communication object name data is the same as a character string represented by 'NAMESPACE', indicating that the message is sent to an opposite end CPU, searching a corresponding communication object name by a ubusd process through the communication object name data, if the names are the same, indicating that the message is sent to a communication object corresponding to the searched communication object name, and forwarding the message to the searched communication object;
If the analyzed data attribute is communication object ID data, the communication object ID data is compared with the numerical value of an ID label under opposite terminal information in the routing table, if the number of the communication object ID data is within the range of the ID label, the message is sent to an opposite terminal CPU, a ubusd process searches a corresponding communication object ID through the communication object ID data, if the IDs are the same, the message is sent to a communication object corresponding to the searched communication object ID, and then the message is forwarded to the searched communication object.
In this embodiment, if the "communication object name" and the "communication object ID" are not found in both the home terminal information and the opposite terminal information of the routing table, the message is discarded.
In this embodiment, step S4 is further included, for the message communicated in the local CPU, directly finding a UNIX domain socket of the communication object, and then sending the message to the corresponding communication object through a UNIX domain socket channel; for the message sent to the opposite terminal CPU, after finding the matching item in the routing table of the opposite terminal information, recording the index value, filling the ID of the sent data object into the head of the message to represent the message source, then obtaining the session of kcp through the index value of the matched opposite terminal information, and sending out the data through the session of kcp.
The protocol encapsulation layer is added, is an abstract layer of a specific protocol, realizes interfaces such as protocol creation, protocol initialization, protocol operation, sending and receiving functions and the like, and firstly creates a specific protocol after a program is started, then initializes the protocol and finally operates the protocol; adding a kcp protocol to realize an interface required by a protocol encapsulation layer, creating through a creation interface of the protocol encapsulation layer, initializing through an initialization interface of the protocol layer, creating a corresponding kcp session according to a routing table during initialization, and finally running through an operation function of the protocol encapsulation layer, checking whether data need to be forwarded from kcp or not through the operation function, and checking whether the kcp receives the data or not; when registering a communication object, checking whether the name of the communication object is under a local namespace, and simultaneously, allocating an ID number for the communication object to be in accordance with the range of the local ID number; before processing the message, checking the type or destination ID number of the message, distinguishing the destination of the message by using the name space and ID start value of the static route, carrying out local processing on the message which does not need to be forwarded across the CPU, inquiring the kcp session from the route information on the message which needs to be forwarded across the CPU, and then sending the message from the session; and marking the data received from the kcp with a kcp session label, sending the data to a local ubus process for processing, and sending the processed result data from the corresponding kcp session according to the kcp session label.
Auxiliary fig. 2, take CPU1 and CPU2 communication as an example:
When the process A needs to perform internal communication to send data to the process B, the process A sends a message to a ubusd process through an API interface, and after the ubusd process receives the message, the process forwards the message to the process B; when the process a needs to perform external communication to send data to the process D, the process a sends a message to the ubusd process through the API interface, after the ubusd process receives the message, the message is routed, the message is sent to the ubusd process through the kcp protocol, and after the ubusd process receives the message, the message is sent to the process D through object management.
In summary, the embodiment of the present invention encapsulates the parameters and data input by the user into the message in the predetermined format by using the API interface, where the message includes the data attribute and the data object, and the data attribute includes the "communication object name" or "communication object ID"; the message is sent to ubusd processes for processing through UNIX domain sockets; ubusd process parses the data attributes of the "communication object name" or "communication object ID" in the message: if the analyzed data attribute is communication object name data, comparing the communication object name data with a character string of a 'NAMESPACE' tag under the home terminal information in a routing table, if the character string started by the initial letter of the communication object name data is the same as the character string represented by 'NAMESPACE', indicating that the message is sent to a home terminal CPU, searching a corresponding communication object name by a ubusd process through the communication object name data, if the names are the same, indicating that the message is sent to a communication object corresponding to the searched communication object name, and forwarding the message to the searched communication object; if the analyzed data attribute is communication object ID data, the communication object ID data is compared with the numerical value of an ID label under the local end information in the routing table, if the number of the communication object ID data is within the range of the ID label, the message is sent to a local end CPU, a ubusd process searches a corresponding communication object ID through the communication object ID data, if the IDs are the same, the message is sent to a communication object corresponding to the searched communication object ID, and then the message is forwarded to the searched communication object; if the communication object name and the communication object ID are not found in the local information, traversing all opposite end information of the routing table for comparison, if the comparison is successful, indicating that the message is sent to another CPU, and sending the message through a corresponding kcp session. The invention can make the software support the communication among multiple CPUs by modifying the static route configuration file, and the service software modification and deployment does not need to modify codes; the kcp protocol is used for communication, so that the system protocol stack is not relied on, and the system security is improved; the bottom hardware architecture is shielded for the business software, and the business software is not affected by the change of the hardware structure.
It should be noted that the method of the embodiments of the present disclosure may be performed by a single device, such as a computer or a server. The method of the embodiment can also be applied to a distributed scene, and is completed by mutually matching a plurality of devices. In the case of such a distributed scenario, one of the devices may perform only one or more steps of the methods of embodiments of the present disclosure, the devices interacting with each other to accomplish the methods.
It should be noted that the foregoing describes some embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments described above and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
Example 2
Referring to fig. 3, embodiment 2 of the present invention provides a communication device implementing a multi-CPU architecture based on ubus frames, including:
a message assembling module 1, configured to package parameters and data input by a user into a message in a predetermined format by using an API interface, where the message includes a data attribute and a data object, and the data attribute includes a "communication object name" or a "communication object ID";
The message sending module 2 is used for sending the message to the ubusd process for processing through a UNIX domain socket;
a message parsing module 3, configured to parse the data attribute of the "communication object name" or "communication object ID" in the message by using the ubusd process;
the message parsing module 3 includes:
The local terminal character string comparison sub-module 31 is configured to compare the "communication object name" data with the character string of the "NAMESPACE" tag under the local terminal information in the routing table if the parsed data attribute is "communication object name" data, and if the character string started by the initial letter of the "communication object name" data is the same as the character string represented by "NAMESPACE", indicate that the message is sent to the local terminal CPU;
The first local communication object name searching sub-module 32 is configured to search for a corresponding communication object name by using "communication object name" data by using the ubusd process, if the names are the same, indicate that the message is sent to a communication object corresponding to the searched communication object name, and then forward the message to the searched communication object;
The local end numerical comparison sub-module 33 is configured to compare the "communication object ID" data with the numerical value of the "ID" tag under the local end information in the routing table if the parsed data attribute is the "communication object ID" data, and if the numerical value of the "communication object ID" data is within the range of the "ID" tag, indicate that the message is sent to the local end CPU;
A second local communication object name searching sub-module 34, configured to search for a corresponding communication object ID by using "communication object ID" data by using the ubusd process, if the IDs are the same, indicate that the message is sent to a communication object corresponding to the searched communication object ID, and then forward the message to the searched communication object;
and the opposite terminal processing module 4 is used for traversing all opposite terminal information of the routing table for comparison if the communication object name and the communication object ID are not found in the local terminal information, and sending the message out through a corresponding kcp session if the comparison is successful, which indicates that the message is sent to another CPU.
In this embodiment, the system further includes a routing table configuration module 5, configured to configure the routing table, where the routing table configuration includes local end information and opposite end information;
the local information is stored under the label of the 'conf';
At least one set of opposite terminal information is stored under the labels of "[0]", "[1]", and "[2]", and the value of the label represents the number of the route.
In this embodiment, the peer processing module 4 includes:
the opposite terminal character string comparison sub-module 41 compares the data of the "communication object name" with the character string of the "NAMESPACE" label under the opposite terminal information in the routing table if the analyzed data attribute is the "communication object name" data, and if the character string started by the initial letter of the "communication object name" data is the same as the character string represented by "NAMESPACE", the message is indicated to be sent to the opposite terminal CPU;
A first opposite-end communication object name searching sub-module 42, configured to search for a corresponding communication object name by using "communication object name" data by using the ubusd process, if the names are the same, indicate that the message is sent to a communication object corresponding to the searched communication object name, and then forward the message to the searched communication object;
The opposite terminal numerical value comparison sub-module 43 compares the numerical value of the "communication object ID" data with the numerical value of the "ID" tag under the opposite terminal information in the routing table if the analyzed data attribute is the "communication object ID" data, and indicates that the message is sent to the opposite terminal CPU if the numerical value of the "communication object ID" data is within the range of the "ID" tag;
The second peer communication object name searching sub-module 44, ubusd process searches the corresponding communication object ID through the "communication object ID" data, if the IDs are the same, indicates that the message is sent to the communication object corresponding to the searched communication object ID, and then forwards the message to the searched communication object.
In this embodiment, the device further includes a message discarding module 6, configured to discard the message if the "communication object name" and the "communication object ID" are not found in the local information and the opposite information of the routing table;
The first message forwarding module 7 is used for directly finding a UNIX domain socket of a communication object for the message communicated in the local CPU, and then sending the message to the corresponding communication object through a UNIX domain socket channel;
The second message forwarding module 8 is configured to record an index value after a matching item is found in a routing table of the opposite terminal information for a message sent to the opposite terminal CPU, fill an ID of a sending data object into a header of the message to indicate a message source, obtain a kcp session according to the index value of the matched opposite terminal information, and send data according to the kcp session.
It should be noted that, because the content of information interaction and execution process between the modules of the above-mentioned device is based on the same concept as the method embodiment in the embodiment 1 of the present application, the technical effects brought by the content are the same as the method embodiment of the present application, and the specific content can be referred to the description in the foregoing illustrated method embodiment of the present application, which is not repeated herein.
Example 3
Embodiment 3 of the present invention provides a non-transitory computer-readable storage medium having stored therein program code for implementing a communication method of a multi-CPU architecture based on a ubus framework, the program code including instructions for performing the communication method of embodiment 1 or any possible implementation thereof, based on a ubus framework.
Computer readable storage media can be any available media that can be accessed by a computer or data storage devices, such as servers, data centers, etc., that contain an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (Solid STATE DISK, SSD)), etc.
Example 4
Embodiment 4 of the present invention provides an electronic device, including: a memory and a processor;
The processor and the memory complete communication with each other through a bus; the memory stores program instructions executable by the processor to invoke the program instructions capable of performing the communication method of embodiment 1 or any possible implementation thereof implementing the multi-CPU architecture based on the ubus framework.
Specifically, the processor may be implemented by hardware or software, and when implemented by hardware, the processor may be a logic circuit, an integrated circuit, or the like; when implemented in software, the processor may be a general-purpose processor, implemented by reading software code stored in a memory, which may be integrated in the processor, or may reside outside the processor, and which may reside separately.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.).
It will be appreciated by those skilled in the art that the modules or steps of the invention described above may be implemented in a general purpose computing device, they may be concentrated on a single computing device, or distributed across a network of computing devices, they may alternatively be implemented in program code executable by computing devices, so that they may be stored in a memory device for execution by computing devices, and in some cases, the steps shown or described may be performed in a different order than that shown or described, or they may be separately fabricated into individual integrated circuit modules, or multiple modules or steps within them may be fabricated into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
While the invention has been described in detail in the foregoing general description and specific examples, it will be apparent to those skilled in the art that modifications and improvements can be made thereto. Accordingly, such modifications or improvements may be made without departing from the spirit of the invention and are intended to be within the scope of the invention as claimed.

Claims (8)

1. The communication method for realizing the multi-CPU architecture based on ubus framework is characterized by comprising the following steps:
encapsulating parameters and data input by a user into a message in a preset format by using an API interface, wherein the message comprises data attributes and data objects, and the data attributes comprise a communication object name or a communication object ID;
the message is sent to ubusd processes for processing through UNIX domain sockets;
ubusd process parses the data attributes of the "communication object name" or "communication object ID" in the message:
If the analyzed data attribute is communication object name data, comparing the communication object name data with a character string of a 'NAMESPACE' tag under the home terminal information in a routing table, if the character string started by the initial letter of the communication object name data is the same as the character string represented by 'NAMESPACE', indicating that the message is sent to a home terminal CPU, searching a corresponding communication object name by a ubusd process through the communication object name data, if the names are the same, indicating that the message is sent to a communication object corresponding to the searched communication object name, and forwarding the message to the searched communication object; for the message communicated in the CPU of the local terminal, a UNIX domain socket of a communication object is directly found, and then the message is sent to the corresponding communication object through a UNIX domain socket channel;
If the analyzed data attribute is communication object ID data, the communication object ID data is compared with the numerical value of an ID label under the local end information in the routing table, if the number of the communication object ID data is within the range of the ID label, the message is sent to a local end CPU, a ubusd process searches a corresponding communication object ID through the communication object ID data, if the IDs are the same, the message is sent to a communication object corresponding to the searched communication object ID, and then the message is forwarded to the searched communication object;
If the communication object name and the communication object ID are not found in the local information, traversing all opposite end information of the routing table for comparison, if the comparison is successful, indicating that the message is sent to another CPU, and sending the message through a corresponding kcp session; for the message sent to the opposite terminal CPU, after finding the matching item in the routing table of the opposite terminal information, recording the index value, filling the ID of the sent data object into the head of the message to represent the message source, then obtaining the session of kcp through the index value of the matched opposite terminal information, and sending out the data through the session of kcp.
2. The method for implementing a multi-CPU architecture based on ubus framework of claim 1, further comprising configuring the routing table, the routing table configuration including home information and peer information;
the local information is stored under the label of the 'conf';
At least one set of opposite terminal information is stored under the labels of "[0]", "[1]", and "[2]", and the value of the label represents the number of the route.
3. The method for implementing a multi-CPU architecture based on ubus framework according to claim 1, wherein the process of traversing all peer information for comparison is:
If the analyzed data attribute is communication object name data, comparing the communication object name data with a character string of a 'NAMESPACE' tag under opposite end information in a routing table, if the character string started by the initial letter of the communication object name data is the same as a character string represented by 'NAMESPACE', indicating that the message is sent to an opposite end CPU, searching a corresponding communication object name by a ubusd process through the communication object name data, if the names are the same, indicating that the message is sent to a communication object corresponding to the searched communication object name, and forwarding the message to the searched communication object;
If the analyzed data attribute is communication object ID data, the communication object ID data is compared with the numerical value of an ID label under opposite terminal information in the routing table, if the number of the communication object ID data is within the range of the ID label, the message is sent to an opposite terminal CPU, a ubusd process searches a corresponding communication object ID through the communication object ID data, if the IDs are the same, the message is sent to a communication object corresponding to the searched communication object ID, and then the message is forwarded to the searched communication object.
4. The communication method based on the ubus framework for implementing a multi-CPU architecture according to claim 1, wherein if "communication object name" and "communication object ID" are not found in both the home information and the peer information of the routing table, the message is discarded.
5. A communications apparatus that implements a multi-CPU architecture based on ubus framework, comprising:
A message assembly module, configured to encapsulate parameters and data entered by a user into a message in a predetermined format using an API interface, where the message includes a data attribute and a data object, and the data attribute includes a "communication object name" or a "communication object ID";
the message sending module is used for sending the message to the ubusd process for processing through the UNIX domain socket;
The message analysis module is used for analyzing the data attribute of the communication object name or the communication object ID in the message by ubusd processes;
the message parsing module includes:
The local terminal character string comparison sub-module is used for comparing the 'communication object name' data with the character string of the 'NAMESPACE' tag under the local terminal information in the routing table if the analyzed data attribute is the 'communication object name' data, and if the character string started by the initial letter of the 'communication object name' data is the same as the character string represented by 'NAMESPACE', the message is indicated to be sent to the local terminal CPU;
The first local communication object name searching sub-module is used for searching the corresponding communication object name through the data of the communication object name by ubusd processes, if the names are the same, the message is indicated to be sent to the communication object corresponding to the searched communication object name, and then the message is forwarded to the searched communication object;
The local end numerical value comparison sub-module is used for comparing the numerical value of the communication object ID data with the numerical value of the ID label under the local end information in the routing table if the analyzed data attribute is the communication object ID data, and indicating that the message is sent to the local end CPU if the numerical value of the communication object ID data is within the range of the ID label;
A second local communication object name searching sub-module, configured to search for a corresponding communication object ID by using "communication object ID" data by using the ubusd process, if the IDs are the same, indicate that the message is sent to a communication object corresponding to the searched communication object ID, and then forward the message to the searched communication object;
The opposite terminal processing module is used for traversing all opposite terminal information of the routing table for comparison if the communication object name and the communication object ID are not found in the local terminal information, and sending the message out through a corresponding kcp session if the comparison is successful, which means that the message is sent to another CPU;
The first message forwarding module is used for directly finding a UNIX domain socket of a communication object for the message communicated in the CPU of the local terminal, and then sending the message to the corresponding communication object through a UNIX domain socket channel;
The second message forwarding module is used for searching a matching item in a routing table of opposite terminal information for a message sent to the opposite terminal CPU, recording an index value, filling an ID of a sent data object into a header of the message to represent a message source, acquiring a kcp session through the index value of the matched opposite terminal information, and sending out data through the kcp session.
6. The ubus-framework-based communication device implementing a multi-CPU architecture according to claim 5, further comprising a routing table configuration module configured to configure the routing table, the routing table configuration including home information and peer information;
the local information is stored under the label of the 'conf';
At least one set of opposite terminal information is stored under the labels of "[0]", "[1]", and "[2]", and the value of the label represents the number of the route.
7. The ubus-framework-based communication device implementing a multi-CPU architecture of claim 5, wherein the peer processing module includes:
The opposite terminal character string comparison sub-module compares the data of the communication object name with the character string of the NAMESPACE label under the opposite terminal information in the routing table if the analyzed data attribute is the data of the communication object name, and indicates that the message is sent to the opposite terminal CPU if the character string started by the initial letter of the data of the communication object name is the same as the character string represented by NAMESPACE;
The first opposite-end communication object name searching sub-module is used for searching the corresponding communication object name through the data of the communication object name by ubusd processes, if the names are the same, the message is indicated to be sent to the communication object corresponding to the searched communication object name, and then the message is forwarded to the searched communication object;
the opposite terminal numerical value comparison sub-module compares the numerical value of the communication object ID data with the numerical value of an ID label under opposite terminal information in the routing table if the analyzed data attribute is the communication object ID data, and indicates that the message is sent to an opposite terminal CPU if the numerical value of the communication object ID data is within the range of the ID label;
And the second opposite-end communication object name searching sub-module ubusd processes search the corresponding communication object ID through the communication object ID data, if the IDs are the same, the message is indicated to be sent to the communication object corresponding to the searched communication object ID, and then the message is forwarded to the searched communication object.
8. The communication apparatus implementing a multi-CPU architecture based on the ubus framework, further comprising a message discard module configured to discard the message if the "communication object name" and the "communication object ID" are not found in both the home information and the peer information of the routing table.
CN202311051537.6A 2023-08-18 2023-08-18 Communication method and device for realizing multi-CPU architecture based on ubus framework Active CN117093533B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311051537.6A CN117093533B (en) 2023-08-18 2023-08-18 Communication method and device for realizing multi-CPU architecture based on ubus framework

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311051537.6A CN117093533B (en) 2023-08-18 2023-08-18 Communication method and device for realizing multi-CPU architecture based on ubus framework

Publications (2)

Publication Number Publication Date
CN117093533A CN117093533A (en) 2023-11-21
CN117093533B true CN117093533B (en) 2024-05-07

Family

ID=88774760

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311051537.6A Active CN117093533B (en) 2023-08-18 2023-08-18 Communication method and device for realizing multi-CPU architecture based on ubus framework

Country Status (1)

Country Link
CN (1) CN117093533B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6134676A (en) * 1998-04-30 2000-10-17 International Business Machines Corporation Programmable hardware event monitoring method
CN104317661A (en) * 2014-11-04 2015-01-28 上海斐讯数据通信技术有限公司 Intersystem communication method and device of dual embedded systems
CN110018911A (en) * 2018-01-09 2019-07-16 阿里巴巴集团控股有限公司 Management of process and inter-process communication methods, calculate equipment and storage medium at device
CN110166361A (en) * 2019-05-30 2019-08-23 新华三技术有限公司 A kind of message forwarding method and device
CN114928660A (en) * 2022-05-16 2022-08-19 北京计算机技术及应用研究所 Method for transparent interprocess communication of embedded operating system
CN115827266A (en) * 2022-11-07 2023-03-21 深圳市中网信安技术有限公司 Method and system for message forwarding framework in multi-CPU system heterogeneous computer system
CN115955444A (en) * 2022-12-16 2023-04-11 深信服科技股份有限公司 Multiplexing method, device, equipment and storage medium based on virtual serial port

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6134676A (en) * 1998-04-30 2000-10-17 International Business Machines Corporation Programmable hardware event monitoring method
CN104317661A (en) * 2014-11-04 2015-01-28 上海斐讯数据通信技术有限公司 Intersystem communication method and device of dual embedded systems
CN110018911A (en) * 2018-01-09 2019-07-16 阿里巴巴集团控股有限公司 Management of process and inter-process communication methods, calculate equipment and storage medium at device
CN110166361A (en) * 2019-05-30 2019-08-23 新华三技术有限公司 A kind of message forwarding method and device
CN114928660A (en) * 2022-05-16 2022-08-19 北京计算机技术及应用研究所 Method for transparent interprocess communication of embedded operating system
CN115827266A (en) * 2022-11-07 2023-03-21 深圳市中网信安技术有限公司 Method and system for message forwarding framework in multi-CPU system heterogeneous computer system
CN115955444A (en) * 2022-12-16 2023-04-11 深信服科技股份有限公司 Multiplexing method, device, equipment and storage medium based on virtual serial port

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于TR069协议的终端设备管理研究;陈泽宇;《中国优秀博硕士学位论文全文数据库(硕士)信息科技辑》;第2022年卷(第12期);全文 *
开放系统桌面进程通信机制研究;陈华清;吴键;;计算机应用研究(第10期);全文 *

Also Published As

Publication number Publication date
CN117093533A (en) 2023-11-21

Similar Documents

Publication Publication Date Title
CN109639572B (en) Route management method and device and micro-service system
CN106656650B (en) Method and system for generating service test environment, and method, device and system for service test
JP4509916B2 (en) SNMP-based network management apparatus and method
US20120137276A1 (en) Processing of expressions
WO2019185051A1 (en) Integrated flow table-based packet forwarding method and device
CN113010378B (en) Log processing method and device of microservice module, storage medium and electronic device
CN111294235A (en) Data processing method, device, gateway and readable storage medium
CN113360301B (en) Message transmission system and method
US11768759B2 (en) Method and system for automated testing of web service APIs
CN116634046A (en) Message processing method and device, electronic equipment and storage medium
CN112988409A (en) Interface calling method and device, computer equipment and storage medium
CN117093533B (en) Communication method and device for realizing multi-CPU architecture based on ubus framework
CN111064729B (en) Message processing method and device, storage medium and electronic device
US9577669B2 (en) Methods, systems, and computer readable media for optimized message decoding
CN108259350B (en) Message transmission method and device and machine-readable storage medium
CN112769863B (en) Method and device for processing service request message data, electronic equipment and readable storage medium
CN114301993A (en) Data transmission method, device, terminal equipment and storage medium
US11804986B2 (en) Method for the remote management of a device connected to a residential gateway
JP2996296B2 (en) Message decoding device and finite state machine generating device
CN111107536B (en) User plane function forwarding method, device, system and storage medium
CN113825166B (en) Base station testing method and device, electronic equipment and storage medium
CN114448691B (en) Data forwarding method, data plane and switch
CN115118765B (en) Service processing method, device, electronic equipment and storage medium
CN115567485A (en) Domain name resolution method and device, electronic equipment and storage medium
CN112764826A (en) tuxedo resource batch processing method, system, equipment and medium

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