Showing posts with label framing. Show all posts
Showing posts with label framing. Show all posts

Sunday, February 2, 2014

Framing

Recall RS-232 use of start and stop bit for framing the data bits between start and stop bits. The start bit serves to synchronize the receiver with the remaining bits from the sender. The sender and receiver use the same baud rate but, due to clock drift, must resynchronize on each data transmission.
Typically, the receiver tries to sample the signal at the expected middle of each bit. When the transition from 1 to 0 is detected, the receiver counts (typically 16 times the baud rate) 8 times before sampling the start bit, 16 times to the sample at the middle of the first data bit, 16 times to the next, etc.
                                           _      _____
Volts  _______|  |___|        |  |  |   |        |_____________
       1  1  1  1  0  1  1  0  0  1  0  1  0   0   1  1  1  1  1  1  1
      No data    |B|  Data 'S' ASCII code |P | E|    No data          
                                time-->                  
                                   
          B = Start bit (opposite of no data representation).
          P = Parity bit (0 as even number of 1's in ASCII 'S' code).
          E = Stop bit (same as no data representation).
It is important to note that the data link layer of the sender adds the framing information, which is used and removed by the receiver's data link layer. From the network layer view, framing is transparent as the message appears to travel directly from the sender's network layer to the receiver's, since the framing information was added and removed by the corresponding data link layers. The following are common framing methods.
  • Character count -  Has general format of:     Count <Count Characters> Count <Count Characters> ...
    to send the ASCII message "ABCDEFGHI"  in three separate transmissions:  3ABC4DEFG3HI

    The problem is that the message is transmitted in binary as (in hexadecimal):  0341424304344546470348494A
    An error of any type in the Count field (e.g. a single bit error changes 210 = 000000102 to 13010=100000102) can cause the receiver to lose count without hope of recovery.
  • Character stuffing
  • Special start/end characters can be used (e.g. STX to start and ETX to end a frame) but these characters cannot then occur in the message itself, only for framing.
  • Character stuffing uses the special start/end characters for framing and allows those characters in the message also. The method is for the sender to stuff an extra special character whenever the start or end character occurs naturally so that within the message the special character always occurs in pairs. The receiver recognizes the single special character as start/end and removes from the message the first special character from pairs received. Using the special character of <DEL> and <STX> and <ETX> for start/end framing, the message:

                AB<DEL>C<STX><ETX>DE 

    would be sent as (stuffed characters are underlined):
      <STX>AB<DEL><DEL>C<DEL><STX><DEL><ETX>DE<ETX>...<STX>
    If the receiver loses track it can wait for the next <STX> to locate the next frame. <DEL><STX> would be recognized as data since a <DEL> in data is stuffed as <DEL><DEL>. One problem is the dependency on use of the 8-bit ASCII code.
How would the following data be sent using character stuffing?
  • ABC
  • <DEL><STX>A<DEL><ETX>
  • Bit stuffing - Similar to character stuffing except a special bit pattern used to flag framing (e.g. 111111 marks the start of a frame). If that pattern naturally occurs (e.g. the data contains 6 1's, 111111) the sender stuffs in a 0 after natural 5 1's (11111 becomes 111110). To the receiver all 111111 are framing and all 111110 should have the 0 removed to become 11111. As with character stuffing, on a framing error the receiver can wait for the next framing bits to locate the next frame.
How would the following data be sent using bit stuffing as described above using a framing flag of 111111?
  • 0000
  • 1111111111
  • Physical layer coding violations - The message itself is encoded as 0's and 1's. The framing information is some signal that does not correspond to a legal 0 or 1. With Manchester encoding below, 1 is High/Low and 0 is Low/High so framing flag could be Low/Low with no rise or fall, something that cannot occur in the message.

Data flow in osi model

The OSI model presents a standard data flow architecture, with protocols specified in such a way that the receiving layer at the destination computer receives exactly the same object as sent by the matching layer at the source computer. Figure A.2 shows the OSI model data flow.
Figure A.2 OSI Model Data Flow
As data passes from one layer to the next layer, additional formatting or addressing is added from the sending computer so that it can be transmitted successfully.  
We sent the data through the inter face of the application.the data may be voice,text,images.The sending process passes data to the application layer. The application layer attaches an application header and then prepares the frame and passes the frame to the presentation layer.
The presentation layer can transform data in various ways, if necessary, such as by translating it and adding a header. It gives the result to the session layer. The presentation layer is not aware of which portion (if any) of the data received from the application layer is the application header and which portion is actually user data, because that information is irrelevant to the presentation layer's role.
The process of adding headers is repeated from layer to layer until the frame reaches the data link layer. There, in addition to a data-link header, a data-link trailer is added. The data-link trailer contains a checksum and padding if needed. This aids in frame synchronization. The frame is passed down to the physical layer, where it is transmitted to the receiving computer.
On the receiving computer, the various headers and the data trailer are stripped off one by one as the frame ascends the layers and finally reaches the receiving process.
Although the actual data transmission is vertical, each layer is programmed as if the transmission were horizontal. For example, when a sending transport layer gets a message from the session layer, it attaches a transport header and sends it to the receiving transport layer. The fact that the message actually passes through the network layer on its own computer is unimportant.

The data recieving process is just the reverse work done to sent. Formatting and addressing information is stripped away at each layer as it is passed up the layers until it arrives at the seventh layer, the Application layer, where it is returned back to its original state that can be interpreted by the receiving computer.

HERE ARE FUNCTION AND WORKING OF THE LAYERS:

We will now discuss the purpose of each layer in the OSI model.

Application Layer

The Application layer is the top layer of the OSI model. It is used to allow applications to access network services. It handles general network access, flow control, and error recovery. Some of the functions it supports are:

Accessing remote files
Accessing remote printers
Accessing remote databases
Electronic mail

Presentation Layer

The next layer down is the Presentation layer which is located at layer 6. It is the translator for the network as it determines the format used to exchange data among the computers on the network. Some of its functions are:

Protocol conversion
Data translation
Data encryption
Data compression
Conversion of the character set

Session Layer

Layer 5 is the Session layer, which establishes a communications connection between processes running on different computers. It performs name recognition and related functions; for example, user authentication and resource-access security that are needed to allow processes to communicate over the network. To ensure that all data gets sent, it uses checkpoints placed in the data stream to provide for synchronization. In the case of network failure the only data that needs to be sent again is the data after the last checkpoint. The Session layer is also responsible for controlling when and for how long each side transmits.

Transport Layer

Layer 4 is the Transport layer, which is responsible for ensuring that all the data is delivered in the correct sequence, error free, with no losses. It is the Transport layer that breaks up large messages into smaller packets for delivery. Some of the other functions provided by the Transport layer are:

Error handling
Flow control by notifying the transmitting computer to not transmit when the receiving computer has no available receive buffers

Network Layer

Layer 3, the Network layer, is responsible for determining the route that is taken from the transmitting computer to the receiving computer. It is also responsible for addressing messages and the translation of logical addresses into physical addresses. The Network layer determines what path the data should take based upon several factors, including the condition of the network and the priority of service.

Data Link Layer

Layer 2 is the Data Link layer, which is responsible for providing error-free transfer of frames from one computer to another using the Physical layer. A frame is a bundle of information sent as a single entity. Some of the other functions provided by the Data Link layer are:

Transmitting and receiving frames sequentially
Providing frame acknowledgment for frames it receives
Retransmitting frames that are not acknowledged by the receiving computer

Physical Layer

The Physical layer is located at layer 1, the bottom of the OSI model. The Physical layer handles the unstructured, raw, bit-stream data that is transferred over a physical medium. It also defines how the physical medium, or cable, is attached to the Network Interface Card (NIC). It does that by determining how many pins are in the connector that is being used and also the function of each of the pins. The Physical layer sends out bits equaling 1s and 0s and determines how long each bit lasts and how it is translated into the suitable optical or electrical impulse for the network cable.