Detailed Description
The present application is described in further detail below with reference to specific examples, but the present application is not limited thereto. In the following description, different "one embodiment" or "an embodiment" refers to not necessarily the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
The embodiment of the application provides a method for detecting traffic information by a virtual traffic survey station of a highway. Fig. 1 is a flow chart illustrating an embodiment of a method for accurately and controllably parsing and displaying protocol fields according to the present application. Referring to fig. 1, the method for accurately and controllably parsing and displaying the protocol field includes:
capturing a flow packet;
analyzing the flow packet layer by layer to obtain protocol information contained in the flow packet;
and displaying fields in the protocol information according to a preset rule.
In the method for accurately and controllably analyzing and displaying the protocol field, the flow packet is captured; analyzing the flow packet layer by layer to obtain protocol information contained in the flow packet; and displaying fields in the protocol information according to a preset rule. Only fields needing to be displayed can be displayed according to preset rules, and fields not needing to be displayed do not need to be displayed. The network transmission load is reduced, and the storage space is saved. The operation efficiency is improved.
In the embodiment of the application, the preset rule may be preset by the user according to needs. The preset rule may be set to display fields that the user needs to display, and not to display fields that do not need to be displayed. In some embodiments, referring to fig. 2, according to the preset rule, displaying the fields in the protocol information includes: fields registered in the protocol information are displayed. And displaying the corresponding field according to whether the field in the protocol information is registered or not. Only registered fields are displayed and unregistered fields are not displayed. The user can register the fields needing to be displayed in advance to realize the display requirement of the user.
In an exemplary embodiment, referring to fig. 2, displaying fields registered in the protocol information includes: judging whether each field in the protocol information is registered; if the field is registered, the registered field is displayed. In the embodiment of the application, whether each field in the protocol information is registered is judged, corresponding display is carried out according to the judgment result, and only the registered field is displayed. The unregistered field is not displayed.
In the embodiment of the application, the user can change the preset rule at any time. For example, fields are registered before displaying the fields registered in the protocol information. And displaying the fields in the protocol information according to the fields newly registered by the user.
In an exemplary embodiment, referring to fig. 3, the registration field includes:
reading a configuration file, wherein the format of the configuration file is a json character string;
converting the configuration file into a cjson object;
matching fields to be registered in the cjson object;
when the matching is successful, the field is registered.
In the embodiment of the application, the displayed fields can be controlled more flexibly.
Referring to fig. 3, the registration field further includes: the cjson object is destroyed.
In the embodiment of the application, when the matching fails, the field is not registered, and the cjson object is destroyed.
In the embodiment of the application, the cjson object is destroyed, so that the memory can be saved.
The embodiment of the application also provides a device for accurately and controllably analyzing and displaying the protocol field. The apparatus may implement the method of any of the embodiments described above. The following embodiments of the apparatus can be used for understanding the above-described method embodiments, which can also be used to explain the embodiments of the apparatus described below. Referring to fig. 4, the apparatus includes:
a grasping unit 10 for grasping a traffic packet;
the analysis unit 20 is configured to analyze the traffic packet layer by layer to obtain protocol information included in the traffic packet;
and a display unit 30 for displaying fields in the protocol information according to a preset rule.
In the device for accurately and controllably analyzing and displaying the protocol field provided by the embodiment of the application, the capturing unit 10 captures the flow packet; the analyzing unit 20 analyzes the traffic packet layer by layer to obtain protocol information included in the traffic packet; the display unit 30 displays fields in the protocol information according to a preset rule. Only fields needing to be displayed can be displayed according to preset rules, and fields not needing to be displayed do not need to be displayed. The network transmission load is reduced, and the storage space is saved. The operation efficiency is improved.
In the embodiment of the application, the preset rule may be preset by the user according to needs. The preset rule may be set to display fields that the user needs to display, and not to display fields that do not need to be displayed. In some embodiments, the display unit 30 displays fields registered in the protocol information. The display unit 30 displays a corresponding field according to whether the field in the protocol information is registered. The display unit 30 displays only registered fields and does not display unregistered fields. The user can register the fields needing to be displayed in advance to realize the display requirement of the user.
In an exemplary embodiment, the display unit 30 may include a judging module and a display module, where the judging module is configured to judge whether each field in the protocol information is registered; if the field is registered, the display module is used for displaying the registered field. In the embodiment of the application, the judging module judges whether each field in the protocol information is registered, the display module correspondingly displays according to the judging result, and the display module only displays the registered field. The unregistered field is not displayed.
In the embodiment of the application, the user can change the preset rule at any time. For example, a registration unit is also included. The registration unit is used to register fields before the display unit 30 displays the fields registered in the protocol information. The display unit 30 displays fields in the protocol information according to the fields newly registered by the user.
In an exemplary embodiment, the registration unit includes:
the reading module is used for reading a configuration file, and the format of the configuration file is a json character string;
a conversion module for converting the configuration file into a cjson object;
a matching module for matching fields to be registered in the cjson object;
and the registration module is used for registering the fields with successful matching when the matching is successful.
In the embodiment of the application, the displayed fields can be controlled more flexibly.
In some embodiments, the registration unit further comprises a destruction module: the destroying module is used for destroying the cjson object after the registration module registers the successfully matched field.
In an exemplary embodiment, when the matching fails, the registration module does not register the field and the destruction module destroys the cjson object.
In the embodiment of the application, the cjson object is destroyed, so that the memory can be saved.
It is obvious to those skilled in the art that the division of "unit" or "module" in the embodiments of the present application is only a division of one logic function, and there may be another division in actual implementation, for example, multiple "units" or "modules" may be combined or integrated into one "unit" or "module" to implement the corresponding functions. Or one "unit" or "module" is decomposed into a plurality of pieces to realize the corresponding functions together. The "unit" or "module" in the embodiments of the present application may be software and/or hardware that can perform a specific function independently or in cooperation with other components, where the hardware may be, for example, an FPGA (Field-Programmable Gate Array), an IC (Integrated Circuit), and the like, and details thereof are not repeated herein.
The embodiments of the present application also provide a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the steps of the method of any one of the foregoing embodiments. The computer-readable storage medium may include, but is not limited to, any type of disk including floppy disks, optical disks, DVD, CD-ROMs, microdrive, and magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic or optical cards, nano-devices (including molecular memory ICs), or any type of media or device suitable for storing instructions and/or data.
The embodiment of the present application further provides a terminal, which includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and when the processor executes the program, the steps of any of the above-mentioned embodiments of the method are implemented.
Fig. 5 shows a block diagram of a terminal according to an embodiment of the present application. Referring to fig. 5, the terminal includes a processor 510, a memory 520, a camera 530, and a microphone 540.
In this embodiment, the processor 510 is a control center of a computer system, and may be a processor of a physical machine or a processor of a virtual machine. In the embodiment of the present application, the memory 520 stores at least one instruction, and the instruction is loaded and executed by the processor 510 to implement the application control method in the above embodiments. The terminal in the embodiment of the present application includes, but is not limited to, a smart phone, a tablet computer, a laptop computer, and other devices.
In an alternative embodiment of the present application, the camera 530 may include a front camera and may also include a rear camera.
In alternative embodiments of the present application, the microphone 540 may be a first microphone and a second microphone. One of the first microphone and the second microphone may be a primary microphone for receiving sounds of a user's conversation, voice or recording activity, and the other microphone may be a secondary microphone for reducing noise in cooperation with the primary microphone.
Fig. 6 shows a block diagram of a terminal 600 according to another embodiment of the present application. Referring to fig. 6, the terminal 600 includes: a processor 601 and a memory 602.
The processor 601 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so on. The processor 601 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 601 may also include a main processor and a coprocessor, where the main processor is a processor for processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state.
The memory 602 may include one or more computer-readable storage media, which may be non-transitory. The memory 602 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments of the present application, a non-transitory computer readable storage medium in the memory 602 is used to store at least one instruction for execution by the processor 601 to implement the application control method in embodiments of the present application.
In an optional embodiment of the present application, the terminal 600 further includes: a peripheral interface 603 and at least one peripheral. The processor 601, memory 602, and peripheral interface 603 may be connected by buses or signal lines. Various peripheral devices may be connected to the peripheral interface 603 via a bus, signal line, or circuit board. Specifically, the peripheral device includes: at least one of a display screen 604, a camera 605, an audio circuit 606, and a power supply 607.
The peripheral interface 603 may be used to connect at least one peripheral related to I/O (Input/Output) to the processor 601 and the memory 602. In some embodiments of the present application, the processor 601, memory 602, and peripheral interface 603 are integrated on the same chip or circuit board; in some other embodiments of the present application, any one or both of the processor 601, the memory 602, and the peripheral interface 603 may be implemented on separate chips or circuit boards. The embodiment of the present application is not particularly limited to this.
The display screen 604 is used to display a UI (User Interface). The UI may include graphics, text, icons, video, and any combination thereof. When the display screen 604 is a touch display screen, the display screen 604 also has the ability to capture touch signals on or over the surface of the display screen 604. The touch signal may be input to the processor 601 as a control signal for processing. At this point, the display screen 604 may also be used to provide virtual buttons and/or a virtual keyboard, also referred to as soft buttons and/or a soft keyboard. In some embodiments of the present application, the display screen 604 may be one, and is provided as a front panel of the terminal 600; in other embodiments of the present application, the display screens 604 may be at least two, respectively disposed on different surfaces of the terminal 600 or in a folding design; in still other embodiments of the present application, the display 604 may be a flexible display disposed on a curved surface or a folded surface of the terminal 600. Even further, the display screen 604 may be arranged in a non-rectangular irregular pattern, i.e. a shaped screen. The Display screen 604 may be made of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), and the like.
The camera 605 is used to capture images or video. Optionally, the camera 605 includes a front camera and a rear camera. Generally, a front camera is disposed at a front panel of the terminal, and a rear camera is disposed at a rear surface of the terminal. In some embodiments, the number of the rear cameras is at least two, and each rear camera is any one of a main camera, a depth-of-field camera, a wide-angle camera and a telephoto camera, so that the main camera and the depth-of-field camera are fused to realize a background blurring function, and the main camera and the wide-angle camera are fused to realize panoramic shooting and VR (Virtual Reality) shooting functions or other fusion shooting functions. In some embodiments of the present application, camera 605 may also include a flash. The flash lamp can be a monochrome temperature flash lamp or a bicolor temperature flash lamp. The double-color-temperature flash lamp is a combination of a warm-light flash lamp and a cold-light flash lamp, and can be used for light compensation at different color temperatures.
Audio circuitry 606 may include a microphone and a speaker. The microphone is used for collecting sound waves of a user and the environment, converting the sound waves into electric signals, and inputting the electric signals to the processor 601 for processing. For the purpose of stereo sound collection or noise reduction, a plurality of microphones may be provided at different portions of the terminal 600. The microphone may also be an array microphone or an omni-directional pick-up microphone.
Power supply 607 is used to provide power to the various components in terminal 600. The power supply 607 may be ac, dc, disposable or rechargeable. When power supply 607 includes a rechargeable battery, the rechargeable battery may be a wired rechargeable battery or a wireless rechargeable battery. The wired rechargeable battery is a battery charged through a wired line, and the wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery may also be used to support fast charge technology.
The block diagram of the terminal structure shown in the embodiments of the present application does not constitute a limitation to the terminal 600, and the terminal 600 may include more or less components than those shown, or combine some components, or adopt a different arrangement of components.
In this application, the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or order; the term "plurality" means two or more unless expressly limited otherwise. The terms "mounted," "connected," "fixed," and the like are to be construed broadly, and for example, "connected" may be a fixed connection, a removable connection, or an integral connection; "coupled" may be direct or indirect through an intermediary. The specific meaning of the above terms in the present application can be understood by those of ordinary skill in the art as appropriate.
In the description of the present application, it is to be understood that the terms "upper", "lower", and the like indicate orientations or positional relationships based on those shown in the drawings, and are only for convenience in describing the present application and simplifying the description, but do not indicate or imply that the referred device or unit must have a specific direction, be configured and operated in a specific orientation, and thus, should not be construed as limiting the present application.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.