def sniff(opts=false)
      if Process.uid == 0
        if opts
          interface = opts[:interface] if opts[:interface]
          channel = opts[:channel] if opts[:channel]
          timeout = opts[:timeout] if opts[:timeout]
        end
        interface = default_interface unless interface
        channel = "" unless channel
        timeout = 5 unless timeout
        stdin, stdout, stderr, wait_thr = Open3.popen3("#{AIRPORT} #{interface} sniff #{channel}")
        sleep(timeout.to_i)
        if Process.kill("KILL", wait_thr.pid)
          @file = determine_cap_file
          @pcap = Parser.new.parse(self)
        else
          raise WillowRunError.new("unable to kill pid #{wait_thr.pid}")
        end
      else
        raise WillowRunError.new("sniffing must be done with root!")
      end
      self
    end
def sniff(opts=false)
      if Process.uid == 0
        if opts
          interface = opts[:interface] if opts[:interface]
          channel = opts[:channel] if opts[:channel]
          timeout = opts[:timeout] if opts[:timeout]
        end
        interface = default_interface unless interface
        channel = "" unless channel
        timeout = 5 unless timeout
        stdin, stdout, stderr, wait_thr = Open3.popen3("#{AIRPORT} #{interface} sniff #{channel}")
        sleep(timeout.to_i)
        if Process.kill("KILL", wait_thr.pid)
          @file = determine_cap_file
          @pcap = Parser.new.parse(self)
        else
          raise WillowRunError.new("unable to kill pid #{wait_thr.pid}")
        end
      else
        raise WillowRunError.new("sniffing must be done with root!")
      end
      self
    end
You can either create a parser object with
 or without data when it is iniatilized.
 sniff() alllows the capturing packets, as long as
 the process as the correct privelleges. Optionally,
 a set of options can be passed in as a hash to set
 custom parameters for the sniffing. A default of 5
 seconds has been given to the sniff method, whereafter
 the sniffing will stop / the process PID be killed.