ruby-pcap
ruby-pcap copied to clipboard
Capture#first iterates over packets
In this example, test.pcap is a 10-packet capture generated by tcpdump. If you'd like to see the pcap file, I'd be happy to attach it but this seems like a pretty reproducible issue. It happens on every file I generate.
As you can see, I get a different destination IP every time I ask for the first packet of the capture. After getting 10, I get an exception since I've reached the end of the capture.
>> require 'pcap'
=> true
>> incoming = Pcap::Capture.open_offline('test.pcap')
=> #<Pcap::Capture:0x10167f280>
>> incoming.first.dst
=> 192.168.1.230
>> incoming.first.dst
=> 72.46.233.89
>> incoming.first.dst
=> 192.168.1.230
>> incoming.first.dst
=> 72.46.233.89
>> incoming.first.dst
=> 255.255.255.255
>> incoming.first.dst
=> 192.168.1.255
>> incoming.first.dst
=> 204.93.163.221
>> incoming.first.dst
=> 192.168.1.230
>> incoming.first.dst
=> 204.93.163.221
>> incoming.first.dst
=> 74.125.67.103
>> incoming.first.dst
NoMethodError: undefined method `dst' for nil:NilClass
from (irb):15
>>
Could you attach the pcap file you were testing with? This sounds similar to some behavior I was seeing when I was getting this gem to build and run on ruby 1.9.2 and I'd like to confirm that it was the same issue.