fleshed out pseudo code with packet in/out