Check out scapy
It takes a bit getting used to with the python scripting language and all, but its extremely powerful in taking raw input, such as a random packet, and then dividing each part into its respective OSI layer for inspection or customization.




