1. A controller configured with instructions for path tracing in a software defined network, the controller comprising: layer 2 path tracing in the 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 wherein the user interface provides user interactions where users input a set of L2 paths, and a path query, where users input the path identification encoded in the packet, the host where the packet is received, and the time when the packet is received, for path tracing the user interface forwards the user input to the encoder and for path query the user interface forwards the user input to the decoder, and returns to the user the full path information from the decoder.