Log management method based on pon network and onu gateway and related products
By implementing a log management method for ONU gateways in a PON network, and through log level matching and hierarchical storage strategies, the problem of unlimited log growth in ONU gateways has been solved, achieving efficient utilization of system resources and complete fault diagnosis.
Patent Information
- Application Number
- CN202611431190.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-15
- Publication Date
- 2026-11-27
AI Technical Summary
In Passive Optical Networks (PON), when the ONU gateway is unattended for a long time, the logs grow indefinitely, consuming system resources, and the fault information disappears before maintenance personnel intervene, making it difficult to achieve a balance between diagnostic integrity, persistent memory lifespan, and long-distance transmission bandwidth.
By determining the log level of the log to be processed and matching it with the preset local and remote masks, the retention and remote transmission of the log are controlled respectively; when the memory buffer reaches the segmentation threshold, it is frozen as a read-only snapshot and compressed into an archive segment and written to persistent storage, thereby realizing the hierarchical retention of logs and avoiding unlimited growth.
By continuously storing the latest logs within a fixed space, a balance is achieved between diagnostic integrity, persistent storage lifespan, and remote transmission bandwidth, thus avoiding unlimited occupation of system resources.
Smart Images

Figure CN123185060A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer network technology, and in particular to a log management method based on a PON network and an ONU gateway, a log management device based on a PON network and an ONU gateway, an ONU gateway, and a computer-readable storage medium. Background Technology
[0002] Passive Optical Network (PON) is an optical access network employing a point-to-multipoint topology, typically comprising an Optical Line Terminal (OLT) and multiple Optical Network Unit (ONU) gateways. The OLT, located at the central office, connects to the upper-layer network; the ONU gateway, located at the user side, connects to the OLT via optical fiber, providing broadband access to the user. In home and small-scale applications, ONU gateways often operate unattended for extended periods, continuously generating logs for startup, link, address allocation, wireless access, authentication, forwarding, and anomaly recovery. When an ONU gateway experiences intermittent network outages, restarts, or configuration errors, the fault often disappears before maintenance personnel intervene. Maintenance personnel can only reconstruct the complete event chain before and after the fault by reading the logs on-site. Therefore, ONU gateways need to retain logs within limited storage space. Summary of the Invention
[0003] This application provides a log management method, a log management device, an ONU gateway, and a computer-readable storage medium based on a PON network and an ONU gateway. The method and device can continuously store the latest logs in a fixed space, avoiding the infinite growth of logs that occupy system resources. At the same time, it achieves a balance between diagnostic integrity, persistent storage lifespan, and remote transmission bandwidth.
[0004] Firstly, the log management method based on PON network and ONU gateway provided in this application includes: Determine the log level of the log to be processed, and match the log level with the preset local mask and remote mask respectively; If the log level matches the remote mask, the log to be processed is sent to the remote log server. If the log level matches the local mask, the log to be processed is written to the currently active buffer in memory; When the current active buffer reaches the segmentation threshold, the current active buffer is frozen as a read-only snapshot and a new active buffer is created. The read-only snapshot is compressed into the current archive segment and written to the archive slot of persistent storage. The continuous context at the end of the previous archive segment is copied to the new active buffer.
[0005] Secondly, the log management device based on a PON network and an ONU gateway provided in this application includes: The channel matching module is used to determine the log level of the log to be processed and match the log level with the preset local mask and remote mask respectively; The remote channel module is used to send the log to be processed to the remote log server if the log level matches the remote mask. The local channel module is used to write the log to be processed to the current active buffer in memory if the log level matches the local mask; and to freeze the current active buffer as a read-only snapshot and create a new active buffer when the current active buffer reaches the segment threshold, and to compress the read-only snapshot into the current archive segment and write it to the archive slot of persistent storage, and to copy the continuous context at the end of the previous archive segment to the new active buffer.
[0006] Optionally, in one embodiment, when compressing a read-only snapshot into the current archive segment and writing it to the archive slot of persistent storage, the local channel module is used to: Compress the read-only snapshot into the current archive segment, and determine the target slot number of the current archive segment in persistent storage based on the segmentation threshold and the log budget capacity of persistent storage; Write the current archive segment to the archive slot corresponding to the target slot number in the persistent storage.
[0007] Optionally, in one embodiment, when writing the current archive segment to the archive slot corresponding to the target slot number in the persistent memory, the local channel module is used to: Get the remaining available space in persistent storage, and get the compression ratio of multiple archive segments within the data window where the current archive segment is located; The target slot number is corrected based on the remaining available space and the compression ratio to obtain the corrected slot number; Write the current archive segment to the archive slot with the corresponding correction slot number in the persistent storage.
[0008] Optionally, in one embodiment, the log management device based on a PON network and an ONU gateway provided in this application further includes a log evidence collection module, used for: Upon receiving a log evidence request from the party making the evidence request, the current active buffer is copied as a read-only tail segment; The read-only end segment is concatenated with the archived segment already stored in persistent storage to form a log forensics packet, and the log forensics packet is returned to the forensics requester.
[0009] Optionally, in one embodiment, when concatenating the read-only end segment with the archived segment already stored in persistent storage to form a log forensics package, the log forensics module is used to: The diagnostic value of each archive segment stored in persistent storage is determined based on its log level, timestamp, and context continuity. Obtain the maximum capacity that the evidence requester can accept, and based on the diagnostic value and capacity limit of each stored archive segment, select several archive segments from the stored archive segments and concatenate them with the read-only tail segment to form a log evidence package.
[0010] Optionally, in one embodiment, after returning the log forensics package to the requesting party, the log forensics module is further configured to: When the log evidence packet fails to be returned to the evidence requester, a retry interval is determined, and the log evidence packet is retransmitted according to the retry interval until the maximum number of retries is reached or the upload is successful.
[0011] Optionally, in one embodiment, when determining the retry interval, the log forensics module is used to: Based on the initial interval, the retry interval is obtained by adding the backoff time, which increases with the number of retries but does not exceed the maximum backoff time, and adding the random jitter determined by the number of retries.
[0012] Thirdly, the ONU gateway provided in this application includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, it implements the log management method based on the PON network and ONU gateway provided in this application.
[0013] Fourthly, the computer-readable storage medium provided in this application stores a computer program, which, when executed by a processor, implements the log management method based on a PON network and an ONU gateway provided in this application.
[0014] The log management scheme based on PON network and ONU gateway provided in this application determines the log level of the log to be processed and matches the log level with preset local and remote masks respectively. If the log level matches the remote mask, the log to be processed is sent to the remote log server; if the log level matches the local mask, the log to be processed is written to the current active buffer in memory. When the current active buffer reaches the segmentation threshold, the current active buffer is frozen as a read-only snapshot and a new active buffer is created. The read-only snapshot is compressed into the current archive segment and written to the archive slot of persistent storage. The continuous context at the end of the previous archive segment is copied to the new active buffer. In this way, by independently controlling the log level strategy of local retention and real-time remote transmission through local and remote masks respectively, a balance is achieved between diagnostic integrity, persistent storage life and remote transmission bandwidth. At the same time, through the hierarchical retention of memory buffer and persistent storage compression, the latest logs can be continuously stored in a fixed space, avoiding the infinite growth of logs and the occupation of system resources. Attached Figure Description
[0015] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a schematic diagram of a log management system based on a PON network and an ONU gateway provided in an embodiment of this application; Figure 2 This is a flowchart illustrating the log management method based on a PON network and an ONU gateway provided in an embodiment of this application. Figure 3 This is a schematic diagram of the structure of the log management device based on a PON network and an ONU gateway provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the ONU gateway provided in the embodiments of this application. Detailed Implementation
[0017] To make the technical problems, technical solutions, and beneficial effects solved by this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0018] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0019] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0020] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0021] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0022] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0023] This application provides a log management method based on a PON network and an ONU gateway, a log management device based on a PON network and an ONU gateway, an ONU gateway, a computer-readable storage medium, and a computer program product. The log management method based on a PON network and an ONU gateway can be executed by the log management device based on a PON network and an ONU gateway, or by an ONU gateway integrating the log management device based on a PON network and an ONU gateway.
[0024] Please refer to Figure 1 This application also provides a log management system based on a PON network and an ONU gateway, such as... Figure 1 As shown, the log management system based on a PON network and an ONU gateway includes an ONU gateway and a remote log server. The ONU gateway can determine the log level of the log to be processed and match the log level with preset local and remote masks respectively. If the log level matches the remote mask, the log to be processed is sent to the remote log server. If the log level matches the local mask, the log to be processed is written to the current active buffer in memory. When the current active buffer reaches the segmentation threshold, the current active buffer is frozen as a read-only snapshot and a new active buffer is created. The read-only snapshot is compressed into the current archive segment and written to the archive slot of the persistent storage. The continuous context at the end of the previous archive segment is copied to the new active buffer.
[0025] It should be noted that, Figure 1The schematic diagram of the log management system based on PON network and ONU gateway shown is merely an example. The log management system and scenario based on PON network and ONU gateway described in this application are for the purpose of more clearly illustrating the technical solutions of this application and do not constitute a limitation on the technical solutions provided in this application. As those skilled in the art will know, with the evolution of log management systems based on PON network and ONU gateway and the emergence of new service scenarios, the technical solutions provided in this application are also applicable to similar technical problems.
[0026] To facilitate understanding, the technical terms involved in the embodiments of this application will be explained below: PON (Passive Optical Network): A point-to-multipoint access network technology, typically composed of an Optical Line Terminal (OLT), an Optical Distribution Network (ODN), and Optical Network Unit (ONU) gateways. The OLT is located at the central office and distributes optical signals to multiple ONU gateways via passive optical splitters in the ODN. The ONU gateways are located on the user side, acting as access gateways to provide broadband access to homes or small businesses.
[0027] ONU gateway: In a PON network, this refers to the access gateway device located on the user side. It possesses memory, persistent storage (such as flash memory), and processing capabilities, carrying out functions such as routing, forwarding, wireless access, and address allocation, and running software modules such as log management. The method described in this application can be applied to Fiber to the Room (FTTR), enterprise-level Fiber to the Room-Business (FTTR-B), and broadband converged terminal products.
[0028] Logs: During the operation of the ONU gateway, each software module (such as startup, link, address allocation, wireless access, authentication, forwarding and anomaly recovery modules) records information describing the device's operating status and events, which usually includes fields such as time, level, and content.
[0029] Log levels: These are used to identify the importance or severity of the events described in the logs. In this application, the log levels may include eight levels: Critical, Alarm, Critical, Error, Warning, Notification, Information, and Debug. Among them, Critical, Alarm, Critical, and Error are usually high-level logs, fewer in number but with high diagnostic value; Warning, Notification, Information, and Debug are low-level logs, more in number but helpful in reproducing the entire fault process.
[0030] A mask is a combination used for bitwise control of switches. In this application, the mask is a preset bit string with enable bits set bit by bit according to the log level. When the enable bit corresponding to a certain log level is 1 (i.e., a match), it indicates that logs of that level are allowed to enter the corresponding channel; when it is 0 (i.e., a mismatch), it indicates that logs are prohibited. The local mask is used to control the range of log levels retained locally, and the remote mask is used to control the range of log levels forwarded to the remote log server in real time. The two are independent of each other and can be configured separately.
[0031] Current Activity Buffer: A volatile buffer in the ONU gateway's memory used to temporarily store the latest written local logs. It is in a readable and writable active state; when the segmentation threshold is reached, it is frozen into a read-only snapshot.
[0032] Segment threshold: The preset upper limit of the current active buffer size, that is, the maximum size allowed for each log segment before compression (also known as the single segment uncompressed limit). When this threshold is reached, a cycle of archiving is triggered.
[0033] Read-only snapshot: A read-only log segment created by freezing the currently active buffer when it reaches the segmentation threshold, and used as input for an archive.
[0034] Archive segment: A log segment that is written to the persistent storage archive slot after compressing and verifying read-only snapshots. It is the product of cyclic archiving. Multiple adjacent archive segments are arranged in chronological order to form a continuous log history.
[0035] Archive slot: A storage unit in persistent storage (such as flash memory) used to store archive segments. Multiple archive slots are used in a cycle, identified by slot number, and can be written to and overwritten in a cycle.
[0036] Persistent storage: a non-volatile storage medium that retains data even after power failure, such as flash memory in this application, used for cyclic storage of archive segments and log indexes.
[0037] Continuous context: To ensure that log information remains continuous between adjacent archive segments at the rotation boundary, a number of log lines from the end of the previous archive segment are pre-set in the new archive segment.
[0038] Log Evidence Packet: In response to an evidence request, a log data packet is formed by concatenating and encapsulating the read-only tail segment with the archived segment already stored in persistent storage, and is used to reconstruct the event chain before and after the failure.
[0039] The party requesting evidence collection: The party initiating the log evidence collection request can be the remote log server or file transfer server of the maintenance platform, or the management terminal that is logged in through a web page, in order to obtain the historical logs of the ONU gateway for troubleshooting.
[0040] Please refer to Figure 2This is a flowchart illustrating a log management method based on a PON network and an ONU gateway disclosed in an embodiment of this application. Figure 2 As shown, the process of this log management method based on PON network and ONU gateway can be as follows: In S110, the log level of the log to be processed is determined, and the log level is matched with the preset local mask and remote mask respectively.
[0041] In this embodiment of the application, when the software module of the ONU gateway generates various event information during operation, it encapsulates it into a log and adds information such as timestamp, log level, monotonic sequence number, etc. to form a unified log format.
[0042] The log level can be labeled by the software module that generates the log according to the severity of the event described in the log. For example, if the log describes a serious event such as a reset or restart of the ONU gateway, the log level can be labeled as high (such as urgent or serious); if the log describes a normal link establishment process, the log level can be labeled as low (such as information or debugging).
[0043] Logs pending processing refer to raw logs newly generated by software modules that have entered the log management process but have not yet completed mask matching and storage decisions.
[0044] The ONU gateway is pre-configured with a local mask M_L and a remote mask M_R. The local mask controls the range of log levels retained locally, while the remote mask controls the range of log levels forwarded to the remote log server in real time. For example, assuming the log level is 1, the log level 1 is ANDed with the corresponding bit M_L[l] in the local mask M_L and with the corresponding bit M_R[l] in the remote mask M_R. The result of the AND operation determines whether the log level matches the corresponding mask: if the result is 1, it matches; if it is 0, it does not match. It should be noted that the local mask and the remote mask are independent of each other, respectively limiting the allowed log levels for local retention and remote forwarding. Therefore, the local server can retain low-level logs such as notifications and information, while the remote server can only forward high-level logs of error level and above in real time; the two do not affect each other.
[0045] After determining the log level of the log to be processed, the ONU gateway matches the log level of the log to be processed with the preset local mask and remote mask respectively to determine whether the log to be processed meets the level conditions for local retention or remote real-time forwarding, thereby providing a basis for subsequent differentiated storage and transmission decisions.
[0046] In S120, if the log level matches the remote mask, the log to be processed is sent to the remote log server.
[0047] When the log level of the log to be processed matches the remote mask (i.e., is allowed by the remote mask), the ONU gateway sends the log to be processed to the remote log server in real time, so that the maintenance platform can continuously monitor the operating status of the ONU gateway.
[0048] The ONU gateway can send data using a preset transmission method (such as the Syslog protocol or file transfer protocol) and the configured server address and port. This real-time forwarding process is independent of the local archiving process. When the remote log server is unreachable, local archiving can still continue to run without affecting the retention of local logs.
[0049] In S130, if the log level matches the local mask, the log to be processed is written to the currently active buffer in memory.
[0050] When the log level of a log to be processed matches the local mask (i.e., is allowed by the local mask), the ONU gateway writes the log to be processed into the currently active buffer in memory. The currently active buffer is a volatile buffer in the ONU gateway's memory used to temporarily store the most recently written local log.
[0051] It should be noted that if a log entry's log level matches both the local and remote masks, the log entry is written to the current active buffer for local retention and simultaneously sent to the remote log server for remote monitoring. If it matches only one type of mask, it only enters the corresponding channel. This achieves an independent and non-interfering log level strategy for local retention and real-time remote transmission.
[0052] In S140, when the current active buffer reaches the segmentation threshold, the current active buffer is frozen as a read-only snapshot and a new active buffer is created. The read-only snapshot is compressed into the current archive segment and written to the archive slot of the persistent memory. The continuous context at the end of the previous archive segment is copied to the new active buffer.
[0053] The ONU gateway continuously writes logs matching the local mask to the current active buffer and monitors the size of the current active buffer. When the size of the current active buffer reaches a preset segmentation threshold, it indicates that the current buffer is full. At this point, the ONU gateway freezes the current active buffer as a read-only snapshot and creates a new active buffer to continue receiving subsequent logs, thus ensuring uninterrupted log collection. For example, the segmentation threshold can be set to approximately 4MB.
[0054] In addition, the ONU gateway compresses the frozen read-only snapshot to obtain the current archive segment, and writes the current archive segment into the archive slot of the persistent storage. The persistent storage can be the ONU gateway's flash memory, and the archive slot is a storage unit within the flash memory used to store the archive segment; multiple archive slots are used cyclically.
[0055] While writing to the current archive segment, the ONU gateway copies the continuous context from the end of the previous archive segment to the new active buffer. This means that the new archive segment (the current log segment corresponding to the new active buffer) pre-sets several log lines from the end of the previous archive segment (exemplarily retaining the last 200 lines), ensuring log context continuity between adjacent archive segments at the rotation boundary. This allows for the restoration of the complete fault event chain even when a fault crosses a segment boundary. For example, the ONU gateway can also attach a "cross-segment copy" flag to these copied continuous context lines, enabling deduplication of logs duplicated in the cross-segment copy and adjacent archive segments based on log sequence numbers during subsequent merge and export, thus preventing log duplication.
[0056] As described above, the log management scheme based on PON network and ONU gateway provided in this application determines the log level of the log to be processed and matches the log level with preset local and remote masks respectively. If the log level matches the remote mask, the log to be processed is sent to the remote log server; if the log level matches the local mask, the log to be processed is written to the current active buffer in memory. When the current active buffer reaches the segmentation threshold, the current active buffer is frozen as a read-only snapshot and a new active buffer is created. The read-only snapshot is compressed into the current archive segment and written to the archive slot of persistent storage. The continuous context at the end of the previous archive segment is copied to the new active buffer. In this way, by independently controlling the log level strategy of local retention and real-time remote transmission through local and remote masks respectively, a balance is achieved between diagnostic integrity, persistent storage lifespan, and remote transmission bandwidth. At the same time, through the layered retention of memory buffer-persistent storage compression, the latest logs can be continuously stored in a fixed space, avoiding the infinite growth of logs and the occupation of system resources.
[0057] Optionally, in one embodiment, compressing a read-only snapshot into the current archive segment and writing it to the archive slot of persistent storage includes: Compress the read-only snapshot into the current archive segment, and determine the target slot number of the current archive segment in persistent storage based on the segmentation threshold and the log budget capacity of persistent storage; Write the current archive segment to the archive slot corresponding to the target slot number in the persistent storage.
[0058] The log budget capacity of persistent storage is the amount of flash space pre-allocated for log archiving; The segmentation threshold is the upper limit of the size of a single log segment before compression.
[0059] In this embodiment, the ONU gateway can determine the number of archiving slots based on the log budget capacity, segmentation threshold, and reservation coefficient, and calculate the target slot number using a cyclically increasing method to achieve cyclic overwrite storage of logs within a fixed space, for example: N = ⌊B_f / (ρB_m)⌋; Where N represents the target slot number, B_f represents the log budget capacity, B_m represents the segmentation threshold, ρ represents the reservation coefficient used to cover compression rate fluctuations, indexing, and temporary file overhead, and can be calibrated according to the compressibility of the actual log content, and ⌊⌋ represents rounding down. For example, using a segmentation threshold of approximately 4MB and thirteen fixed slots, a circular log retention space of approximately 50MB can be formed.
[0060] It should be noted that after the target slot number is determined for the first time, when determining the target slot number in subsequent times, the ONU gateway can use a cyclic increment method to calculate the target slot number. That is, the current slot number is incremented by one and then moduloed by the total number of archive slots to obtain the next target slot number. This cyclic increment is achieved within the total number of archive slots, thus realizing the cyclic overwrite storage of logs within a fixed space.
[0061] Optionally, in one embodiment, writing the current archive segment to the archive slot corresponding to the target slot number in the persistent memory includes: Get the remaining available space in persistent storage, and get the compression ratio of multiple archive segments within the data window where the current archive segment is located; The target slot number is corrected based on the remaining available space and the compression ratio to obtain the corrected slot number; Write the current archive segment to the archive slot with the corresponding correction slot number in the persistent storage.
[0062] In this embodiment, the ONU gateway also obtains the remaining available space of the persistent storage, i.e., the current available space in the flash memory for log archiving. Simultaneously, the ONU gateway also obtains the compression ratio of multiple archive segments within the data window containing the current archive segment. The data window is a preset sliding window used to observe the compression status of recent archive segments, containing multiple recently written archive segments. The compression ratio measures the size ratio of an archive segment before and after compression; for example, if an archive segment is 4MB before compression and 1MB after compression, its compression ratio is approximately 4:1 (i.e., 25%).
[0063] After obtaining the remaining available space and the compression ratios of multiple archive segments, the initially determined target slot number is further corrected based on the obtained remaining available space and the compression ratios of multiple archive segments to obtain the corrected slot number. For example, when the remaining available space is insufficient, or when there is a significant deviation between the actual compression ratio of multiple archive segments within the data window and the assumed compression ratio corresponding to the preset reservation coefficient ρ (e.g., the actual compression ratio is significantly lower than the assumed value, resulting in the archive segment actually occupying more space than expected), it indicates that writing to the original target slot number may cause insufficient space or premature overwriting. In this case, the ONU gateway can dynamically adjust the number of archive slots N (e.g., dynamically reduce N based on the actual available space and the compression ratios of the most recent segments), and recalculate the target slot number based on the adjusted number of archive slots to obtain the corrected slot number. It should be noted that the reduced number of archive slots should not be lower than the minimum number of slots required to guarantee the fault window, that is, it should ensure that at least the amount of logs required to cover the time period before and after a typical fault occurs can be retained.
[0064] As shown above, after obtaining the corrected slot number, the ONU gateway writes the current archive segment into the archive slot corresponding to the corrected slot number in the persistent storage, thus completing this archive.
[0065] The above method dynamically adjusts the slot number based on the remaining available space and the actual compression ratio, enabling cyclic archiving to adapt to the dynamic changes in the available space of persistent storage and the log compression characteristics. This fully utilizes storage space and avoids premature overwriting or write failures of evidence due to space estimation errors, thereby improving the controllability and reliability of log retention.
[0066] Optionally, in one embodiment, the log management method based on a PON network and an ONU gateway provided in this application further includes: Upon receiving a log evidence request from the party making the evidence request, the current active buffer is copied as a read-only tail segment; The read-only end segment is concatenated with the archived segment already stored in persistent storage to form a log forensics packet, and the log forensics packet is returned to the forensics requester.
[0067] When the ONU gateway receives a log evidence collection request from the requesting party, it triggers a log evidence collection process. The requesting party can be a remote log server or file transfer server of the maintenance platform, or a web management terminal or an authorized remote management entity.
[0068] To avoid compromising the consistency of the log forensics packet due to continuous log writing during the log export process, the ONU gateway replicates the current active buffer as a read-only tail segment, i.e., generates a read-only copy of the current active buffer for inclusion in this log forensics packet. After obtaining the read-only tail segment, the current active buffer continues to receive logs, without pausing log collection for an extended period due to forensics packetization, thus ensuring that new faults during the export process are not missed.
[0069] For example, the ONU gateway can also record the snapshot boundary number and the trigger time. The snapshot boundary number is the sequence number of the last log in the current active buffer corresponding to this evidence collection (i.e., the sequence number boundary of the read-only tail segment). The trigger time is the time when the log evidence collection request is received, which is used for deduplication and boundary determination when merging archive segments in the future.
[0070] The ONU gateway reads the archive segments stored in the persistent storage, concatenates the read-only end segment with these archive segments to form a log forensics packet, and then returns the log forensics packet to the forensics requester.
[0071] For example, the ONU gateway can read the list of archive segments from the log index of persistent storage, parse each archive segment in cyclic order starting from the earliest valid archive slot, and then append the read-only tail segment to each archive segment to form a complete log sequence arranged in chronological order, which serves as the log forensics package. During the concatenation process, the ONU gateway can deduplicate adjacent archive segments and read-only tail segments based on the monotonic sequence number of the logs (for example, logs with consecutive contexts marked by cross-segment replica flags that overlap with the source archive segment are deduplicated by sequence number), and discard new logs with sequence numbers exceeding the snapshot boundary sequence number, thereby ensuring that no logs within the same log forensics package are omitted or mixed with uncertain data after triggering.
[0072] In addition, the log forensics package can also contain verification information such as device category, software version, configuration generation, snapshot boundary, start and end sequence numbers of each archive segment, level statistics, compressed summary and general inventory summary. The party requesting for evidence can use this information to verify whether the log forensics package file is complete, whether the order is continuous and whether it comes from the same snapshot, thus achieving verifiable evidence collection.
[0073] The above method generates a log forensics package by copying the read-only tail segment and concatenating it with the stored archive segment. While continuously collecting logs, it forms a time-consistent forensics snapshot, ensuring that log forensics includes the latest logs before the trigger time, and that collection is not interrupted due to packaging. This achieves parallel processing of consistent forensics and continuous collection.
[0074] Optionally, in one embodiment, the read-only end segment is concatenated with the archived segment already stored in persistent storage to form a log forensics package, including: The diagnostic value of each archive segment stored in persistent storage is determined based on its log level, timestamp, and context continuity. Obtain the maximum capacity that the evidence requester can accept, and based on the diagnostic value and capacity limit of each stored archive segment, select several archive segments from the stored archive segments and concatenate them with the read-only tail segment to form a log evidence package.
[0075] When the uplink bandwidth of the ONU gateway or the receiving capacity of the party requesting evidence is limited, preventing the uploading of all archive segments at once, the ONU gateway needs to select the most valuable archive segments from the stored archive segments and include them in the log evidence package. To this end, the ONU gateway calculates the diagnostic value of each archive segment based on its corresponding log level, timestamp, and context continuity.
[0076] The diagnostic value of an archive segment is related to its log level (such as the severity corresponding to the highest log level within the segment), the time distance from the fault / evidence collection moment, and the continuity of context. Specifically, the higher the log level of the archive segment, the closer the time distance to the trigger moment, and the higher the continuity of context, the higher the diagnostic value; conversely, if an archive segment has already been successfully uploaded (high degree of duplication), its diagnostic value may decrease accordingly.
[0077] For example, the diagnostic value of archive segment j can be expressed as: V_j=αP_j+βe^(-|t_j-t_0| / τ)+γC_j-δD_j; Where P_j represents the severity corresponding to the highest log level of archive segment j, t_j represents the center time of archive segment j, t_0 represents the trigger time, τ represents the failure time window decay constant, C_j represents the contextual continuity of archive segment j with adjacent archive segments or the current active buffer, D_j represents the degree of duplication of archive segment j that has been successfully uploaded, and α, β, γ, and δ are non-negative weights. This formula is only used to illustrate the calculation method of diagnostic value, and this application does not impose specific limitations on it, as long as it can comprehensively reflect the log level, temporal proximity, and contextual continuity of the archive segment.
[0078] In addition, the ONU gateway also obtains the maximum capacity that the evidence requester can receive (i.e., the amount of data allowed in this upload), and then, based on the diagnostic value of each archive segment and this maximum capacity, selects several archive segments with higher diagnostic value from the stored archive segments. For example, the ONU gateway can sort the archive segments from highest to lowest diagnostic value, and, provided that the total upload size does not exceed the maximum capacity, prioritize the inclusion of archive segments with higher diagnostic value into the log evidence package.
[0079] It should be noted that the read-only tail segment contains the latest logs before the trigger time, and is the evidence with the highest diagnostic value and closest to the time of failure in the entire log forensics package. Therefore, during the screening process, the ONU gateway forcibly includes the read-only tail segment in the log forensics package without any pruning. In addition, the ONU gateway can also forcibly include archive segments before and after the trigger time (such as the one or two most recent archive segments before and after the trigger time) and the manifest file (containing the index of the archive segments, the start and end timestamps of each segment, and checksums, etc.) to ensure that the log forensics package can cover the critical window before and after the failure time, and the log forensics package can be verified and parsed through the manifest file.
[0080] The above method filters archive segments based on diagnostic value. When transmission capacity is limited, it prioritizes the retention of high-level log segments that are close to the time of failure and have a continuous context. It also forces the inclusion of read-only tail segments, the segments closest to the trigger time, and manifest files. This prevents the most valuable fault windows from being overwhelmed by a large amount of ordinary information or from failing to upload due to excessively large files, thereby increasing the probability of remote forensics and problem location.
[0081] Optionally, in one embodiment, after returning the log forensics packet to the forensics requester, the method further includes: When the log evidence packet fails to be returned to the evidence requester, a retry interval is determined, and the log evidence packet is retransmitted according to the retry interval until the maximum number of retries is reached or the upload is successful.
[0082] After returning the log evidence packet to the requesting party, the ONU gateway receives the requesting party's response or the local transmission result, and determines whether the upload was successful. If successful, the evidence collection is completed, and the completion status can be recorded and the temporary evidence packet deleted; if it fails, the retransmission process begins.
[0083] When an upload fails, the ONU gateway determines the retry interval, which is the time to wait before retransmission. After waiting for the retry interval, the ONU gateway retransmits the log evidence packet and checks again whether the upload was successful. If it still fails, the retry interval is reset and retransmission continues until the maximum number of retries is reached or the upload is successful. If the maximum number of retries is reached and the upload is still unsuccessful, the ONU gateway stops retrying and may optionally write the reason for failure back to the evidence requester or maintenance platform.
[0084] Optionally, the ONU gateway can interpret this log evidence collection trigger as a one-time command and generate a task identifier. Repeated triggers with the same task identifier will only return the current task status and will not be packaged or uploaded repeatedly, thereby avoiding repeated generation and uploading of evidence collection packages due to repeated commands.
[0085] Optionally, the ONU gateway can also retain the generated log evidence packets and task status during the retransmission process, and delete the temporary evidence packets after successful upload to ensure safe retry after communication interruption.
[0086] By using retransmission upon failure and bounded retries, the log evidence collection process forms a remote closed loop that is queryable, recoverable, and does not repeat, thus preventing the loss of critical evidence due to a single communication anomaly.
[0087] Optionally, in one embodiment, determining the retry interval includes: Based on the initial interval, the retry interval is obtained by adding the backoff time, which increases with the number of retries but does not exceed the maximum backoff time, and adding the random jitter determined by the number of retries.
[0088] The initial interval is the base waiting time before the first retry.
[0089] The backoff time increases exponentially with the number of retries, but is constrained by the maximum backoff time, meaning the backoff time does not exceed the maximum backoff time, thus preventing the retry interval from growing indefinitely.
[0090] Random jitter is used to randomly distribute retry times across the timeline, preventing a large number of devices from retrying simultaneously due to the same backoff pattern, which could cause momentary congestion on remote log servers or file transfer servers. For example, random jitter can be obtained by taking the modulo of a discrete window using a hash function with the number of retries as input (optionally combined with the task identifier).
[0091] For example, the time for the r-th retry can be expressed as: T_r=T_0+min(T_max,2^r·Δ)+[H(r) mod W]; Where T_0 is the initial interval, T_max is the maximum backoff time, Δ is the basic backoff, W is the discrete window size, H is the hash function, min indicates taking the smaller value, and mod indicates taking the modulus. It should be noted that the above formula is only used as an example to illustrate the superposition of bounded backoff and random jitter, and this application does not impose any specific restrictions on it.
[0092] The above method combines bounded backoff with random jitter to determine the retry interval, ensuring that the ONU gateway will not extend the waiting time indefinitely during retries, nor will it retransmit simultaneously at the moment the server recovers due to completely consistent backoff patterns. This effectively reduces the instantaneous impact on the evidence requester, improves the retransmission success rate, and enhances the overall stability of operation and maintenance.
[0093] To facilitate better implementation of the above log management method based on PON network and ONU gateway, this application also provides a corresponding log management device based on PON network and ONU gateway. The meanings of the terms used are the same as in the above log management method based on PON network and ONU gateway; for specific implementation details, please refer to the descriptions in the above method embodiments.
[0094] Please refer to Figure 3 The log management device based on PON network and ONU gateway may include channel matching module 210, remote channel module 220 and local channel module 230. The detailed description of each functional module is as follows: The channel matching module 210 is used to determine the log level of the log to be processed and match the log level with the preset local mask and remote mask respectively; The remote channel module 220 is used to send the log to be processed to the remote log server if the log level matches the remote mask. The local channel module 230 is used to write the log to be processed to the current active buffer in memory if the log level matches the local mask; and to freeze the current active buffer as a read-only snapshot and create a new active buffer when the current active buffer reaches the segment threshold, and to compress the read-only snapshot into the current archive segment and write it to the archive slot of the persistent storage, and to copy the continuous context at the end of the previous archive segment to the new active buffer.
[0095] Optionally, in one embodiment, when compressing a read-only snapshot into the current archive segment and writing it to the archive slot of persistent storage, the local channel module 230 is used to: Compress the read-only snapshot into the current archive segment, and determine the target slot number of the current archive segment in persistent storage based on the segmentation threshold and the log budget capacity of persistent storage; Write the current archive segment to the archive slot corresponding to the target slot number in the persistent storage.
[0096] Optionally, in one embodiment, when writing the current archive segment to the archive slot corresponding to the target slot number in the persistent memory, the local channel module 230 is used to: Get the remaining available space in persistent storage, and get the compression ratio of multiple archive segments within the data window where the current archive segment is located; The target slot number is corrected based on the remaining available space and the compression ratio to obtain the corrected slot number; Write the current archive segment to the archive slot with the corresponding correction slot number in the persistent storage.
[0097] Optionally, in one embodiment, the log management device based on a PON network and an ONU gateway provided in this application further includes a log evidence collection module, used for: Upon receiving a log evidence request from the party making the evidence request, the current active buffer is copied as a read-only tail segment; The read-only end segment is concatenated with the archived segment already stored in persistent storage to form a log forensics packet, and the log forensics packet is returned to the forensics requester.
[0098] Optionally, in one embodiment, when concatenating the read-only end segment with the archived segment already stored in persistent storage to form a log forensics package, the log forensics module is used to: The diagnostic value of each archive segment stored in persistent storage is determined based on its log level, timestamp, and context continuity. Obtain the maximum capacity that the evidence requester can accept, and based on the diagnostic value and capacity limit of each stored archive segment, select several archive segments from the stored archive segments and concatenate them with the read-only tail segment to form a log evidence package.
[0099] Optionally, in one embodiment, after returning the log forensics package to the requesting party, the log forensics module is further configured to: When the log evidence packet fails to be returned to the evidence requester, a retry interval is determined, and the log evidence packet is retransmitted according to the retry interval until the maximum number of retries is reached or the upload is successful.
[0100] Optionally, in one embodiment, when determining the retry interval, the log forensics module is used to: Based on the initial interval, the retry interval is obtained by adding the backoff time, which increases with the number of retries but does not exceed the maximum backoff time, and adding the random jitter determined by the number of retries.
[0101] Specific limitations regarding the log management device based on PON networks and ONU gateways can be found in the limitations of the log management method based on PON networks and ONU gateways mentioned above, and will not be repeated here. Each module in the aforementioned log management device based on PON networks and ONU gateways can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the ONU gateway in hardware form or independent of it, or stored in the memory of the ONU gateway in software form, so that the processor can call and execute the corresponding operations of each module.
[0102] In one embodiment, an ONU gateway is provided, the internal structure of which can be shown as follows: Figure 4 As shown. This ONU gateway includes a processor, memory, network interface, and database connected via a system bus.
[0103] Network interfaces are used to connect to external devices. For example, network interfaces may include PON uplink interfaces, which are the physical interfaces through which ONU gateways access the PON network and are used to connect to the OLT via optical fiber.
[0104] The processor in the ONU gateway is used to provide computing and control capabilities.
[0105] The ONU gateway's storage includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and databases. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media to run.
[0106] When a computer program is executed by a processor, it implements the log management method based on a PON network and an ONU gateway provided in this application.
[0107] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When executed by a processor, the computer program implements the log management method based on a PON network and an ONU gateway as described above.
[0108] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0109] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0110] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A log management method based on a PON network and an ONU gateway, characterized in that, Determine the log level of the log to be processed, and match the log level with the preset local mask and remote mask respectively; If the log level matches the remote mask, the log to be processed is sent to the remote log server. If the log level matches the local mask, the log to be processed is written to the current active buffer in memory; When the current active buffer reaches the segmentation threshold, the current active buffer is frozen as a read-only snapshot and a new active buffer is created. The read-only snapshot is compressed into the current archive segment and written to the archive slot of the persistent storage. The continuous context at the end of the previous archive segment is copied to the new active buffer.
2. The log management method based on PON network and ONU gateway according to claim 1, characterized in that, The step of compressing the read-only snapshot into the current archive segment and writing it to the archive slot of persistent storage includes: The read-only snapshot is compressed into the current archive segment, and the target slot number of the current archive segment in the persistent storage is determined according to the segmentation threshold and the log budget capacity of the persistent storage. Write the current archive segment to the archive slot corresponding to the target slot number in the persistent memory.
3. The log management method based on PON network and ONU gateway according to claim 2, characterized in that, The step of writing the current archive segment into the persistent storage corresponding to the target slot number includes: Obtain the remaining available space of the persistent storage, and obtain the compression ratio of multiple archive segments within the data window where the current archive segment is located; The target slot number is corrected based on the remaining available space and the compression ratio to obtain the corrected slot number; Write the current archive segment to the archive slot corresponding to the corrected slot number in the persistent memory.
4. The log management method based on PON network and ONU gateway according to claim 1, characterized in that, Also includes: Upon receiving a log evidence request from the party requesting evidence, the current activity buffer is copied as a read-only end segment; The read-only end segment is concatenated with the archive segment already stored in the persistent storage to form a log forensics package, and the log forensics package is returned to the forensics requester.
5. The log management method based on PON network and ONU gateway according to claim 4, characterized in that, The step of concatenating the read-only tail segment with the archived segment already stored in the persistent storage to form a log forensics package includes: The diagnostic value of each archive segment stored in the persistent storage is determined based on its log level, timestamp, and context continuity. Obtain the maximum capacity that the evidence requester can receive, and based on the diagnostic value of each stored archive segment and the maximum capacity, select several archive segments from the stored archive segments and concatenate them with the read-only tail segment to form a log evidence package.
6. The log management method based on PON network and ONU gateway according to claim 4, characterized in that, After returning the log forensics package to the forensics requester, the method further includes: If the log evidence packet fails to be returned to the evidence requester, a retry interval is determined, and the log evidence packet is retransmitted according to the retry interval until the maximum number of retries is reached or the upload is successful.
7. The log management method based on PON network and ONU gateway according to claim 6, characterized in that, The determination of the retry interval includes: The retry interval is obtained by adding the backoff time, which increases with the number of retries but does not exceed the maximum backoff time, to the initial interval, and adding the random jitter determined by the number of retries.
8. A log management device based on a PON network and an ONU gateway, characterized in that, include: The channel matching module is used to determine the log level of the log to be processed, and match the log level with the preset local mask and remote mask respectively; The remote channel module is used to send the log to be processed to the remote log server if the log level matches the remote mask. The local channel module is configured to write the log to be processed into the current active buffer in memory if the log level matches the local mask; and when the current active buffer reaches the segmentation threshold, freeze the current active buffer as a read-only snapshot and create a new active buffer, compress the read-only snapshot into the current archive segment and write it into the archive slot of the persistent storage, and copy the continuous context at the end of the previous archive segment to the new active buffer.
9. An ONU gateway, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the log management method based on a PON network and an ONU gateway as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the log management method based on a PON network and an ONU gateway as described in any one of claims 1 to 7.
