The primary purpose of encapsulating packets into frames is to facilitate the entry and exit of data on media. The term encapsulation refers to the process of putting headers and trailers around some data.
A web server encapsulates the webpage inside an HTTP header. It first encapsulates the data into the application layer header, and it is called a segment. A segment is then encapsulated into the IP layer header, and it is then called a packet. Finally, the network access layer encapsulates the IP packets inside both a header and trailer called a frame. A frame is the final form of the encapsulated data that is physically transferred. The physical layer encodes a signal onto the medium to transmit the frame.
Unlike previous encapsulations of data, a frame is encapsulated by both a header and trailer. These headers and trailers define how a string of binary numbers is interpreted. In other words, framing defines the meaning behind the bits that are transmitted across a network. The physical layer helps in getting a string of bits from one device to another. When the receiving device receives the bits, it must determine how to interpret them, and framing refers to the definition of the fields assumed to be in the data that the device receives.