# \[ANN\] packetgen 1.0.1 released

**URL:** <https://rubytalk.org/t/ann-packetgen-1-0-1-released/73964>\
**Category:** ruby-talk\
**Created:** [19 December 2016 16:06 UTC](https://rubytalk.org/t/ann-packetgen-1-0-1-released/73964 "2016-12-19T16:06:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sylvain\_Daubert](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Sylvain\_Daubert](https://rubytalk.org/u/Sylvain_Daubert)\
**Post date:** [19 December 2016 16:06 UTC](https://rubytalk.org/t/ann-packetgen-1-0-1-released/73964/1 "2016-12-19T16:06:58Z")

</div>

packetgen 1.0.1 has been released.

\* home: \<[https://github.com/sdaubert/packetgen](https://github.com/sdaubert/packetgen)\>  
\* bugs: \<[https://github.com/sdaubert/packetgen/issues](https://github.com/sdaubert/packetgen/issues)\>  
\* doc: \<[http://www.rubydoc.info/gems/packetgen](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  
- send packets at IP/IPv6 layers

Known protocols are: Ethernet, IP, IPv6, ARP, ICMP, ICMPv6, UDP and TCP.

# 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](http://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:  
pkt.to\_w # send on eth0  
pkt.to\_w('eth1')

# Capture packets from wire  
PacketGen.capture('eth0') do |packet|  
&nbsp;&nbsp;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)

Changes:

### 1.0.1 / 2016-12-19

\* 2 bug fixes:  
&nbsp;&nbsp;\* PacketGen.capture crashed when no block was given. Fixed  
&nbsp;&nbsp;\* all captures returned immediatly when no timeout option was given. Fixed
