BGP · Topic 1 of 4

BGP Operation and Message Types

Learn how BGP works on Junos for the JNCIS-SP JN0-364: TCP port 179, the neighbor states, the five message types, hold time and keepalive timers.

  • 5 min
In a nutshell
  • BGP-4 uses TCP port 179; peers are configured manually.
  • States: Idle, Connect, Active, OpenSent, OpenConfirm, Established. Only Established exchanges routes.
  • Message types: OPEN 1, UPDATE 2, NOTIFICATION 3, KEEPALIVE 4, ROUTE-REFRESH 5.

What it is

BGP (Border Gateway Protocol, version 4) is the routing protocol that carries reachability between autonomous systems (ASs). A service provider runs it to exchange routes with customers and other providers, and inside its own network to carry those routes from edge to edge.

BGP is a path vector protocol. Each route carries a list of the ASs it has crossed, the AS path, and a set of attributes the receiver uses to pick the best path. Unlike OSPF or IS-IS, BGP does not discover neighbors: every peer is configured by hand and the session runs over TCP port 179.

IdlestartConnectTCP failsActiveConnectTCP up, OPEN sentOpenSentOPEN receivedOpenConfirmKEEPALIVE receivedEstablished

How it works

Sessions over TCP

Because BGP rides on TCP, it gets reliable, ordered delivery for free. BGP itself never retransmits or acknowledges updates; TCP does that. This is also why BGP peers do not need to share a subnet: any address the router can reach can be a peer, as long as TCP can connect.

After the session comes up, BGP sends the full table once and then only incremental updates. There is no periodic refresh of routes. Liveness is checked with small keepalive messages.

The neighbor state machine

StateWhat is happening
IdleBGP is not trying to connect, for example after an error or before configuration is complete
ConnectWaiting for the TCP connection to complete
ActiveThe TCP attempt failed or timed out; BGP keeps retrying
OpenSentTCP is up and an OPEN has been sent; waiting for the peer's OPEN
OpenConfirmOPEN received and accepted; waiting for a KEEPALIVE
EstablishedSession up; UPDATE messages flow

Only Established means a working session. A peer stuck in Active is not "actively working". It means the router cannot complete TCP, usually because of a wrong peer address, no route to the peer, a missing local-address, or a filter blocking port 179.

The five message types

Every BGP message starts with a 19-byte header: a 16-byte marker, a 2-byte length and a 1-byte type.

TypeMessagePurpose
1OPENStarts the session: BGP version, sender AS, proposed hold time, BGP identifier (router ID), optional capabilities
2UPDATEAdvertises new routes with their attributes and withdraws routes that are no longer reachable
3NOTIFICATIONReports an error and closes the session
4KEEPALIVEHeader only; confirms the peer is alive and acknowledges an OPEN
5ROUTE-REFRESHAsks the peer to resend its routes, used after an inbound policy change

One UPDATE can carry several prefixes that share the same attributes, plus a list of withdrawn prefixes. Capabilities in the OPEN, such as the address families (family inet, inet6, inet-vpn) and 4-byte AS support, must be agreed before routes of that type can be exchanged.

Hold time and keepalives

The hold time is proposed in the OPEN, and both peers use the lower of the two values. The Junos OS default hold time is 90 seconds, and keepalives are sent at one third of the hold time, so every 30 seconds. If no KEEPALIVE or UPDATE arrives within the hold time, the router sends a NOTIFICATION and tears the session down.

user@router# set protocols bgp group EXT-PEERS hold-time 30

What happens when a session drops

When a session closes, every route learned from that peer is removed and best path selection runs again. The NOTIFICATION carries an error code, such as hold timer expired or OPEN message error (for example a wrong peer AS), which is what you look for in the logs.

Exam tip

In show bgp summary, an Established peer shows route counts in the last column. Any other value in that column, such as Active or Connect, is the session state, and it means no routes are being exchanged with that peer.

Monitoring the basics

user@router> show bgp summary
user@router> show bgp neighbor 192.0.2.2

show bgp summary lists each peer, its AS, packets in and out, flaps, time in the current state and either the state or the active, received, accepted and damped prefix counts. show bgp neighbor adds the negotiated hold time, the capabilities, the last error and the configured options for one peer.

Common mistakes

Reading "Active" as healthy. Active is a failure state in which TCP cannot be completed. Look at reachability, addresses and filters.

Expecting BGP to find peers. Nothing happens until you configure each neighbor. There is no hello or multicast discovery.

Thinking BGP refreshes routes periodically. Only changes are sent after the initial exchange. Keepalives carry no routes.

Mixing up who acknowledges an OPEN. The peer answers an acceptable OPEN with a KEEPALIVE, which moves the session from OpenConfirm to Established.

Watch out

A NOTIFICATION always closes the session. If a question shows a peer cycling between Idle and Active with an "OPEN message error", the usual cause is a mismatched peer-as or an unsupported capability.

What to remember for the exam

  • BGP-4 uses TCP port 179; peers are configured manually.
  • States: Idle, Connect, Active, OpenSent, OpenConfirm, Established. Only Established exchanges routes.
  • Message types: OPEN 1, UPDATE 2, NOTIFICATION 3, KEEPALIVE 4, ROUTE-REFRESH 5.
  • Header is 19 bytes; a KEEPALIVE is the header alone.
  • UPDATE carries both new routes with attributes and withdrawn routes.
  • Junos default hold time 90 seconds; keepalive every 30 seconds; peers use the lower hold time.
  • Full table once, then incremental updates only.
  • show bgp summary and show bgp neighbor are the first checks.

Check yourself

  • A peer shows the state Active in show bgp summary. What does this mean?

    The router cannot complete the TCP connection to the peer, so no routes are exchanged; check addressing, reachability and filters on port 179.

  • Which message withdraws a route that is no longer reachable?

    An UPDATE message, which carries a list of withdrawn prefixes as well as new routes.

  • One peer proposes a 90 second hold time and the other 30 seconds. What hold time is used?

    The lower value, 30 seconds, with keepalives every 10 seconds.

Topic 1 of 4 in BGP

Test yourself on BGP

The full Juniper JNCIS-SP JN0-364 question bank has 860 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.