add lib/packet.py and format code