2013-02-08 2 views
2

일정한 양의 목적지를 향하여 매초마다 핑 패킷을 보낼 수있는 코드를 구현해야합니다. 문제는 가능한 한 많은 목적지를 1 초 안에 핑합니다. 이런 이유로 나는 nmap에 사이클링을 부과하는 방법이 있다고 생각했다. (나는 cycle-nmap 매개 변수와 같은 것을 의미한다.) 그래서 소켓이 한 번만 열리 며 루프 핑의 마지막에 닫히면 a를 사용하는 것보다 시간이 절약된다. "nmap 감시"접근!NMAP 연속 ping

답변

1

당신은을 통해 명령 줄에서 다중 병렬 nmap은 프로세스를 생성 할 수 다음 outputX 파일 (output0, 출력 1 등)의 실행 인덱스를 유지하면서 각각의 대상에 대한

nmap [options for destination 0] > output0 & 

스폰 많은 그런 nmap을 요청 .. 모든 요청이 완료되면 각 출력 파일의 내용을 검사 할 수 있습니다.

+0

모든 인스턴스가 동일한 파일에 기록되어야한다면'>'대신'>>'을 시도하십시오. – sjas

3

Nmap 프로젝트의 일부는 Nping tool입니다. 원하는대로 정확하게 수행 할 수 있도록 설계되었으며 매우 구성 가능합니다. 예를 들면 다음과 같습니다.

$ sudo nping --rate 4 --icmp 192.168.1.4/30 

Starting Nping 0.6.26SVN (http://nmap.org/nping) at 2013-02-08 11:53 CST 
SENT (0.0192s) ICMP 192.168.1.142 > 192.168.1.5 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (0.2692s) ICMP 192.168.1.142 > 192.168.1.6 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (0.5193s) ICMP 192.168.1.142 > 192.168.1.7 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (0.7695s) ICMP 192.168.1.142 > 192.168.1.4 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (1.0196s) ICMP 192.168.1.142 > 192.168.1.5 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (1.2701s) ICMP 192.168.1.142 > 192.168.1.5 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
RCVD (1.2707s) ICMP 192.168.1.5 > 192.168.1.142 Echo reply (type=0/code=0) ttl=64 id=34160 iplen=28 
SENT (1.5206s) ICMP 192.168.1.142 > 192.168.1.7 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (1.7708s) ICMP 192.168.1.142 > 192.168.1.4 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (2.0209s) ICMP 192.168.1.142 > 192.168.1.5 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (2.2712s) ICMP 192.168.1.142 > 192.168.1.5 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
RCVD (2.2717s) ICMP 192.168.1.5 > 192.168.1.142 Echo reply (type=0/code=0) ttl=64 id=34161 iplen=28 
SENT (2.5216s) ICMP 192.168.1.142 > 192.168.1.7 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (2.7717s) ICMP 192.168.1.142 > 192.168.1.4 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (3.0219s) ICMP 192.168.1.142 > 192.168.1.5 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
SENT (3.2724s) ICMP 192.168.1.142 > 192.168.1.5 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
RCVD (3.2730s) ICMP 192.168.1.5 > 192.168.1.142 Echo reply (type=0/code=0) ttl=64 id=34162 iplen=28 
SENT (3.5230s) ICMP 192.168.1.142 > 192.168.1.7 Echo request (type=8/code=0) ttl=64 id=53659 iplen=28 
^C 
Statistics for host 192.168.1.4: 
| Probes Sent: 4 | Rcvd: 0 | Lost: 4 (100.00%) 
|_ Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A 
Statistics for host 192.168.1.5: 
| Probes Sent: 4 | Rcvd: 3 | Lost: 1 (25.00%) 
|_ Max rtt: 0.391ms | Min rtt: 0.263ms | Avg rtt: 0.332ms 
Statistics for host 192.168.1.6: 
| Probes Sent: 4 | Rcvd: 0 | Lost: 4 (100.00%) 
|_ Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A 
Statistics for host 192.168.1.7: 
| Probes Sent: 3 | Rcvd: 0 | Lost: 3 (100.00%) 
|_ Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A 
Raw packets sent: 15 (420B) | Rcvd: 3 (138B) | Lost: 12 (80.00%) 
Tx time: 3.57078s | Tx bytes/s: 117.62 | Tx pkts/s: 4.20 
Rx time: 3.57078s | Rx bytes/s: 38.65 | Rx pkts/s: 0.84 
Nping done: 4 IP addresses pinged in 3.59 seconds 
관련 문제