Bgp update message

UPDATE messages are used to transfer routing information between BGP peers. The information in the UPDATE message can be used to construct a graph that describes the relationships of the various Autonomous Systems. By applying rules to be discussed, routing

information loops and some other anomalies may be detected and removed from inter-AS routing.

An UPDATE message is used to advertise feasible routes that share common path attributes to a peer, or to withdraw multiple unfeasible routes from service (see 3.1). An UPDATE message MAY simultaneously advertise a feasible route and withdraw multiple unfeasible routes from service. The UPDATE message always includes the fixed-size BGP header, and also includes the other fields, as shown below (note, some of the shown fields may not be present in every UPDATE message):

  +-----------------------------------------------------+
  |   Withdrawn Routes Length (2 octets)                |
  +-----------------------------------------------------+
  |   Withdrawn Routes (variable)                       |
  +-----------------------------------------------------+
  |   Total Path Attribute Length (2 octets)            |
  +-----------------------------------------------------+
  |   Path Attributes (variable)                        |
  +-----------------------------------------------------+
  |   Network Layer Reachability Information (variable) |
  +-----------------------------------------------------+

  Withdrawn Routes Length:

     This 2-octets unsigned integer indicates the total length of
     the Withdrawn Routes field in octets.  Its value allows the
     length of the Network Layer Reachability Information field to
     be determined, as specified below.

     A value of 0 indicates that no routes are being withdrawn from
     service, and that the WITHDRAWN ROUTES field is not present in
     this UPDATE message.

  Withdrawn Routes: see bgp_route.ivy

  Total Path Attribute Length:

     This 2-octet unsigned integer indicates the total length of the
     Path Attributes field in octets.  Its value allows the length
     of the Network Layer Reachability field to be determined as
     specified below.

     A value of 0 indicates that neither the Network Layer
     Reachability Information field nor the Path Attribute field is
     present in this UPDATE message.

  Path Attributes: see bgp_path_attribute.ivy

  Network Layer Reachability Information: see bgp_network_layer_reach_info.ivy

The minimum length of the UPDATE message is 23 octets -- 19 octets for the fixed header + 2 octets for the Withdrawn Routes Length + 2 octets for the Total Path Attribute Length (the value of Withdrawn Routes Length is 0 and the value of Total Path Attribute Length is 0).

An UPDATE message can advertise, at most, one set of path attributes, but multiple destinations, provided that the destinations share these attributes. All path attributes contained in a given UPDATE message apply to all destinations carried in the NLRI field of the UPDATE message.

An UPDATE message can list multiple routes that are to be withdrawn from service. Each such route is identified by its destination (expressed as an IP prefix), which unambiguously identifies the route in the context of the BGP speaker - BGP speaker connection to which it has been previously advertised.

An UPDATE message might advertise only routes that are to be withdrawn from service, in which case the message will not include path attributes or Network Layer Reachability Information. Conversely, it may advertise only a feasible route, in which case the WITHDRAWN ROUTES field need not be present.

An UPDATE message SHOULD NOT include the same address prefix in the WITHDRAWN ROUTES and Network Layer Reachability Information fields. However, a BGP speaker MUST be able to process UPDATE messages in this form. A BGP speaker SHOULD treat an UPDATE message of this form as though the WITHDRAWN ROUTES do not contain the address prefix.

include bgp_route
include bgp_path_attribute
include bgp_network_layer_reachability_info

object bgp_update_message = {
    type this = struct {
        withdraw_routes_len : stream_pos,
        withdraw_routes : withdraw_route.arr,
        total_path_attr_len : stream_pos,
        path_attrs : path_attr.arr,
        network_layer_reach_infos : network_layer_reach_info
    }

    instance idx : unbounded_sequence
    instance arr : array(idx,this)
}

action bgp_update_message_event(src:bgp_id,dst:bgp_id,bgp_message:bgp_update_message) = {}
relation bgp_update_event
around  bgp_update_message_event(src:bgp_id,dst:bgp_id,bgp_message:bgp_update_message) {
    require isup(bgpid_to_endpoint(src));
    require open_message_recv(src) & open_message_recv(dst);
    require origin_present(src);
    require num_queued_path_attr(src) >= 0;
    call show_path_attr_size(path_attr_size(src));
    require bgp_message.total_path_attr_len = path_attr_size(src);
    require bgp_message.path_attrs = queued_path_attr(src);
    bgp_update_event := true;
    ...
    require isup(bgpid_to_endpoint(src));

    origin_present(src) := false;
    queued_path_attr(src) := path_attr.arr.empty;
    num_queued_path_attr(src) := 0;
}

import action show_path_attr_size(s:stream_pos)