partial implementation of layer 2