CN117880347A - OpenWrt router wired user flow obtaining method and system - Google Patents
OpenWrt router wired user flow obtaining method and system Download PDFInfo
- Publication number
- CN117880347A CN117880347A CN202311646018.4A CN202311646018A CN117880347A CN 117880347 A CN117880347 A CN 117880347A CN 202311646018 A CN202311646018 A CN 202311646018A CN 117880347 A CN117880347 A CN 117880347A
- Authority
- CN
- China
- Prior art keywords
- cloud server
- moquitto
- connection
- openwrt router
- openwrt
- 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.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/2866—Architectures; Arrangements
- H04L67/30—Profiles
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/12—Network monitoring probes
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/133—Protocols for remote procedure calls [RPC]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/143—Termination or inactivation of sessions, e.g. event-controlled end of session
- H04L67/145—Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/50—Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Health & Medical Sciences (AREA)
- Cardiology (AREA)
- General Health & Medical Sciences (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention provides a method and a system for obtaining wired user flow of an OpenWrt router, which belongs to the technical field of OpenWrt router management, wherein the method comprises the following steps: step S1, an OpenWrt router creates a configuration file at least comprising a cloud server address, a cloud server port and an encryption mode; step S2, the OpenWrt router establishes connection with the cloud server based on the configuration file, and starts an MQTT process, and the MQTT process issues a successful notification of the cloud server connection; step S3, the OpenWrt router monitors a successful connection notice of the cloud server to acquire a connection state of the cloud server; s4, the OpenWrt router obtains the wired user flow through a swconfig command based on the connection state; and S5, after the OpenWrt router packages the wired user traffic into a JSON format, invoking a ubus interface of the MQTT process to upload the wired user traffic to the cloud server, and receiving and displaying the wired user traffic by the cloud server. The invention has the advantages that: the method and the system realize the acquisition of the wired user traffic of the OpenWrt router, and greatly improve the management reliability of the OpenWrt router.
Description
Technical Field
The invention relates to the technical field of OpenWrt router management, in particular to a method and a system for obtaining wired user flow of an OpenWrt router.
Background
Most of the current OpenWrt routers acquire user information through a CWMP protocol, the CWMP protocol acquires the user information based on a data model, the TR098 and TR181 data models of the CWMP protocol only acquire information such as user IP and MAC, but can not acquire wired user traffic, the wired user traffic is important information, and the loss of the wired user traffic affects the reliability of the OpenWrt router management.
Therefore, how to provide a method and a system for obtaining the wired user traffic of the OpenWrt router, so as to achieve obtaining the wired user traffic of the OpenWrt router, so as to improve the management reliability of the OpenWrt router, becomes a technical problem to be solved urgently.
Disclosure of Invention
The invention aims to solve the technical problem of providing a method and a system for acquiring wired user traffic of an OpenWrt router, which are used for acquiring the wired user traffic of the OpenWrt router so as to improve the management reliability of the OpenWrt router.
In a first aspect, the present invention provides a method for obtaining wired user traffic of an OpenWrt router, including the following steps:
step S1, an OpenWrt router creates a configuration file at least comprising a cloud server address, a cloud server port and an encryption mode;
s2, establishing connection between the OpenWrt router and the cloud server based on the configuration file, and starting an MQTT process, wherein the MQTT process issues a successful notification of the cloud server connection;
step S3, the OpenWrt router monitors the successful connection notification of the cloud server to acquire the connection state of the cloud server;
step S4, the OpenWrt router obtains the wired user flow through a swconfig command based on the connection state;
and S5, packaging the wired user traffic into a JSON format by using an OpenWrt router, calling a ubus interface of the MQTT process, uploading the packaged wired user traffic to a cloud server, and receiving and displaying the wired user traffic by the cloud server.
Further, the step S1 further includes:
and encrypting the configuration file by using a cryptographic algorithm, and storing the configuration file in a designated path.
Further, the step S2 specifically includes:
the OpenWrt router establishes connection with the cloud server based on the cloud server address, the cloud server port and the encryption mode carried by the configuration file, and pings the cloud server through the OpenWrt router to verify the connection;
the OpenWrt router calls a moquitto_lib_init function initialization library of the moquitto library, calls a moquitto_new function of the moquitto library to create a moquitto object, calls a moquitto_message_callback_set function of the moquitto library to create a Broker message processing callback function, calls a moquitto_tls_set function of the moquitto library to start tls authentication, calls a moquitto_connect function of the moquitto library to connect with a Broker, and calls a moquitto_loop_forever function of the moquitto library to keep long connection after the Broker connection is successful, so as to start an MQTT process, and the MQTT process issues a cloud server connection success notification.
Further, the step S3 specifically includes:
the OpenWrt router calls a ubus_register_event_handler function through a c language interface provided by a ubus interface of the MQTT process to monitor the connection success notification of the cloud server, and acquires the connection state of the cloud server based on a status field in the connection success notification of the cloud server; the connection state is connection success or connection failure.
Further, in the step S4, the wired user traffic includes a receiving traffic and a transmitting traffic.
In a second aspect, the present invention provides an OpenWrt router wired user traffic acquisition system, including the following modules:
the configuration file creation module is used for creating a configuration file at least comprising a cloud server address, a cloud server port and an encryption mode by the OpenWrt router;
the MQTT process starting module is used for establishing connection between the OpenWrt router and the cloud server based on the configuration file and starting the MQTT process, and the MQTT process issues a successful connection notice of the cloud server;
the connection state acquisition module is used for monitoring the successful connection notification of the cloud server by the OpenWrt router so as to acquire the connection state of the cloud server;
the wired user flow acquisition module is used for acquiring wired user flow through a swconfig command by the OpenWrt router based on the connection state;
and the wired user flow uploading module is used for calling a ubus interface of the MQTT process to upload to a cloud server after the OpenWrt router packages the wired user flow into a JSON format, and the cloud server receives and displays the wired user flow.
Further, the configuration file creation module is further configured to:
and encrypting the configuration file by using a cryptographic algorithm, and storing the configuration file in a designated path.
Further, the MQTT process starting module is specifically configured to:
the OpenWrt router establishes connection with the cloud server based on the cloud server address, the cloud server port and the encryption mode carried by the configuration file, and pings the cloud server through the OpenWrt router to verify the connection;
the OpenWrt router calls a moquitto_lib_init function initialization library of the moquitto library, calls a moquitto_new function of the moquitto library to create a moquitto object, calls a moquitto_message_callback_set function of the moquitto library to create a Broker message processing callback function, calls a moquitto_tls_set function of the moquitto library to start tls authentication, calls a moquitto_connect function of the moquitto library to connect with a Broker, and calls a moquitto_loop_forever function of the moquitto library to keep long connection after the Broker connection is successful, so as to start an MQTT process, and the MQTT process issues a cloud server connection success notification.
Further, the connection state acquisition module is specifically configured to:
the OpenWrt router calls a ubus_register_event_handler function through a c language interface provided by a ubus interface of the MQTT process to monitor the connection success notification of the cloud server, and acquires the connection state of the cloud server based on a status field in the connection success notification of the cloud server; the connection state is connection success or connection failure.
Further, in the wired user traffic obtaining module, the wired user traffic includes a receiving traffic and a sending traffic.
The invention has the advantages that:
1. creating a configuration file comprising a cloud server address, a cloud server port and an encryption mode through an OpenWrt router, establishing connection with a cloud server based on the configuration file, starting an MQTT process, and releasing a cloud server connection success notice by the MQTT process; the OpenWrt router monitors a successful connection notice of the cloud server to acquire a connection state of the cloud server, acquires wired user traffic comprising received traffic and sent traffic through swconfig commands based on the connection state, packages the wired user traffic into a JSON format, and then invokes a ubus interface of an MQTT process to upload to the cloud server for display; the swconfig command is an OpenWrt official configuration tool, and can be used for configuring and acquiring various parameters of the OpenWrt router, so that the wired user traffic of the OpenWrt router is acquired, and the management reliability of the OpenWrt router is greatly improved.
2. The cloud server acquires the wired user flow of the OpenWrt router through the MQTT protocol, replaces the traditional CWMP protocol, reduces occupied message space due to smaller message of the MQTT protocol, and has high data receiving and transmitting efficiency and low data receiving and transmitting power consumption; the MQTT protocol can reconstruct and simplify the service flow, thereby reducing unnecessary functions and mechanisms; the MQTT protocol is a long connection protocol, so that interaction information is reduced, a STUN keep-alive channel is not required to be maintained, a QoS mechanism is provided, different message quality grades can be set according to different use scenes, overhead of OpenWrt router management is reduced finally, and reliability and flexibility of OpenWrt router management are improved greatly.
Drawings
The invention will be further described with reference to examples of embodiments with reference to the accompanying drawings.
Fig. 1 is a flowchart of an OpenWrt router wired user traffic acquisition method of the present invention.
Fig. 2 is a schematic structural diagram of an OpenWrt router wired subscriber flow acquisition system according to the present invention.
Detailed Description
According to the technical scheme in the embodiment of the application, the overall thought is as follows: the swconfig command is an OpenWrt official configuration tool, and can be used for configuring and acquiring various parameters of an OpenWrt router, so that the acquisition of the wired user traffic of the OpenWrt router is realized, and the management reliability of the OpenWrt router is improved.
Referring to fig. 1 to 2, a preferred embodiment of a method for obtaining wired user traffic of an OpenWrt router according to the present invention includes the following steps:
step S1, an OpenWrt router creates a configuration file at least comprising a cloud server address, a cloud server port and an encryption mode;
the OpenWrt is an embedded operating system based on Linux, is an operating system specially designed for intelligent routers and network equipment, adopts a modularized design concept, and can easily customize and expand functions of the routers; the core of OpenWrt is a cut Linux kernel, rich network functions are provided by adding software packages and plug-ins, the application is a third-party router firmware, the OpenWrt has openness, a user can install needed third-party software on a router, and compared with the traditional router, the OpenWRT provides more powerful, flexible and intelligent functions;
s2, establishing connection between the OpenWrt router and the cloud server based on the configuration file, and starting an MQTT process, wherein the MQTT process issues a successful notification of the cloud server connection;
the MQTT process is a main channel for interaction between the OpenWrt router and the cloud server, and the wired user traffic is sent to the cloud server through the MQTT process;
the MQTT protocol (Message Queuing Telemetry Transport, message queue telemetry transport) is a lightweight communication protocol based on a Publish/subscribe (Purchase/subscribe) mode under the ISO standard (ISO/IEC PRF 20922), works on the TCP/IP protocol family, and is a Publish/subscribe message protocol designed for remote devices with low hardware performance and under the condition of poor network conditions; the MQTT protocol has the greatest advantage of providing real-time reliable message service for remote equipment with few codes and limited bandwidth; the MQTT protocol is used as an instant communication protocol with low cost and low bandwidth occupation, and has wide application in the aspects of the Internet of things, small-sized equipment, mobile application and the like;
step S3, the OpenWrt router monitors the successful connection notification of the cloud server to acquire the connection state of the cloud server;
step S4, the OpenWrt router obtains the wired user flow through a swconfig command based on the connection state;
and S5, packaging the wired user traffic into a JSON format by using an OpenWrt router, calling a ubus interface of the MQTT process, uploading the packaged wired user traffic to a cloud server, and receiving and displaying the wired user traffic by the cloud server.
The wired user traffic in JSON format is exemplified by:
{“ip”:”xxx”,”mac”:”xxx”,”type”:”wired”,”rx”:”xxx”,”tx”:”xxx”}
ip: ip assigned by the wired user;
mac: mac of the wired subscriber;
type: indicating that the current user is a wired user;
rx: the received total flow;
tx: total traffic sent.
The uploading of the wired user traffic to the cloud server is exemplified by:
ubus call mqtt data_notify'{"user":"sta_flow","id":"01","ts":xxx,"data":{xxx}}'
user: a service module name;
id: a service module code number;
ts: a current timestamp;
data: data to be sent to the cloud server, JSON format.
The cloud server is used for remotely managing the OpenWrt router, the cloud server provides a WEB front end accessed by a user and can access through a browser, the cloud server and the OpenWrt router can interact through various protocols, CWMP, COAP, MQTT and the like, and the invention obtains wired user traffic based on the MQTT protocol.
The step S1 further includes:
and encrypting the configuration file by using a cryptographic algorithm, and storing the configuration file in a designated path.
The step S2 specifically comprises the following steps:
the OpenWrt router establishes connection with the cloud server based on the cloud server address, the cloud server port and the encryption mode carried by the configuration file, and pings the cloud server through the OpenWrt router to verify the connection;
the OpenWrt router calls a moquitto_lib_init function initialization library of the moquitto library, calls a moquitto_new function of the moquitto library to create a moquitto object, calls a moquitto_message_callback_set function of the moquitto library to create a Broker message processing callback function, calls a moquitto_tls_set function of the moquitto library to start tls authentication, calls a moquitto_connect function of the moquitto library to connect with a Broker, and calls a moquitto_loop_forever function of the moquitto library to keep long connection after the Broker connection is successful, so as to start an MQTT process, and the MQTT process issues a cloud server connection success notification.
The Broker message processing callback function is responsible for triggering the CWMP to actively initiate a request to the ACS; topics may be subscribed to each other after connecting the Broker.
The cloud server connection success notification is exemplified by: ubus-t 3send cloud_server '{ "status": "connected" } "'
The step S3 specifically comprises the following steps:
the OpenWrt router calls a ubus_register_event_handler function through a c language interface provided by a ubus interface of the MQTT process to monitor the connection success notification of the cloud server, and acquires the connection state of the cloud server based on a status field in the connection success notification of the cloud server; the connection state is connection success or connection failure, and when the value of the status field is connected, the connection state is connection success.
g_closed_connect_event is the processing function of the cloud server connection success notification.
An interface: ubus_register_event_handler (g_ubus_ctx, & g_closed_connected_t_event, "closed_server")
In the step S4, the wired user traffic includes a received traffic and a transmitted traffic.
Acquiring a command of receiving traffic: swconfig dev switch0 port x get mix |grep RxByte|awk ' { print $3} ' '
Acquiring a command for sending traffic: swconfig dev switch0 port x get mix |grep TxByte|awk ' { print $3} ' '
X in the command is the wired user interface number.
The preferred embodiment of the invention relates to a wired user flow acquisition system of an OpenWrt router, which comprises the following modules:
the configuration file creation module is used for creating a configuration file at least comprising a cloud server address, a cloud server port and an encryption mode by the OpenWrt router;
OpenWrt is an embedded operating system based on Liux, is an operating system specially designed for intelligent routers and network equipment, adopts a modularized design concept, and can easily customize and expand functions of the routers; the core of OpenWrt is a cut Linux kernel, rich network functions are provided by adding software packages and plug-ins, the application is a third-party router firmware, the OpenWrt has openness, a user can install needed third-party software on a router, and compared with the traditional router, the OpenWRT provides more powerful, flexible and intelligent functions;
the MQTT process starting module is used for establishing connection between the OpenWrt router and the cloud server based on the configuration file and starting the MQTT process, and the MQTT process issues a successful connection notice of the cloud server;
the MQTT process is a main channel for interaction between the OpenWrt router and the cloud server, and the wired user traffic is sent to the cloud server through the MQTT process;
the MQTT protocol (Message Queuing Telemetry Transport, message queue telemetry transport) is a lightweight communication protocol based on a Publish/subscribe (Purchase/subscribe) mode under the ISO standard (ISO/IEC PRF 20922), works on the TCP/IP protocol family, and is a Publish/subscribe message protocol designed for remote devices with low hardware performance and under the condition of poor network conditions; the MQTT protocol has the greatest advantage of providing real-time reliable message service for remote equipment with few codes and limited bandwidth; the MQTT protocol is used as an instant communication protocol with low cost and low bandwidth occupation, and has wide application in the aspects of the Internet of things, small-sized equipment, mobile application and the like;
the connection state acquisition module is used for monitoring the successful connection notification of the cloud server by the OpenWrt router so as to acquire the connection state of the cloud server;
the wired user flow acquisition module is used for acquiring wired user flow through a swconfig command by the OpenWrt router based on the connection state;
and the wired user flow uploading module is used for calling a ubus interface of the MQTT process to upload to a cloud server after the OpenWrt router packages the wired user flow into a JSON format, and the cloud server receives and displays the wired user flow.
The wired user traffic in JSON format is exemplified by:
{“ip”:”xxx”,”mac”:”xxx”,”type”:”wired”,”rx”:”xxx”,”tx”:”xxx”}
ip: ip assigned by the wired user;
mac: mac of the wired subscriber;
type: indicating that the current user is a wired user;
rx: the received total flow;
tx: total traffic sent.
The uploading of the wired user traffic to the cloud server is exemplified by:
ubuscallmqttdata_notify'{"user":"sta_flow","id":"01","ts":xxx,"data":{xxx}}'
user: a service module name;
id: a service module code number;
ts: a current timestamp;
data: data to be sent to the cloud server, JSON format.
The cloud server is used for remotely managing the OpenWrt router, the cloud server provides a WEB front end accessed by a user and can access through a browser, the cloud server and the OpenWrt router can interact through various protocols, CWMP, COAP, MQTT and the like, and the invention obtains wired user traffic based on the MQTT protocol.
The profile creation module is further configured to:
and encrypting the configuration file by using a cryptographic algorithm, and storing the configuration file in a designated path.
The MQTT process starting module is specifically used for:
the OpenWrt router establishes connection with the cloud server based on the cloud server address, the cloud server port and the encryption mode carried by the configuration file, and pings the cloud server through the OpenWrt router to verify the connection;
the OpenWrt router calls a moquitto_lib_init function initialization library of the moquitto library, calls a moquitto_new function of the moquitto library to create a moquitto object, calls a moquitto_message_callback_set function of the moquitto library to create a Broker message processing callback function, calls a moquitto_tls_set function of the moquitto library to start tls authentication, calls a moquitto_connect function of the moquitto library to connect with a Broker, and calls a moquitto_loop_forever function of the moquitto library to keep long connection after the Broker connection is successful, so as to start an MQTT process, and the MQTT process issues a cloud server connection success notification.
The Broker message processing callback function is responsible for triggering the CWMP to actively initiate a request to the ACS; topics may be subscribed to each other after connecting the Broker.
The cloud server connection success notification is exemplified by: ubus-t 3send cloud_server '{ "status": "connected" } "'
The connection state acquisition module is specifically configured to:
the OpenWrt router calls a ubus_register_event_handler function through a c language interface provided by a ubus interface of the MQTT process to monitor the connection success notification of the cloud server, and acquires the connection state of the cloud server based on a status field in the connection success notification of the cloud server; the connection state is connection success or connection failure, and when the value of the status field is connected, the connection state is connection success.
g_closed_connect_event is the processing function of the cloud server connection success notification.
An interface: ubus_register_event_handler (g_ubus_ctx, & g_closed_connected_t_event, "closed_server")
In the wired user flow obtaining module, the wired user flow includes a receiving flow and a sending flow.
Acquiring a command of receiving traffic: swconfig dev switch0 port x get mix |grep RxByte|awk ' { print $3} ' '
Acquiring a command for sending traffic: swconfig dev switch0 port x get mix |grep TxByte|awk ' { print $3} ' '
X in the command is the wired user interface number.
In summary, the invention has the advantages that:
1. creating a configuration file comprising a cloud server address, a cloud server port and an encryption mode through an OpenWrt router, establishing connection with a cloud server based on the configuration file, starting an MQTT process, and releasing a cloud server connection success notice by the MQTT process; the OpenWrt router monitors a successful connection notice of the cloud server to acquire a connection state of the cloud server, acquires wired user traffic comprising received traffic and sent traffic through swconfig commands based on the connection state, packages the wired user traffic into a JSON format, and then invokes a ubus interface of an MQTT process to upload to the cloud server for display; the swconfig command is an OpenWrt official configuration tool, and can be used for configuring and acquiring various parameters of the OpenWrt router, so that the wired user traffic of the OpenWrt router is acquired, and the management reliability of the OpenWrt router is greatly improved.
2. The cloud server acquires the wired user flow of the OpenWrt router through the MQTT protocol, replaces the traditional CWMP protocol, reduces occupied message space due to smaller message of the MQTT protocol, and has high data receiving and transmitting efficiency and low data receiving and transmitting power consumption; the MQTT protocol can reconstruct and simplify the service flow, thereby reducing unnecessary functions and mechanisms; the MQTT protocol is a long connection protocol, so that interaction information is reduced, a STUN keep-alive channel is not required to be maintained, a QoS mechanism is provided, different message quality grades can be set according to different use scenes, overhead of OpenWrt router management is reduced finally, and reliability and flexibility of OpenWrt router management are improved greatly.
While specific embodiments of the invention have been described above, it will be appreciated by those skilled in the art that the specific embodiments described are illustrative only and not intended to limit the scope of the invention, and that equivalent modifications and variations of the invention in light of the spirit of the invention will be covered by the claims of the present invention.
Claims (10)
1. A wired user flow obtaining method of an OpenWrt router is characterized in that: the method comprises the following steps:
step S1, an OpenWrt router creates a configuration file at least comprising a cloud server address, a cloud server port and an encryption mode;
s2, establishing connection between the OpenWrt router and the cloud server based on the configuration file, and starting an MQTT process, wherein the MQTT process issues a successful notification of the cloud server connection;
step S3, the OpenWrt router monitors the successful connection notification of the cloud server to acquire the connection state of the cloud server;
step S4, the OpenWrt router obtains the wired user flow through a swconfig command based on the connection state;
and S5, packaging the wired user traffic into a JSON format by using an OpenWrt router, calling a ubus interface of the MQTT process, uploading the packaged wired user traffic to a cloud server, and receiving and displaying the wired user traffic by the cloud server.
2. The OpenWrt router wired user traffic acquisition method of claim 1, wherein: the step S1 further includes:
and encrypting the configuration file by using a cryptographic algorithm, and storing the configuration file in a designated path.
3. The OpenWrt router wired user traffic acquisition method of claim 1, wherein: the step S2 specifically comprises the following steps:
the OpenWrt router establishes connection with the cloud server based on the cloud server address, the cloud server port and the encryption mode carried by the configuration file, and pings the cloud server through the OpenWrt router to verify the connection;
the OpenWrt router calls a moquitto_lib_init function initialization library of the moquitto library, calls a moquitto_new function of the moquitto library to create a moquitto object, calls a moquitto_message_cal lback_set function of the moquitto library to create a Broker message processing callback function, calls a moquitto_tls_set function of the moquitto library to start tls authentication, calls a moquitto_connect function of the moquitto library to connect with a Broker, and calls a moquitto_loop_forever function of the moquitto library to keep long connection after the Broker connection is successful so as to start an MQTT process, and the MQTT process issues a cloud server connection success notification.
4. The OpenWrt router wired user traffic acquisition method of claim 1, wherein: the step S3 specifically comprises the following steps:
the OpenWrt router calls a ubus_register_event_handler function through a c language interface provided by a ubus interface of the MQTT process to monitor the connection success notification of the cloud server, and acquires the connection state of the cloud server based on a status field in the connection success notification of the cloud server; the connection state is connection success or connection failure.
5. The OpenWrt router wired user traffic acquisition method of claim 1, wherein: in the step S4, the wired user traffic includes a received traffic and a transmitted traffic.
6. An OpenWrt router wired user flow acquisition system, which is characterized in that: the device comprises the following modules:
the configuration file creation module is used for creating a configuration file at least comprising a cloud server address, a cloud server port and an encryption mode by the OpenWrt router;
the MQTT process starting module is used for establishing connection between the OpenWrt router and the cloud server based on the configuration file and starting the MQTT process, and the MQTT process issues a successful connection notice of the cloud server;
the connection state acquisition module is used for monitoring the successful connection notification of the cloud server by the OpenWrt router so as to acquire the connection state of the cloud server;
the wired user flow acquisition module is used for acquiring wired user flow through a swconfig command by the OpenWrt router based on the connection state;
and the wired user flow uploading module is used for calling a ubus interface of the MQTT process to upload to a cloud server after the OpenWrt router packages the wired user flow into a JSON format, and the cloud server receives and displays the wired user flow.
7. The OpenWrt router wired user traffic acquisition system of claim 6, wherein: the profile creation module is further configured to:
and encrypting the configuration file by using a cryptographic algorithm, and storing the configuration file in a designated path.
8. The OpenWrt router wired user traffic acquisition system of claim 6, wherein: the MQTT process starting module is specifically used for:
the OpenWrt router establishes connection with the cloud server based on the cloud server address, the cloud server port and the encryption mode carried by the configuration file, and pings the cloud server through the OpenWrt router to verify the connection;
the OpenWrt router calls a moquitto_lib_init function initialization library of the moquitto library, calls a moquitto_new function of the moquitto library to create a moquitto object, calls a moquitto_message_cal lback_set function of the moquitto library to create a Broker message processing callback function, calls a moquitto_tls_set function of the moquitto library to start tls authentication, calls a moquitto_connect function of the moquitto library to connect with a Broker, and calls a moquitto_loop_forever function of the moquitto library to keep long connection after the Broker connection is successful so as to start an MQTT process, and the MQTT process issues a cloud server connection success notification.
9. The OpenWrt router wired user traffic acquisition system of claim 6, wherein: the connection state acquisition module is specifically configured to:
the OpenWrt router calls a ubus_register_event_handler function through a c language interface provided by a ubus interface of the MQTT process to monitor the connection success notification of the cloud server, and acquires the connection state of the cloud server based on a status field in the connection success notification of the cloud server; the connection state is connection success or connection failure.
10. The OpenWrt router wired user traffic acquisition system of claim 1, wherein: in the wired user flow obtaining module, the wired user flow includes a receiving flow and a sending flow.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311646018.4A CN117880347A (en) | 2023-12-04 | 2023-12-04 | OpenWrt router wired user flow obtaining method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311646018.4A CN117880347A (en) | 2023-12-04 | 2023-12-04 | OpenWrt router wired user flow obtaining method and system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117880347A true CN117880347A (en) | 2024-04-12 |
Family
ID=90576142
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311646018.4A Pending CN117880347A (en) | 2023-12-04 | 2023-12-04 | OpenWrt router wired user flow obtaining method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117880347A (en) |
-
2023
- 2023-12-04 CN CN202311646018.4A patent/CN117880347A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112769938B (en) | Kubernets cloud side communication system and method based on QUIC | |
JP5982002B2 (en) | Network bandwidth throttling using traffic scheduling | |
CN111083161A (en) | Data transmission processing method and device and Internet of things equipment | |
US10298627B2 (en) | Concentration of independent tunneled encapsulated media | |
CN109327493A (en) | A kind of remote medical monitoring system based on cloud and monitoring method | |
CN112631788B (en) | Data transmission method and data transmission server | |
AU2002325941B2 (en) | System for remote data acquisition based on e-mail message communication through public and private networks | |
US20220239761A1 (en) | Data Subscription Method, Apparatus, and System | |
CN113194550B (en) | Data channel construction method, server and data cluster system | |
US10645184B2 (en) | Information transmission method, gateway, and controller | |
US20220109607A1 (en) | Customer premises equipment configuration management method and apparatus | |
CN112333237B (en) | 5G industrial module and electronic equipment | |
CN117615043B (en) | Inter-service communication method and system on edge gateway | |
US20240251016A1 (en) | Communication protocol, and a method thereof for accelerating artificial intelligence processing tasks | |
CN117880347A (en) | OpenWrt router wired user flow obtaining method and system | |
WO2011130962A1 (en) | Remote processing method, device and system | |
US6973044B1 (en) | Efficient method for collecting statistics via a half-duplex serial bus | |
CN110086772B (en) | Method and system for acquiring monitoring video | |
CN117978697A (en) | OpenWrt router user real-time rate acquisition method and system | |
JP5162641B2 (en) | Automatic configuration system for media adapter device and router device | |
CN100375464C (en) | Method for data communication of every terminal when network interconnecting | |
CN117675896A (en) | Router remote management method and system based on MQTT | |
CN118018538B (en) | Method for communication of Internet of things through external program module | |
CN114268979A (en) | A secure communication method for northbound interface of network management terminal | |
KR100798995B1 (en) | Trap message transmission method using SNP based TC |
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 |