CN111666109A - Method and system for optimizing automatic scanning speed of local area network CIFS (common information platform) sharing equipment - Google Patents

Method and system for optimizing automatic scanning speed of local area network CIFS (common information platform) sharing equipment Download PDF

Info

Publication number
CN111666109A
CN111666109A CN202010515298.5A CN202010515298A CN111666109A CN 111666109 A CN111666109 A CN 111666109A CN 202010515298 A CN202010515298 A CN 202010515298A CN 111666109 A CN111666109 A CN 111666109A
Authority
CN
China
Prior art keywords
scanning
address
thread
threads
equipment
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.)
Granted
Application number
CN202010515298.5A
Other languages
Chinese (zh)
Other versions
CN111666109B (en
Inventor
赵文娴
刘广宾
郝成
李尧彦
邓晓天
彭琳
谢绍强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Original Assignee
Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan Happly Sunshine Interactive Entertainment Media Co Ltd filed Critical Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Priority to CN202010515298.5A priority Critical patent/CN111666109B/en
Publication of CN111666109A publication Critical patent/CN111666109A/en
Application granted granted Critical
Publication of CN111666109B publication Critical patent/CN111666109B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4416Network booting; Remote initial program loading [RIPL]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses

Abstract

The invention discloses a method and a system for optimizing the automatic scanning speed of a local area network CIFS (common information system) sharing device, wherein the method comprises the following steps: calculating the total number M of all IP addresses and the initial IP address a of the current local area network segment, and adaptively setting the number N of automatically scanned threads based on the performance parameters of the equipment; setting a priority scanning IP address list based on the initial IP address a and the thread number N of automatic scanning; calculating the number L of scanning IP tasks which need to be evenly distributed by each thread; based on the number N of the threads to be automatically scanned and the number L of scanning IP tasks which need to be evenly distributed for each thread, initially setting a scanning IP two-dimensional array of each scanning thread; adjusting the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list; judging whether the current network segment has history sharing equipment, if not: and starting N scanning threads, and scanning the IP addresses in the adjusted two-dimensional array one by one. The invention can effectively shorten the time for determining the sharing equipment.

Description

Method and system for optimizing automatic scanning speed of local area network CIFS (common information platform) sharing equipment
Technical Field
The invention relates to the technical field of local area network sharing, in particular to a method and a System for optimizing the automatic scanning speed of a local area network CIFS (common Internet File System) sharing device.
Background
At present, on an intelligent terminal based on an Android operating system platform, for a file browser application supporting access to network file sharing based on a CIFS protocol, the application usually scans all IP addresses in a network segment where a local area network is located automatically through multithreading traversal scanning to discover all sharing devices. Therefore, the existing scanning mode is to scan all IP addresses in the network segment where the current local area network is located by adopting a fixed scanning mode, and a long time is needed when the shared device is determined.
Therefore, how to shorten the time for determining the shared device is an urgent problem to be solved.
Disclosure of Invention
In view of this, the present invention provides a method for optimizing an automatic scanning speed of a local area network CIFS sharing device, which can adaptively set a scanning mode, and effectively shorten a time for determining the sharing device.
The invention provides a method for optimizing the automatic scanning speed of a local area network CIFS (common information system) sharing device, which comprises the following steps:
acquiring a local area network IP address of the current device;
calculating the total number M of all IP addresses and the initial IP address a of the current local area network segment based on the local area network IP address;
acquiring performance parameters of equipment;
setting the thread number N of automatic scanning in a self-adaptive manner based on the performance parameters of the equipment;
setting a priority scanning IP address list based on the initial IP address a and the thread number N of the automatic scanning;
calculating the number L of scanning IP tasks which need to be evenly distributed by each thread based on the total number M of all IP addresses of the current local area network segment and the number N of the automatically scanned threads;
based on the number N of the automatically scanned threads and the number L of the scanning IP tasks which need to be evenly distributed by each thread, initially setting a scanning IP two-dimensional array of each scanning thread;
adjusting the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list;
judging whether the current network segment has history sharing equipment, if not, then:
and starting N scanning threads, and scanning the IP addresses in the adjusted two-dimensional array one by one.
Preferably, the method further comprises:
and when the current network segment has the history sharing equipment, adjusting the scanning IP two-dimensional array of each scanning thread based on the IP address of the history sharing equipment.
Preferably, the method further comprises:
displaying the accessible IP address obtained by scanning;
and after all the threads are scanned in a traversing way, storing all the accessible IP addresses obtained by scanning into a database.
Preferably, the adaptively setting the number of threads for automatic scanning based on the performance parameter of the device includes:
judging whether the equipment is low-performance equipment or not based on the performance parameters of the equipment, if so, setting the thread number of automatic scanning as 16 threads, and if not,:
the number of threads for auto-scan is set to 32 threads.
Preferably, the calculating the number L of scanning IP tasks that each thread needs to be evenly allocated based on the total number M of all IP addresses of the current lan segment and the number N of threads of the automatic scanning includes:
and calculating the number L of scanning IP tasks which are required to be evenly distributed by each thread based on a formula L [ (M-1)/N ] +1, wherein M is the total number of all IP addresses of the current LAN segment, and N is the number of threads which are automatically scanned.
A system for optimizing the automatic scanning speed of a local area network CIFS shared device comprises the following components:
the first acquisition module is used for acquiring the IP address of the local area network where the equipment is currently located;
the first calculation module is used for calculating the total number M of all IP addresses and the initial IP address a of the current local area network segment based on the local area network IP address;
the second acquisition module is used for acquiring the performance parameters of the equipment;
the setting module is used for adaptively setting the thread number N of automatic scanning based on the performance parameters of the equipment;
the first setting module is used for setting a priority scanning IP address list based on the initial IP address a and the thread number N of the automatic scanning;
the second calculation module is used for calculating the number L of scanning IP tasks which need to be evenly distributed by each thread based on the total number M of all IP addresses of the current local area network segment and the number N of the automatically scanned threads;
a second setting module, configured to initially set a scanning IP two-dimensional array of each scanning thread based on the number N of threads to be automatically scanned and the number L of scanning IP tasks that each thread needs to be evenly distributed;
the first adjusting module is used for adjusting the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list;
the judging module is used for judging whether the current network segment has history sharing equipment;
and the scanning module is used for starting N scanning threads and scanning the IP addresses in the adjusted two-dimensional array one by one.
Preferably, the system further comprises:
and the second adjusting module is used for adjusting the scanning IP two-dimensional array of each scanning thread based on the IP address of the history sharing equipment when the history sharing equipment exists in the current network segment.
Preferably, the system further comprises:
the display module is used for displaying the accessible IP address obtained by scanning;
and the storage module is used for storing all the accessible IP addresses obtained by scanning to the database after all the threads are traversed and scanned.
Preferably, the setting module is specifically configured to:
judging whether the equipment is low-performance equipment or not based on the performance parameters of the equipment, if so, setting the thread number of automatic scanning as 16 threads, and if not,:
the number of threads for auto-scan is set to 32 threads.
Preferably, the second calculation module is specifically configured to:
and calculating the number L of scanning IP tasks which are required to be evenly distributed by each thread based on a formula L [ (M-1)/N ] +1, wherein M is the total number of all IP addresses of the current LAN segment, and N is the number of threads which are automatically scanned.
In summary, the present invention discloses a method for optimizing the automatic scanning speed of a local area network CIFS sharing device, when the automatic scanning speed of the local area network CIFS sharing device needs to be optimized, obtaining the network IP address of the local area network where the device is currently located, and calculating the total number M of all the IP addresses and the initial IP address a of the current network segment of the local area network based on the network IP address of the local area network; acquiring performance parameters of equipment, and setting the thread number N of automatic scanning in a self-adaptive manner based on the performance parameters of the equipment; setting a priority scanning IP address list based on the initial IP address a and the number N of automatically scanned threads, and calculating the number L of scanning IP tasks which need to be evenly distributed by each thread based on the total number M of all IP addresses of the current local area network segment and the number N of automatically scanned threads; based on the number N of the threads to be automatically scanned and the number L of scanning IP tasks which need to be evenly distributed for each thread, initially setting a scanning IP two-dimensional array of each scanning thread; adjusting the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list, judging whether the current network segment has history sharing equipment, if not, then: and starting N scanning threads, and scanning the IP addresses in the adjusted two-dimensional array one by one. In the intelligent hardware equipment based on the Android system platform, a set of algorithm can be set according to the CPU configuration condition of the equipment, the current connected home office network IP address allocation condition and the historical scanning equipment IP address condition, and the number of scanning threads, the priority scanning IP address list and the arrangement sequence of the IP addresses are determined in a self-adaptive manner, so that all IP addresses in the current network environment are scanned quickly and effectively, and the intelligent sharing equipment which can be shared in a local area network is obtained.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a method of embodiment 1 of the method for optimizing an automatic scanning speed of a local area network CIFS sharing device disclosed in the present invention;
fig. 2 is a flowchart of a method of embodiment 2 of the method for optimizing an automatic scanning speed of a local area network CIFS sharing device disclosed in the present invention;
fig. 3 is a schematic structural diagram of an embodiment 1 of a system for optimizing an automatic scanning speed of a local area network CIFS sharing device according to the present invention;
fig. 4 is a schematic structural diagram of an embodiment 2 of a system for optimizing an automatic scanning speed of a local area network CIFS sharing device disclosed in the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, which is a flowchart of a method of embodiment 1 of the method for optimizing an automatic scanning speed of a local area network CIFS sharing device disclosed in the present invention, the method may include the following steps:
s101, acquiring a local area network IP address of the equipment at present;
when the automatic scanning speed of the local area network CIFS shared equipment needs to be optimized, the IP address of the local area network where the current equipment is located is obtained.
S102, calculating the total number M of all IP addresses and an initial IP address a of the current local area network segment based on the local area network IP address;
after the local area network IP address where the equipment is located currently is obtained, calculating the total number M of all IP addresses and an initial IP address a of the current network segment according to the IP address of the current equipment; for example, if the current IP address is 192.168.1.105, the total number of the current local area network IP addresses is 255, and the starting IP address is 192.168.1.1.
S103, acquiring performance parameters of the equipment;
meanwhile, performance parameters of the equipment are obtained. For example, CPU configuration information of the device is obtained.
S104, setting the thread number N of automatic scanning in a self-adaptive manner based on the performance parameters of the equipment;
after the performance parameters of the equipment are obtained, the number N of the threads of the automatic scanning is further set in a self-adaptive mode according to the performance parameters of the equipment.
Specifically, after the performance parameters of the device are obtained, it is further determined whether the device is a low-performance device according to the performance parameters of the device, where when the device is a low-performance device, the set number N of auto-scan lines is 16, and when the device is not a low-performance device, for example, when the device is a high-interruption device, the set number N of auto-scan lines is 16, 2, 32.
S105, setting a priority scanning IP address list based on the initial IP address a and the thread number N of automatic scanning;
meanwhile, the priority scanning IP address list set according to the starting IP address a and the thread number N of the auto scanning is [ a +100, a +100+ N-1 ]. For example, if the current device is a low-end device and the IP address of the current device is 192.168.1.105, N is set to 16, and the priority scanning IP address range is [192.168.1.100,192.168.1.115 ].
S106, calculating the number L of scanning IP tasks which need to be evenly distributed by each thread based on the total number M of all IP addresses of the current local area network segment and the number N of automatically scanned threads;
and meanwhile, calculating the number L of scanning IP tasks which are required to be evenly distributed by each thread according to the total number M of all IP addresses of the current local area network segment and the number N of the automatically scanned threads. Specifically, the calculation formula is as follows: l ═ [ (M-1)/N ] + 1. It should be noted that, when calculating the number L of scanning IP tasks that need to be equally allocated to each thread, it is necessary to ensure that the multi-thread request synchronizes the sequential requests of the IP addresses as much as possible, that is, it is necessary to ensure that the IP addresses of the single scanning thread are discontinuous.
S107, based on the number N of the threads which are automatically scanned and the number L of the scanning IP tasks which are required to be evenly distributed by each thread, initially setting a scanning IP two-dimensional array of each scanning thread;
initializing an array list to range [ N ] [ L ], that is, respectively allocating L { [ (M-1)/N ] +1} scanning IP address arrays to the N threads, and paying attention to the two-dimensional component's' font arrangement, that is, ensuring that the scanning addresses are sequentially increased after the N threads start scanning synchronously, for example, when M ═ 255 and N ═ 16, the two-dimensional array structure is range [16] [16], and the specific arrangement is as follows:
the scan address assigned to the 1 st scan thread is [1,17, 33.., 241]
The scan address assigned to the 2 nd scan thread is [2,18, 34.. 242]
The scan address assigned to the 5 th scan thread is [5,22,38, …,245]
The scan address assigned to the 16 th scan thread is [16,32,48, …,256 ].
S108, adjusting the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list;
then, the scan IP two-dimensional array list is adjusted according to the priority scan IP address list, for example, the priority scan array is [192.168.1.100,192.168.1.115], and then the arrays are arranged as follows after being adjusted:
the scan address assigned to the 1 st scan thread is [113,1,17,33,.. times.241 ]
The scan address assigned to the 2 nd scan thread is [114,2,18, 34.., 242]
The scan address allocated to the 5 th scan thread is [100,5,21,38, …,245]
The 16 th scan thread is assigned a scan address of [112,16,32,48, …,256 ].
S109, judging whether the current network segment has history sharing equipment, if not, entering S110:
and inquiring whether historical sharing equipment exists at present or not, and whether the IP address of the historical sharing equipment and the IP address of the current network segment belong to the same network segment or not.
S110, starting N scanning threads, and scanning the IP addresses in the adjusted two-dimensional array one by one.
And when the current network segment has no history sharing equipment, starting N scanning threads, and scanning the IP addresses in the two-dimensional array after the scanning IP two-dimensional array of each scanning thread is adjusted based on the priority scanning IP address list one by one.
In summary, in the above embodiments, when the automatic scanning speed of the local area network CIFS sharing device needs to be optimized, the local area network IP address where the device is currently located is obtained, and the total number M of all IP addresses and the starting IP address a of the current local area network segment are calculated based on the local area network IP address; acquiring performance parameters of equipment, and setting the thread number N of automatic scanning in a self-adaptive manner based on the performance parameters of the equipment; setting a priority scanning IP address list based on the initial IP address a and the number N of automatically scanned threads, and calculating the number L of scanning IP tasks which need to be evenly distributed by each thread based on the total number M of all IP addresses of the current local area network segment and the number N of automatically scanned threads; based on the number N of the threads to be automatically scanned and the number L of scanning IP tasks which need to be evenly distributed for each thread, initially setting a scanning IP two-dimensional array of each scanning thread; adjusting the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list, judging whether the current network segment has history sharing equipment, if not, then: and starting N scanning threads, and scanning the IP addresses in the adjusted two-dimensional array one by one. In the intelligent hardware equipment based on the Android system platform, a set of algorithm can be set according to the CPU configuration condition of the equipment, the current connected home office network IP address allocation condition and the historical scanning equipment IP address condition, and the number of scanning threads, the priority scanning IP address list and the arrangement sequence of the IP addresses are determined in a self-adaptive mode, so that all IP addresses in the current network environment are scanned quickly and effectively, and the intelligent sharing equipment which can be shared in a local area network is obtained.
As shown in fig. 2, which is a flowchart of a method of embodiment 2 of the method for optimizing an automatic scanning speed of a local area network CIFS sharing device disclosed in the present invention, the method may include the following steps:
s201, acquiring a local area network IP address of the equipment at present;
when the automatic scanning speed of the local area network CIFS shared equipment needs to be optimized, the IP address of the local area network where the current equipment is located is obtained.
S202, calculating the total number M of all IP addresses and an initial IP address a of the current local area network segment based on the local area network IP address;
after the local area network IP address where the equipment is located currently is obtained, calculating the total number M of all IP addresses and an initial IP address a of the current network segment according to the IP address of the current equipment; for example, if the current IP address is 192.168.1.105, the total number of the current local area network IP addresses is 255, and the starting IP address is 192.168.1.1.
S203, acquiring performance parameters of the equipment;
meanwhile, performance parameters of the equipment are obtained. For example, CPU configuration information of the device is obtained.
S204, setting the thread number N of automatic scanning in a self-adaptive manner based on the performance parameters of the equipment;
after the performance parameters of the equipment are obtained, the number N of the threads of the automatic scanning is further set in a self-adaptive mode according to the performance parameters of the equipment.
Specifically, after the performance parameters of the device are obtained, it is further determined whether the device is a low-performance device according to the performance parameters of the device, where when the device is a low-performance device, the set number N of auto-scan lines is 16, and when the device is not a low-performance device, for example, when the device is a high-interruption device, the set number N of auto-scan lines is 16, 2, 32.
S205, setting a priority scanning IP address list based on the initial IP address a and the thread number N of automatic scanning;
meanwhile, the priority scanning IP address list set according to the starting IP address a and the thread number N of the auto scanning is [ a +100, a +100+ N-1 ]. For example, if the current device is a low-end device and the IP address of the current device is 192.168.1.105, N is set to 16, and the priority scanning IP address range is [192.168.1.100,192.168.1.115 ].
S206, calculating the number L of scanning IP tasks which need to be evenly distributed by each thread based on the total number M of all IP addresses of the current local area network segment and the number N of automatically scanned threads;
and meanwhile, calculating the number L of scanning IP tasks which are required to be evenly distributed by each thread according to the total number M of all IP addresses of the current local area network segment and the number N of the automatically scanned threads. Specifically, the calculation formula is as follows: l ═ [ (M-1)/N ] + 1. It should be noted that, when calculating the number L of scanning IP tasks that need to be equally allocated to each thread, it is necessary to ensure that the multi-thread request synchronizes the sequential requests of the IP addresses as much as possible, that is, it is necessary to ensure that the IP addresses of the single scanning thread are discontinuous.
S207, based on the number N of the threads which are automatically scanned and the number L of the scanning IP tasks which are required to be evenly distributed by each thread, initially setting a scanning IP two-dimensional array of each scanning thread;
initializing an array list to range [ N ] [ L ], that is, respectively allocating L { [ (M-1)/N ] +1} scanning IP address arrays to the N threads, and paying attention to the two-dimensional component's' font arrangement, that is, ensuring that the scanning addresses are sequentially increased after the N threads start scanning synchronously, for example, when M ═ 255 and N ═ 16, the two-dimensional array structure is range [16] [16], and the specific arrangement is as follows:
the scan address assigned to the 1 st scan thread is [1,17, 33.., 241]
The scan address assigned to the 2 nd scan thread is [2,18, 34.. 242]
The scan address assigned to the 5 th scan thread is [5,22,38, …,245]
The scan address assigned to the 16 th scan thread is [16,32,48, …,256 ].
S208, adjusting the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list;
then, the scan IP two-dimensional array list is adjusted according to the priority scan IP address list, for example, the priority scan array is [192.168.1.100,192.168.1.115], and then the arrays are arranged as follows after being adjusted:
the scan address assigned to the 1 st scan thread is [113,1,17,33,.. times.241 ]
The scan address assigned to the 2 nd scan thread is [114,2,18, 34.., 242]
The scan address allocated to the 5 th scan thread is [100,5,21,38, …,245]
The 16 th scan thread is assigned a scan address of [112,16,32,48, …,256 ].
S209, judging whether the current network segment has history sharing equipment, if so, entering S210:
and inquiring whether historical sharing equipment exists at present or not, and whether the IP address of the historical sharing equipment and the IP address of the current network segment belong to the same network segment or not.
S210, adjusting the scanning IP two-dimensional array of each scanning thread based on the historical sharing device IP address;
inquiring whether a history sharing device exists at present, if the history sharing device exists, the IP address of the history sharing device and the current IP address belong to the same network segment, and the history sharing device does not belong to the determined priority scanning IP address list range, then adjusting the scanning array where the history device IP address is located, if the history device IP address is b, the scanning array needing to be jumped is range [ (b-a)% N +1], otherwise, skipping the step, for example, if the history device IP address is 192.168.121, adjusting the 5 th thread scanning IP array list as follows:
the scan address assigned to the 5 th scan thread is [21,100,5,38, …,245 ].
S211, starting N scanning threads, and scanning the IP addresses in the adjusted two-dimensional array one by one;
then, N threads start to start synchronously, and start to scan the ip addresses in the adjusted two-dimensional array one by one, and the single scanning method is to directly use an Nbtaddress.
S212, displaying the accessible IP address obtained by scanning;
in the scanning process, if the accessible IP address is scanned, the scanned accessible IP address is displayed, namely, the shared device list page is refreshed in real time.
And S213, after all the threads are scanned in a traversing manner, storing all the accessible IP addresses obtained by scanning into a database.
And after all the threads are scanned in a traversing way, storing all the accessible IP addresses obtained by scanning into a database.
Experimental data shows that a local area network is built by using a MERCURYMW315R router, a terminal adopts a NunaiM1 box (rk3229) local file manager application, if 16 threads are set, IP addresses are sequentially distributed to each thread, the scanning time of the current whole network segment is 35 seconds, the time of finding all accessible devices is 16 seconds, the time of finding all accessible devices is 10 seconds by adopting the method for optimizing the automatic scanning speed of the local area network CIFS shared device, and the time of finding all accessible devices is 1 second.
In summary, the present invention provides a method for automatically traversing CIFS shared network devices in priority levels in a manner of self-adapting to the performance condition of the current device and the current local area network environment, so as to reduce the scanning time of all devices in the current local area network segment, and preferentially scan and display the most likely shared network devices, thereby further reducing the waiting time for a user to access the network shared device through the intelligent terminal.
As shown in fig. 3, which is a schematic structural diagram of an embodiment 1 of a system for optimizing an automatic scanning speed of a local area network CIFS sharing device disclosed in the present invention, the system may include:
a first obtaining module 301, configured to obtain a local area network IP address where a device is currently located;
when the automatic scanning speed of the local area network CIFS shared equipment needs to be optimized, the IP address of the local area network where the current equipment is located is obtained.
A first calculating module 302, configured to calculate, based on the local area network IP address, a total number M of all IP addresses and a starting IP address a of a current local area network segment;
after the local area network IP address where the equipment is located currently is obtained, calculating the total number M of all IP addresses and an initial IP address a of the current network segment according to the IP address of the current equipment; for example, if the current IP address is 192.168.1.105, the total number of the current local area network IP addresses is 255, and the starting IP address is 192.168.1.1.
A second obtaining module 303, configured to obtain a performance parameter of the device;
meanwhile, performance parameters of the equipment are obtained. For example, CPU configuration information of the device is obtained.
A setting module 304, configured to adaptively set a thread number N of the automatic scanning based on a performance parameter of the device;
after the performance parameters of the equipment are obtained, the number N of the threads of the automatic scanning is further set in a self-adaptive mode according to the performance parameters of the equipment.
Specifically, after the performance parameters of the device are obtained, it is further determined whether the device is a low-performance device according to the performance parameters of the device, where when the device is a low-performance device, the set number N of auto-scan lines is 16, and when the device is not a low-performance device, for example, when the device is a high-interruption device, the set number N of auto-scan lines is 16, 2, 32.
A first setting module 305, configured to set a priority scanning IP address list based on the starting IP address a and the thread number N of the auto scanning;
meanwhile, the priority scanning IP address list set according to the starting IP address a and the thread number N of the auto scanning is [ a +100, a +100+ N-1 ]. For example, if the current device is a low-end device and the IP address of the current device is 192.168.1.105, N is set to 16, and the priority scanning IP address range is [192.168.1.100,192.168.1.115 ].
A second calculating module 306, configured to calculate, based on the total number M of all IP addresses of the current lan segment and the number N of automatically scanned threads, the number L of scanning IP tasks that each thread needs to be evenly allocated;
and meanwhile, calculating the number L of scanning IP tasks which are required to be evenly distributed by each thread according to the total number M of all IP addresses of the current local area network segment and the number N of the automatically scanned threads. Specifically, the calculation formula is as follows: l ═ [ (M-1)/N ] + 1. It should be noted that, when calculating the number L of scanning IP tasks that need to be equally allocated to each thread, it is necessary to ensure that the multi-thread request synchronizes the sequential requests of the IP addresses as much as possible, that is, it is necessary to ensure that the IP addresses of the single scanning thread are discontinuous.
A second setting module 307, configured to initially set a scanning IP two-dimensional array of each scanning thread based on the number N of threads to be automatically scanned and the number L of scanning IP tasks that each thread needs to be evenly allocated;
initializing an array list to range [ N ] [ L ], that is, respectively allocating L { [ (M-1)/N ] +1} scanning IP address arrays to the N threads, and paying attention to the two-dimensional component's' font arrangement, that is, ensuring that the scanning addresses are sequentially increased after the N threads start scanning synchronously, for example, when M ═ 255 and N ═ 16, the two-dimensional array structure is range [16] [16], and the specific arrangement is as follows:
the scan address assigned to the 1 st scan thread is [1,17, 33.., 241]
The scan address assigned to the 2 nd scan thread is [2,18, 34.. 242]
The scan address assigned to the 5 th scan thread is [5,22,38, …,245]
The scan address assigned to the 16 th scan thread is [16,32,48, …,256 ].
A first adjusting module 308, configured to adjust the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list;
then, the scan IP two-dimensional array list is adjusted according to the priority scan IP address list, for example, the priority scan array is [192.168.1.100,192.168.1.115], and then the arrays are arranged as follows after being adjusted:
the scan address assigned to the 1 st scan thread is [113,1,17,33,.. times.241 ]
The scan address assigned to the 2 nd scan thread is [114,2,18, 34.., 242]
The scan address allocated to the 5 th scan thread is [100,5,21,38, …,245]
The 16 th scan thread is assigned a scan address of [112,16,32,48, …,256 ].
A judging module 309, configured to judge whether a current network segment has a history sharing device;
and inquiring whether historical sharing equipment exists at present or not, and whether the IP address of the historical sharing equipment and the IP address of the current network segment belong to the same network segment or not.
The scanning module 310 is configured to start N scanning threads, and start scanning the adjusted IP addresses in the two-dimensional array one by one.
And when the current network segment has no history sharing equipment, starting N scanning threads, and scanning the IP addresses in the two-dimensional array after the scanning IP two-dimensional array of each scanning thread is adjusted based on the priority scanning IP address list one by one.
In summary, in the above embodiments, when the automatic scanning speed of the local area network CIFS sharing device needs to be optimized, the local area network IP address where the device is currently located is obtained, and the total number M of all IP addresses and the starting IP address a of the current local area network segment are calculated based on the local area network IP address; acquiring performance parameters of equipment, and setting the thread number N of automatic scanning in a self-adaptive manner based on the performance parameters of the equipment; setting a priority scanning IP address list based on the initial IP address a and the number N of automatically scanned threads, and calculating the number L of scanning IP tasks which need to be evenly distributed by each thread based on the total number M of all IP addresses of the current local area network segment and the number N of automatically scanned threads; based on the number N of the threads to be automatically scanned and the number L of scanning IP tasks which need to be evenly distributed for each thread, initially setting a scanning IP two-dimensional array of each scanning thread; adjusting the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list, judging whether the current network segment has history sharing equipment, if not, then: and starting N scanning threads, and scanning the IP addresses in the adjusted two-dimensional array one by one. In the intelligent hardware equipment based on the Android system platform, a set of algorithm can be set according to the CPU configuration condition of the equipment, the current connected home office network IP address allocation condition and the historical scanning equipment IP address condition, and the number of scanning threads, the priority scanning IP address list and the arrangement sequence of the IP addresses are determined in a self-adaptive mode, so that all IP addresses in the current network environment are scanned quickly and effectively, and the intelligent sharing equipment which can be shared in a local area network is obtained.
As shown in fig. 4, which is a schematic structural diagram of an embodiment 2 of a system for optimizing an automatic scanning speed of a local area network CIFS sharing device disclosed in the present invention, the system may include:
a first obtaining module 401, configured to obtain a local area network IP address where the device is currently located;
when the automatic scanning speed of the local area network CIFS shared equipment needs to be optimized, the IP address of the local area network where the current equipment is located is obtained.
A first calculating module 402, configured to calculate, based on the local area network IP address, a total number M of all IP addresses and a starting IP address a of a current local area network segment;
after the local area network IP address where the equipment is located currently is obtained, calculating the total number M of all IP addresses and an initial IP address a of the current network segment according to the IP address of the current equipment; for example, if the current IP address is 192.168.1.105, the total number of the current local area network IP addresses is 255, and the starting IP address is 192.168.1.1.
A second obtaining module 403, configured to obtain performance parameters of the device;
meanwhile, performance parameters of the equipment are obtained. For example, CPU configuration information of the device is obtained.
A setting module 404, configured to adaptively set a thread number N of the automatic scanning based on a performance parameter of the device;
after the performance parameters of the equipment are obtained, the number N of the threads of the automatic scanning is further set in a self-adaptive mode according to the performance parameters of the equipment.
Specifically, after the performance parameters of the device are obtained, it is further determined whether the device is a low-performance device according to the performance parameters of the device, where when the device is a low-performance device, the set number N of auto-scan lines is 16, and when the device is not a low-performance device, for example, when the device is a high-interruption device, the set number N of auto-scan lines is 16, 2, 32.
A first setting module 405, configured to set a priority scanning IP address list based on the initial IP address a and the thread number N of the auto scanning;
meanwhile, the priority scanning IP address list set according to the starting IP address a and the thread number N of the auto scanning is [ a +100, a +100+ N-1 ]. For example, if the current device is a low-end device and the IP address of the current device is 192.168.1.105, N is set to 16, and the priority scanning IP address range is [192.168.1.100,192.168.1.115 ].
A second calculating module 406, configured to calculate, based on the total number M of all IP addresses of the current lan segment and the number N of automatically scanned threads, the number L of scanning IP tasks that each thread needs to be evenly allocated;
and meanwhile, calculating the number L of scanning IP tasks which are required to be evenly distributed by each thread according to the total number M of all IP addresses of the current local area network segment and the number N of the automatically scanned threads. Specifically, the calculation formula is as follows: l ═ [ (M-1)/N ] + 1. It should be noted that, when calculating the number L of scanning IP tasks that need to be equally allocated to each thread, it is necessary to ensure that the multi-thread request synchronizes the sequential requests of the IP addresses as much as possible, that is, it is necessary to ensure that the IP addresses of the single scanning thread are discontinuous.
A second setting module 407, configured to initially set a scanning IP two-dimensional array of each scanning thread based on the number N of threads to be automatically scanned and the number L of scanning IP tasks that each thread needs to be evenly allocated;
initializing an array list to range [ N ] [ L ], that is, respectively allocating L { [ (M-1)/N ] +1} scanning IP address arrays to the N threads, and paying attention to the two-dimensional component's' font arrangement, that is, ensuring that the scanning addresses are sequentially increased after the N threads start scanning synchronously, for example, when M ═ 255 and N ═ 16, the two-dimensional array structure is range [16] [16], and the specific arrangement is as follows:
the scan address assigned to the 1 st scan thread is [1,17, 33.., 241]
The scan address assigned to the 2 nd scan thread is [2,18, 34.. 242]
The scan address assigned to the 5 th scan thread is [5,22,38, …,245]
The scan address assigned to the 16 th scan thread is [16,32,48, …,256 ].
A first adjusting module 408, configured to adjust the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list;
then, the scan IP two-dimensional array list is adjusted according to the priority scan IP address list, for example, the priority scan array is [192.168.1.100,192.168.1.115], and then the arrays are arranged as follows after being adjusted:
the scan address assigned to the 1 st scan thread is [113,1,17,33,.. times.241 ]
The scan address assigned to the 2 nd scan thread is [114,2,18, 34.., 242]
The scan address allocated to the 5 th scan thread is [100,5,21,38, …,245]
The 16 th scan thread is assigned a scan address of [112,16,32,48, …,256 ].
A judging module 409, configured to judge whether a current network segment has a history sharing device;
and inquiring whether historical sharing equipment exists at present or not, and whether the IP address of the historical sharing equipment and the IP address of the current network segment belong to the same network segment or not.
A second adjusting module 410, configured to adjust the scanning IP two-dimensional array of each scanning thread based on the historical shared device IP address;
inquiring whether a history sharing device exists at present, if the history sharing device exists, the IP address of the history sharing device and the current IP address belong to the same network segment, and the history sharing device does not belong to the determined priority scanning IP address list range, then adjusting the scanning array where the history device IP address is located, if the history device IP address is b, the scanning array needing to be jumped is range [ (b-a)% N +1], otherwise, skipping the step, for example, if the history device IP address is 192.168.121, adjusting the 5 th thread scanning IP array list as follows:
the scan address assigned to the 5 th scan thread is [21,100,5,38, …,245 ].
The scanning module 411 is configured to start N scanning threads, and start scanning the adjusted IP addresses in the two-dimensional array one by one;
then, N threads start to start synchronously, and start to scan the ip addresses in the adjusted two-dimensional array one by one, and the single scanning method is to directly use an Nbtaddress.
A display module 412, configured to display the accessible IP address obtained by scanning;
in the scanning process, if the accessible IP address is scanned, the scanned accessible IP address is displayed, namely, the shared device list page is refreshed in real time.
And a saving module 413, configured to save, after all the threads traverse and scan, all the accessible IP addresses obtained by scanning to the database.
And after all the threads are scanned in a traversing way, storing all the accessible IP addresses obtained by scanning into a database.
Experimental data shows that a local area network is built by using a MERCURYMW315R router, a terminal adopts a NunaiM1 box (rk3229) local file manager application, if 16 threads are set, IP addresses are sequentially distributed to each thread, the scanning time of the current whole network segment is 35 seconds, the time of finding all accessible devices is 16 seconds, the time of finding all accessible devices is 10 seconds by adopting the method for optimizing the automatic scanning speed of the local area network CIFS shared device, and the time of finding all accessible devices is 1 second.
In summary, the present invention provides a method for automatically traversing CIFS shared network devices in priority levels in a manner of self-adapting to the performance condition of the current device and the current local area network environment, so as to reduce the scanning time of all devices in the current local area network segment, and preferentially scan and display the most likely shared network devices, thereby further reducing the waiting time for a user to access the network shared device through the intelligent terminal.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for optimizing the automatic scanning speed of a local area network CIFS shared device is characterized by comprising the following steps:
acquiring a local area network IP address of the current device;
calculating the total number M of all IP addresses and the initial IP address a of the current local area network segment based on the local area network IP address;
acquiring performance parameters of equipment;
setting the thread number N of automatic scanning in a self-adaptive manner based on the performance parameters of the equipment;
setting a priority scanning IP address list based on the initial IP address a and the thread number N of the automatic scanning;
calculating the number L of scanning IP tasks which need to be evenly distributed by each thread based on the total number M of all IP addresses of the current local area network segment and the number N of the automatically scanned threads;
based on the number N of the automatically scanned threads and the number L of the scanning IP tasks which need to be evenly distributed by each thread, initially setting a scanning IP two-dimensional array of each scanning thread;
adjusting the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list;
judging whether the current network segment has history sharing equipment, if not, then:
and starting N scanning threads, and scanning the IP addresses in the adjusted two-dimensional array one by one.
2. The method of claim 1, further comprising:
and when the current network segment has the history sharing equipment, adjusting the scanning IP two-dimensional array of each scanning thread based on the IP address of the history sharing equipment.
3. The method of claim 2, further comprising:
displaying the accessible IP address obtained by scanning;
and after all the threads are scanned in a traversing way, storing all the accessible IP addresses obtained by scanning into a database.
4. The method of claim 1, wherein adaptively setting the number of threads for automatic scanning based on the performance parameters of the device comprises:
judging whether the equipment is low-performance equipment or not based on the performance parameters of the equipment, if so, setting the thread number of automatic scanning as 16 threads, and if not,:
the number of threads for auto-scan is set to 32 threads.
5. The method of claim 1, wherein calculating the number L of scanning IP tasks that need to be equally distributed per thread based on the total number M of all IP addresses of the current lan segment and the number N of threads to be automatically scanned comprises:
and calculating the number L of scanning IP tasks which are required to be evenly distributed by each thread based on a formula L [ (M-1)/N ] +1, wherein M is the total number of all IP addresses of the current LAN segment, and N is the number of threads which are automatically scanned.
6. A system for optimizing the automatic scanning speed of a local area network CIFS sharing device, comprising:
the first acquisition module is used for acquiring the IP address of the local area network where the equipment is currently located;
the first calculation module is used for calculating the total number M of all IP addresses and the initial IP address a of the current local area network segment based on the local area network IP address;
the second acquisition module is used for acquiring the performance parameters of the equipment;
the setting module is used for adaptively setting the thread number N of automatic scanning based on the performance parameters of the equipment;
the first setting module is used for setting a priority scanning IP address list based on the initial IP address a and the thread number N of the automatic scanning;
the second calculation module is used for calculating the number L of scanning IP tasks which need to be evenly distributed by each thread based on the total number M of all IP addresses of the current local area network segment and the number N of the automatically scanned threads;
a second setting module, configured to initially set a scanning IP two-dimensional array of each scanning thread based on the number N of threads to be automatically scanned and the number L of scanning IP tasks that each thread needs to be evenly distributed;
the first adjusting module is used for adjusting the scanning IP two-dimensional array of each scanning thread based on the priority scanning IP address list;
the judging module is used for judging whether the current network segment has history sharing equipment;
and the scanning module is used for starting N scanning threads and scanning the IP addresses in the adjusted two-dimensional array one by one.
7. The system of claim 6, further comprising:
and the second adjusting module is used for adjusting the scanning IP two-dimensional array of each scanning thread based on the IP address of the history sharing equipment when the history sharing equipment exists in the current network segment.
8. The system of claim 7, further comprising:
the display module is used for displaying the accessible IP address obtained by scanning;
and the storage module is used for storing all the accessible IP addresses obtained by scanning to the database after all the threads are traversed and scanned.
9. The system of claim 6, wherein the setup module is specifically configured to:
judging whether the equipment is low-performance equipment or not based on the performance parameters of the equipment, if so, setting the thread number of automatic scanning as 16 threads, and if not,:
the number of threads for auto-scan is set to 32 threads.
10. The system of claim 6, wherein the second computing module is specifically configured to:
and calculating the number L of scanning IP tasks which are required to be evenly distributed by each thread based on a formula L [ (M-1)/N ] +1, wherein M is the total number of all IP addresses of the current LAN segment, and N is the number of threads which are automatically scanned.
CN202010515298.5A 2020-06-08 2020-06-08 Method and system for optimizing automatic scanning speed of local area network CIFS (common information platform) sharing equipment Active CN111666109B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010515298.5A CN111666109B (en) 2020-06-08 2020-06-08 Method and system for optimizing automatic scanning speed of local area network CIFS (common information platform) sharing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010515298.5A CN111666109B (en) 2020-06-08 2020-06-08 Method and system for optimizing automatic scanning speed of local area network CIFS (common information platform) sharing equipment

Publications (2)

Publication Number Publication Date
CN111666109A true CN111666109A (en) 2020-09-15
CN111666109B CN111666109B (en) 2023-04-07

Family

ID=72386066

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010515298.5A Active CN111666109B (en) 2020-06-08 2020-06-08 Method and system for optimizing automatic scanning speed of local area network CIFS (common information platform) sharing equipment

Country Status (1)

Country Link
CN (1) CN111666109B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114896188A (en) * 2022-04-26 2022-08-12 深圳市科陆电子科技股份有限公司 Method and system for network sharing automatic adaptation of USB (universal serial bus) equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070237141A1 (en) * 2006-04-05 2007-10-11 Joseph Robert Marchese Network device detection, identification, and management
US20100161783A1 (en) * 2008-12-18 2010-06-24 Konica Minolta Systems Laboratory, Inc. Socket connection-based printer discovery method using a thread management scheme
CN102722417A (en) * 2012-06-07 2012-10-10 腾讯科技(深圳)有限公司 Distribution method and device for scan task
CN103634658A (en) * 2013-12-16 2014-03-12 乐视致新电子科技(天津)有限公司 Equipment scanning method and equipment scanning device in smart television
CN108965286A (en) * 2018-07-09 2018-12-07 国网重庆市电力公司电力科学研究院 A kind of lightweight network equipment port detection method based on python
CN110213355A (en) * 2019-05-21 2019-09-06 卓尔购电子商务(武汉)有限公司 The method and its application of search terminal in local area network
CN110336684A (en) * 2019-03-21 2019-10-15 北京天防安全科技有限公司 A kind of networked asset intelligent identification Method and system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070237141A1 (en) * 2006-04-05 2007-10-11 Joseph Robert Marchese Network device detection, identification, and management
US20100161783A1 (en) * 2008-12-18 2010-06-24 Konica Minolta Systems Laboratory, Inc. Socket connection-based printer discovery method using a thread management scheme
CN102722417A (en) * 2012-06-07 2012-10-10 腾讯科技(深圳)有限公司 Distribution method and device for scan task
CN103634658A (en) * 2013-12-16 2014-03-12 乐视致新电子科技(天津)有限公司 Equipment scanning method and equipment scanning device in smart television
CN108965286A (en) * 2018-07-09 2018-12-07 国网重庆市电力公司电力科学研究院 A kind of lightweight network equipment port detection method based on python
CN110336684A (en) * 2019-03-21 2019-10-15 北京天防安全科技有限公司 A kind of networked asset intelligent identification Method and system
CN110213355A (en) * 2019-05-21 2019-09-06 卓尔购电子商务(武汉)有限公司 The method and its application of search terminal in local area network

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李慧慧: ""一种基于多线程机制的端口扫描器的设计与实现"", 《中国优秀硕士论文 信息科技》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114896188A (en) * 2022-04-26 2022-08-12 深圳市科陆电子科技股份有限公司 Method and system for network sharing automatic adaptation of USB (universal serial bus) equipment

Also Published As

Publication number Publication date
CN111666109B (en) 2023-04-07

Similar Documents

Publication Publication Date Title
CN107426302B (en) Access scheduling method, device, system, terminal, server and storage medium
CN110851753B (en) Website access method, device, equipment and storage medium
CN110417903B (en) Information processing method and system based on cloud computing
CN111666109B (en) Method and system for optimizing automatic scanning speed of local area network CIFS (common information platform) sharing equipment
CN111629371B (en) Screen projection method and system
CN112532743B (en) Intelligent load balancing method and device and storage medium
CN111010303A (en) Server control method and device
CN112612618A (en) Interface current limiting method and device, computer equipment and storage medium
CN115225504A (en) Resource allocation method and device, electronic equipment and storage medium
CN111416883B (en) Address query method, device, terminal and computer readable storage medium
CN111064821A (en) Method and device for determining IP address of edge node
CN111143733A (en) Local data caching method and device, electronic equipment and readable storage medium
CN110582096A (en) Data request processing method and communication network system
CN111736751A (en) Stroke redrawing method, device and readable storage medium
US11122146B2 (en) Information processing method, electronic device and computer program product
CN114238246A (en) ARP reserved table entry method and device
CN112423032A (en) Data monitoring method and device based on smart television, electronic equipment and medium
CN113407876A (en) Webpage refreshing method, webpage refreshing system and related device
CN113596105A (en) Content acquisition method, edge node and computer-readable storage medium
CN112333560A (en) Webpage video analyzing and playing method, device and equipment and readable storage medium
CN111782323B (en) Bullet screen obtaining method, computing equipment and computer storage medium
CN111163142B (en) Domain name resolution method and related device
CN115018398B (en) Animation project postponing prediction method, device and system
CN114979276B (en) Dynamic scheduling method, device, equipment and storage medium for resources
CN116700900A (en) Virtual machine resource management method, virtual machine resource management device, terminal equipment and storage medium

Legal Events

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