1. A controller configured with instructions for path tracing in a software defined network, the controller comprising: layer 2 path tracing in a software defined network for troubleshooting the network, the path tracing comprising: a user interface for taking an input of paths of interest to trace or a path identification in a header of a received packet; an encoder for receiving the input and generating a set of control messages to switches in the network that will stamp the packets traversing the traced paths with compact identification information and a corresponding codebook for decoding; and a decoder for using the codebook output by the encoder to translate the path identification information into hop-by-hop information.