packetgen 0.1.0 has been released.


* home: <https://github.com/sdaubert/packetgen>

* bugs: <https://github.com/sdaubert/packetgen/issues>

* doc: <http://www.rubydoc.info/gems/packetgen>


PacketGen provides simple ways to generate, send and capture network
packets easily.


Compared to PacketFu, PacketGen:

- make easy building of packets, not class-defined as PacketFu

- may handle tunneled packets

- will encapsulate and/or decapsulate packets (TODO)

- parse packets bottom-up, so correctly guess lower protocols

- will send packets at IP/IPv6 layers (TODO, only Eth level for now)


Create packets:

pkt = PacketGen.gen('Eth').add('IP')

pkt = PacketGen.gen('IP', src: '192.168.1.2', dst:
'192.168.1.3').add('UDP', dport: 53, sport: 45657)


Manipulate packets:

pkt.is? 'Eth'   # => true

pkt.eth.dst = '00:00:01:02:03:04'

pkt.ip.sum = 0xffff


Get packet binary data:

pkt.to_s


Send packet on wire (for now, only for Eth packets):

pkt.to_w             # send on eth0

pkt.to_w('eth1')


Capture packets from wire

PacketGen.capture('eth0') do |packet|
  do_stuffs_with_packet
end

packets = PacketGen.capture('eth0', max: 6)   # Get 6 packets

packets = PacketGen.capture('eth0', timeout: 10, filter: 'ip')  # Get
all IP packets during 10 seconds


Read/write packets from/to file

packets = PacketNG::Packet.read('file.pcapng')

pkt.to_f('file.pcapng')

PacketNG::Packet.write('another_file.pcapng', ary_of_packets)


Parse a string:

pkt = PacketGen.parse(str)


Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>