BGP connection establishment
Basic connection establishment
Before BGP-specific communications can begin, a pair of BGP-speaking routers need to establish a Transmission Control Protocol (TCP) connection between them. TCP segments carrying BGP information have a source port and destination port with the value 179.
Something that often confuses people with an academic understanding of network reference models can be confused here. While TCP is, in Internet terminology, an end-to-end protocol, and, in OSI terminology, a transport layer protocol, the information carried in the TCP messages is information to control the internetwork layer (Internet) or network layer (OSI). TCP is emphatically not an OSI session layer protocol. The layer to which a protocol belongs, although layering is far less strict in the Internet than in OSI, is defined by the payload of the message, not the delivery encapsulation of the message.
Once the TCP connection is set up, the routers attempt to establish a BGP session. 
Capabilities advertisement and negotiation
All BGP speakers must have a basic set of capabilities. The BGP router initiating the connection, however, can use the BGP capabilities advertisement feature to propose that the two routers use additional capabilities.  If the destination router does not want to support an optional capability, it refuses the connection. Negotiation takes place in that the initiating router will try again, deleting one capability at a time, until either the responding router accepts a connection with the desired option, or the initiating router gives up because certain refused capabilities are necessary for the way in which it desires to operate.
One of the optional capabilities is the ability to restore a temporarily broken BGP session. This is called graceful restart.
- A Border Gateway Protocol 4 (BGP-4), Internet Engineering Task Force, January 2006, RFC 4271, at 12, 34
- Chandra, R. & J. Scudder (November 2002), Capabilities Advertisement with BGP-4, Internet Engineering Task Force, RFC3392
- Chandra, R. & J. Scudder (January 2007), Graceful Restart Mechanism for BGP, Internet Engineering Task Force, RFC4724