Monday 14 October 2013

BGP Packet Structure

BGP messages are processed only when they have been entirely received. The smallest messages that can be sent with BGP is 19 octets and the maximum being 4096 octets. 19 octets is the minimum because it is a BGP message without any information other than the header details. Further more, it will be clear where all these 4096 octets are used.

BGP PACKET HEADER

The BGP packet header consist of 3 items which are :-


note : the integer octets are unsigned.

Marker : The marker uses 15 octets. This field's information is valuable for the detection of un-synchronized BGP peers and also for BGP message authentication.

Length : The Length uses 2 octet unsigned integer which indicates the message length including the header(marker,length,type). It helps for the possibility of the  transport level stream to know the net message which is always between the boundaries of 19-4096.

Type : The Type is 1 octet which indicates what type if BGP message is transmitted. That brings us to the types of BGP messages which are OPEN, UPDATE, NOTIFICATION, KEEPALIVE.

OPEN MESSAGE FORMAT


The open message is the first message transmitted when the connection between two BGP peers have been established. If the OPEN message sent by one of the other BGP peers is accepted by the receiver, then KEEPALIVE message is sent to the source to confirm the OPEN message. As said earlier this is the first message.After this process so can other BGP message types be transmitted like UPDATE,EXCHANGE,NOTIFICATION which shall be seen later in detail. The OPEN message format consist of 5 fields added to the header which sums up to 25 octets with the OPEN message having 6. The fields are:


Version : 1 octet. Displays the current BGP protocol version number.
My Autonomous Systems : 2 octet. Contains the AS number of the source.
Hold Time : 2 octet. This is the holdtime "max sec: that may elapse upon receipt of successful messages (KEEPALIVE, UPDATE, etc)
Auth Code : The type if authentication used.
Auth Data : This is the authentication data sent it has no fixed octets but can be obtained with the subtraction of (25(which is the standard size of a message) + version + my autonomous system + holdtime + authcode ) with the current octet value.


UPDATE MESSAGE FORMAT

This is the message BGP uses to transmit information  of new and existing routes to other BGP peers. This is the info that can be used for graph creation and best path selection between different autonomous systems. This graph gives a clear view of the network in addition for the 19 fixed header size, the update message packet consist of 5 fields.


Unfeasible Routes Length : 2 octets. The total length of the Withdrawn Routes field in octets
Withdrawn Routes: This is a variable length field that contains a list of IP address prefixes for the routes that are being withdrawn from service.
Total Path Attributes Length : 2 octets. Indicates the total length of the path attribute field.
Path Attributes : 2 octets. Discussed later.
Network : These are the networks described in the path attributed can be one or more networks.

The update message length is = 19 + total path + 4 * #Networks


KEEPALIVE MESSAGE FORMAT

This just consist of the message header and uses no TCP based keep alive mechanism to ensure if the links between the peers are active.


NOTIFICATION MESSAGE FORMAT

This message is sent when an error is detected and the BGP session is immediately terminated after the transmission has taken place. It consist of 3 fields in the message format :-


Error Code : 1 octet. This is the type of error notification
Error  Subcode : 1 octet. This is the more specific error classification. Each type of BGP message like UPDATE, OPEN, has different types of errors which are regarded as error subcode.
Data : This contains the message of reason why the error occurred.


PATH ATTRIBUTES

These consist of optional ad mandatory attributes that all BGP systems must implement, The well known attributes are mandatory. Example of these well known attributes are :


ORIGIN : The source of the information with values of 0-2 having different source meanings.

AS_PATH : These are the ASes that must be traversed to reach the networks listed in the update message.

NEXT HOP : As next hop means, this is the gateway of the border router that is to be used as the next hop to other networks which are listed in the update message. The gateway must belong to the same AS the BGP that advertised it.

UNREACHABLE : This is as notification to the other BGP peers that the previously advertised route is now unreachable.



BGP FINITE STATE MACHINE


In other for they to be decision making between peers, each BGP peer uses a finite state machine that consist of six states. This is to avoid scenarios whereby, a BGP peer receives both incoming and outgoing connections from other peers resulting in the creation of 2 FSM instead of one. These states are, Idle, Connect, Active, OpenSent, OpenConfirm, Established. Below is a diagram that shows flow of these states.


  1. IDLE: State when BGP peer refuses any incoming connections.
  2. CONNECT: State in which BGP peer is waiting for its TCP State in which BGP peer is trying to acquire a connection to be completed.
  3. ACTIVE: State in which BGP peer is trying to acquire a peer by listening and accepting TCP connection.
  4. OPENCONFIRM: BGP peer is waiting for KEEPALIVE or NOTIFICATION
  5. OPENSENT: BGP peer is waiting for OPEN message from its peer message from its peer. 
  6. ESTABLISHED: BGP peer connection is established and exchanges UPDATE, NOTIFICATION, and KEEPALIVE messages with its peer.

Extracts from rfc 1163, 1771,1774.4271

No comments:

Post a Comment