Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::NetMapMultiCoreMultiRange.bat
- ::
- ::Made for an english(us) windows environment, to be executed from cmd.exe
- ::the purpose of this .bat file is to map local networks as fast as possible using all the CPU cores(logical) that the system has
- ::
- ::The .bat file will ping every given adress in the range x.x.x.1-255.
- ::You can change the last number from 1 to 168 for example, the .bat file will start scanning from that number all the way to 255 in that case
- ::
- ::CHANGE THE BELOW 3 VALUES ACCORDINGLY
- ::
- set "ipranges=192.168.0.1#127.0.0.1#"
- set iprangestoscan=2
- set NUM_OF_PRO=255
- ::
- ::iprangestoscan should be set to the amount of ranges given in the %ipranges% string
- ::setting NUM_OF_PRO to 61 or less saves power, while still being really fast(yield in the below column is the efficiency)
- ::giving an iprange to scan like "127.0.0.50" could cause issues, if NUM_OF_PRO is set higher than 255-50=205,
- ::recommended is to set all ipranges last number to 1
- ::
- ::here is an example of using multi-thread multi-core workloads for a single range:
- ::
- ::using an i5 6500T (4 core) @2.5 GHz, turbo boosting to around 2.85 GHz
- ::
- ::127.0.0.1(-255)
- ::
- :: 1 thread=1153sec on x1.00000 yield: 1.00000
- ::15 thread= 78 sec on x14.7821 yield: 0.98547
- ::17 thread= 69 sec on x16.7102 yield: 0.98295
- ::29 thread= 43 sec on x26.8139 yield: 0.92462
- ::51 thread= 24 sec on x48.0417 yield: 0.94199
- ::61 thread= 19 sec on x60.6842 yield: 0.99482
- ::64 thread= 20 sec on x57.6500 yield: 0.90078
- ::85 thread= 15 sec on x76.8667 yield: 0.90431
- ::128thread= 12 sec on x96.0833 yield: 0.75065
- ::255thread= 08 sec on x144.125 yield: 0.56520
- ::
- ::processor affinity will automatically be split between all logical cores, trying to achieve 100% CPU usage
- ::
- ::DO NOT CHANGE ANYTHING BELOW THIS LINE
- ::
- @echo off&setlocal enabledelayedexpansion
- echo ###########################################>"%TEMP%\tempnetmap.txt"
- set run=1
- :startrun
- for /f "tokens=%run% delims=#" %%a in ("%ipranges%") do (
- call :runfromhere %%a
- echo # %%a-255>>"%TEMP%\tempnetmap.txt"
- echo #>>"%TEMP%\tempnetmap.txt"
- type "%TEMP%\netmapFinal.txt">>"%TEMP%\tempnetmap.txt"
- echo ###########################################>>"%TEMP%\tempnetmap.txt"
- )
- set/a run+=1
- if "%run%" GTR "%iprangestoscan%" cls&type "%TEMP%\tempnetmap.txt"&exit/b
- goto startrun
- :runfromhere
- set adress=%1
- set "tempfolder=%TEMP%"
- for /f "tokens=1-4 delims=." %%a in ("%adress%") do set ip=%%a.%%b.%%c.&set cnt=%%d
- for /L %%a in (1,1,%NUM_OF_PRO%) do (
- set/a corefrom%%a=25500/%NUM_OF_PRO%*%%a/100
- set/a coreto%%a=25500/%NUM_OF_PRO%/100+25500*%%a/%NUM_OF_PRO%/100-1
- )
- set temp1=1
- :coreloop
- echo off>"%tempfolder%\%~n0-!temp1!.txt"
- if !temp1! LSS %NUM_OF_PRO% set/a temp1+=1&goto coreloop
- set temp1=1
- :loop
- set "from=!corefrom%temp1%!"
- set "to=!coreto%temp1%!"
- start /B cmd /Q /C "for /L %%L in (!from!,1,!to!) do for /f "tokens=2-4 delims=[] " %%a in ('ping -a -n 1 %ip%%%L') do for /f "tokens=1-4 delims=." %%A in ("%%b") do if not "[%%A.%%B.%%C.%%D]"=="[%%A.%%B.%%C.%%L:]" if not "%%a"=="timed" if not "%%a"=="^=" if not ".%%B.%%C.%%D]"=="...]" if not "%%a"=="from" (echo %%a [%%A.%%B.%%C.%%D]>>"%tempfolder%\%~n0-!temp1!.txt") >nul"
- if !temp1! LSS %NUM_OF_PRO% set/a temp1+=1&goto loop
- :WAITLOOP
- tasklist /FI "IMAGENAME eq PING.exe" | find /I /N "PING.exe">nul
- if "%ERRORLEVEL%"=="0" goto RUNNING
- goto NOTRUNNING
- :RUNNING
- timeout 1 /NOBREAK >nul
- goto WAITLOOP
- :NOTRUNNING
- set temp1=0
- echo off >"%tempfolder%\netmapFinal.txt"
- :loop2
- set/a temp1+=1
- type "%tempfolder%\%~n0-!temp1!.txt">>"%tempfolder%\netmapFinal.txt" 2>nul
- if not "%NUM_OF_PRO%"=="!temp1!" goto loop2
- del "%tempfolder%\%~n0-*.txt"
- exit/b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement