Skip to content

Capture#first iterates over packets #2

@duien

Description

@duien

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
>> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions