Packet parser and generator in Ruby