Advertisement
hidde663

NetMapMultiCoreMultiRange.bat

May 22nd, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. ::NetMapMultiCoreMultiRange.bat
  2. ::
  3. ::Made for an english(us) windows environment, to be executed from cmd.exe
  4. ::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
  5. ::
  6. ::The .bat file will ping every given adress in the range x.x.x.1-255.
  7. ::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
  8. ::
  9. ::CHANGE THE BELOW 3 VALUES ACCORDINGLY
  10. ::
  11. set "ipranges=192.168.0.1#127.0.0.1#"
  12. set iprangestoscan=2
  13. set NUM_OF_PRO=255
  14. ::
  15. ::iprangestoscan should be set to the amount of ranges given in the %ipranges% string
  16. ::setting NUM_OF_PRO to 61 or less saves power, while still being really fast(yield in the below column is the efficiency)
  17. ::giving an iprange to scan like "127.0.0.50" could cause issues, if NUM_OF_PRO is set higher than 255-50=205,
  18. ::recommended is to set all ipranges last number to 1
  19. ::
  20. ::here is an example of using multi-thread multi-core workloads for a single range:
  21. ::
  22. ::using an i5 6500T (4 core) @2.5 GHz, turbo boosting to around 2.85 GHz
  23. ::
  24. ::127.0.0.1(-255)
  25. ::
  26. :: 1 thread=1153sec on x1.00000 yield: 1.00000
  27. ::15 thread= 78 sec on x14.7821 yield: 0.98547
  28. ::17 thread= 69 sec on x16.7102 yield: 0.98295
  29. ::29 thread= 43 sec on x26.8139 yield: 0.92462
  30. ::51 thread= 24 sec on x48.0417 yield: 0.94199
  31. ::61 thread= 19 sec on x60.6842 yield: 0.99482
  32. ::64 thread= 20 sec on x57.6500 yield: 0.90078
  33. ::85 thread= 15 sec on x76.8667 yield: 0.90431
  34. ::128thread= 12 sec on x96.0833 yield: 0.75065
  35. ::255thread= 08 sec on x144.125 yield: 0.56520
  36. ::
  37. ::processor affinity will automatically be split between all logical cores, trying to achieve 100% CPU usage
  38. ::
  39. ::DO NOT CHANGE ANYTHING BELOW THIS LINE
  40. ::
  41. @echo off&setlocal enabledelayedexpansion
  42. echo ###########################################>"%TEMP%\tempnetmap.txt"
  43. set run=1
  44. :startrun
  45. for /f "tokens=%run% delims=#" %%a in ("%ipranges%") do (
  46. call :runfromhere %%a
  47. echo # %%a-255>>"%TEMP%\tempnetmap.txt"
  48. echo #>>"%TEMP%\tempnetmap.txt"
  49. type "%TEMP%\netmapFinal.txt">>"%TEMP%\tempnetmap.txt"
  50. echo ###########################################>>"%TEMP%\tempnetmap.txt"
  51. )
  52. set/a run+=1
  53. if "%run%" GTR "%iprangestoscan%" cls&type "%TEMP%\tempnetmap.txt"&exit/b
  54. goto startrun
  55. :runfromhere
  56. set adress=%1
  57. set "tempfolder=%TEMP%"
  58. for /f "tokens=1-4 delims=." %%a in ("%adress%") do set ip=%%a.%%b.%%c.&set cnt=%%d
  59. for /L %%a in (1,1,%NUM_OF_PRO%) do (
  60. set/a corefrom%%a=25500/%NUM_OF_PRO%*%%a/100
  61. set/a coreto%%a=25500/%NUM_OF_PRO%/100+25500*%%a/%NUM_OF_PRO%/100-1
  62. )
  63. set temp1=1
  64. :coreloop
  65. echo off>"%tempfolder%\%~n0-!temp1!.txt"
  66. if !temp1! LSS %NUM_OF_PRO% set/a temp1+=1&goto coreloop
  67. set temp1=1
  68. :loop
  69. set "from=!corefrom%temp1%!"
  70. set "to=!coreto%temp1%!"
  71. 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"
  72. if !temp1! LSS %NUM_OF_PRO% set/a temp1+=1&goto loop
  73. :WAITLOOP
  74. tasklist /FI "IMAGENAME eq PING.exe" | find /I /N "PING.exe">nul
  75. if "%ERRORLEVEL%"=="0" goto RUNNING
  76. goto NOTRUNNING
  77. :RUNNING
  78. timeout 1 /NOBREAK >nul
  79. goto WAITLOOP
  80. :NOTRUNNING
  81. set temp1=0
  82. echo off >"%tempfolder%\netmapFinal.txt"
  83. :loop2
  84. set/a temp1+=1
  85. type "%tempfolder%\%~n0-!temp1!.txt">>"%tempfolder%\netmapFinal.txt" 2>nul
  86. if not "%NUM_OF_PRO%"=="!temp1!" goto loop2
  87. del "%tempfolder%\%~n0-*.txt"
  88. exit/b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement