Add channel hop capabilities
authorJavier Palacios <javiplx@gmail.com>
Mon, 23 Jul 2012 08:20:41 +0000 (10:20 +0200)
committerJavier Palacios <javiplx@gmail.com>
Mon, 23 Jul 2012 08:20:41 +0000 (10:20 +0200)
wifisniffer/wifilogger.py

index 6163e9d..34c6c2f 100755 (executable)
@@ -20,6 +20,19 @@ read_timeout = 100 # in milliseconds
 pc = pcapy.open_live(iface, max_bytes, promiscuous, read_timeout)
 
 
+channel_hop = [ 30.0 , False ]
+
+def channel_change ( ) :
+    try :
+        wlan["channel"] = ( wlan["channel"] ) % 12 + 1
+    except pyiw.error, error:
+        print "PYIW error : %s" % error
+    else :
+        if channel_hop[0] :
+            channel_hop[1] = threading.Timer( channel_hop[0] , channel_change ) 
+            channel_hop[1].start()
+
+
 def parse_radiotap( radiotap , it_present ) :
 
     fields = []
@@ -183,9 +196,15 @@ def dealWithPacket ( hdr , data ) :
 
     curtime = time.time()
     if curtime - tstamp > max_time :
+        channel_hop[0] = 0
         raise CaptureEnd( "Neighborhoud scan completed" )
 
 
+if channel_hop[0]  :
+    channel_hop[1] = threading.Timer( channel_hop[0] , channel_change ) 
+    channel_hop[1].start()
+
+
 packet_limit = -1 # infinite
 try :
     pc.loop( packet_limit , dealWithPacket )