SSF.OS.BGP4
Class BGPSession

java.lang.Object
  |
  +--SSF.OS.ProtocolSession
        |
        +--SSF.OS.BGP4.BGPSession
All Implemented Interfaces:
com.renesys.raceway.DML.Configurable, FIBChangeListener

public class BGPSession
extends ProtocolSession
implements FIBChangeListener

The BGP-4 inter-domain routing protocol. Despite the name of the class, each instance does not represent an individual peering session between two BGP speakers, but a BGP-4 protocol session running on a single router. In other words, an instance of this class is an instance of the protocol running on a router.


Field Summary
static byte ACTIVE
          Indicates the Active state in the BGP finite state machine (FSM).
 boolean alive
          Whether or not the BGP process represented by this BGPSession object is actually alive.
 java.lang.String as_nh
          The NHI address prefix uniquely identifying this BGP speaker's AS.
 int as_num
          The AS number of this BGP speaker's AS.
 IPaddress as_prefix
          The IP address prefix which is representative of this BGP's AS.
 boolean auto_advertise
          Whether or not this BGP speaker should automatically advertise its AS's network prefix to all neighbors.
 IPaddress bgp_id
          The BGP Identifier for this BGP speaker.
static int BGPrun
          Indicates an event that causes the BGP process to start up.
static int BGPstart
          Indicates the BGP Start event type.
static int BGPstop
          Indicates the BGP Stop event type.
 long cluster_num
          If this is a route reflector, the number of the cluster of which it is a member.
static byte CONNECT
          Indicates the Connect state in the BGP finite state machine (FSM).
 long connretry_interval
          The amount of time (in clock ticks) that should elapse between attempts to establish a session with a particular peer.
static int ConnRetryTimerExp
          Indicates the ConnectRetry Timer Expired event type.
 java.util.HashMap dampedRoutes
          Keeps track of damped routes.
 Debug debug
          A helper to manage debugging.
static boolean distrib_done
          Whether or not it has yet been determined if the simulator is running in a distributed fashion or on a single computer.
static long EBGP_MRAI_DEFAULT
          The "system" default Minimum Route Advertisement Timer Interval (in clock ticks) for external neighbors.
static byte ESTABLISHED
          Indicates the Established state in the BGP finite state machine (FSM).
static java.lang.String[] eventNames
          String representations of the different BGP event types.
 RoutingTable fwd_table
          The forwarding table, kept in the IP protocol session, which is the "live" table used for lookups when this router forwards packets (currently, IP is responsible for doing the forwarding).
static long HOLD_TIMER_DEFAULT
          Default Hold Timer Interval (in clock ticks) to be used with peers for whom it is not specifically configured.
static int HoldTimerExp
          Indicates the Hold Timer Expired event type.
static long IBGP_MRAI_DEFAULT
          The "system" default Minimum Route Advertisement Timer Interval (in clock ticks) for internal neighbors.
static byte IDLE
          Indicates the Idle state in the BGP finite state machine (FSM).
 IP ip
          A reference to the instance of IP running on the local router.
static long KEEP_ALIVE_DEFAULT
          Default Keep Alive Timer Interval (in clock ticks) to be used with peers for whom it is not specifically configured.
 double keep_alive_jitter
          Jitter factor for Keep Alive Interval.
static int KeepAliveTimerExp
          Indicates the KeepAlive Timer Expired event type.
 tcpSocket listensocket
          A socket listening for connection requests from (potential) peers (both internal and external).
 LocRIB loc_rib
          The Loc-RIB.
 long masoi
          The Minimum AS Origination Interval: the minimum amount of time (in clock ticks) that must elapse between successive advertisements of update messages that report changes within this BGP speaker's AS.
 double masoi_jitter
          Jitter factor for Minimum AS Origination Interval.
 EventTimer masoiTimer
          The Minimum AS Origination Timer.
 Monitor mon
          A monitor to record events of interest.
 double mrai_jitter
          Jitter factor for Minimum Route Advertisement Interval.
static int MRAITimerExp
          Indicates that an MRAI Timer expired.
 PeerEntry[] nbs
          An array of data for each neighboring router (potential BGP peer).
 java.lang.String nh
          The NH part of the NHI address for this BGP's router.
 int[] nhparts
          An array containing the individual numbers which make up the BGP speaker's NHI address.
static int NoticeUpdate
          Indicates that an Update message arrived.
static byte OPENCONFIRM
          Indicates the OpenConfirm state in the BGP finite state machine (FSM).
static byte OPENSENT
          Indicates the OpenSent state in the BGP finite state machine (FSM).
 java.util.ArrayList outbuf
          A buffer, which is a FIFO queue, which holds arbitrary processes to be executed (in the form of a Continuation objects) immediately after the current BGP event (from the incoming buffer, inbuf) is handled.
static int PORT_NUM
          The well-known port number for BGP.
static int PROTOCOL_NUM
          The well-known BGP protocol number.
static boolean rate_limit_by_dest
          Whether or not rate-limiting should be applied on a per-peer, per-destination basis.
static int ReadTransConnOpen
          Indicates the BGP Read Transport Connection Open event type.
static int RecvKeepAlive
          Indicates the Receive KeepAlive Message event type.
static int RecvNotification
          Indicates the Receive Notification Message event type.
static int RecvOpen
          Indicates the Receive Open Message event type.
static int RecvUpdate
          Indicates the Receive Update Message event type.
 boolean reflector
          Whether or not this instance of BGP serves as a route reflector.
 boolean rfd
          Whether route flap damping is turned on for this BGP speaker.
 RandomStream rng1
          A random number generator for workload generation.
 RandomStream rng2
          A random number generator for uses other than workload generation.
 Continuation RSCC
          A read socket close Continuation.
 Continuation SCC
          A socket close Continuation.
 PeerEntry self
          A special peer entry which represents the local BGP speaker.
 socketMaster socketmaster
          A reference to the Sockets protocol running on the local router.
static java.lang.String[] statestr
          An array of string versions of the state names.
static Net topnet
          A reference to the top-level Net.
static int TransConnClose
          Indicates the BGP Transport Connection Closed event type.
static int TransConnOpen
          Indicates the BGP Transport Connection Open event type.
static int TransConnOpenFail
          Indicates the BGP Transport Connection Open Failed event type.
static int TransFatalError
          Indicates the BGP Transport Fatal Error event type.
static java.lang.String version
          The developer's version string of this implementation of BGP-4.
static int WriteTransConnOpen
          Indicates the BGP Write Transport Connection Open event type.
static int WriteTransConnOpenFail
          Indicates the BGP Write Transport Connection Open Failed event type.
 
Fields inherited from class SSF.OS.ProtocolSession
name, use
 
Constructor Summary
BGPSession()
          Constructs a BGP protocol session.
 
Method Summary
 void config(com.renesys.raceway.DML.Configuration cfg)
          Sets configurable values for BGP.
 void decision_process_1(java.util.ArrayList infolist)
          Runs Phase 1 of the Decision Process, which is responsible for calculating the degree of preference of newly added or updated routes.
 java.util.ArrayList decision_process_2(java.util.ArrayList changedroutes, boolean dampReuse)
          Runs Phase 2 of the Decision Process, which is responsible for selecting which routes (from Adj-RIBs-In) should be installed in Loc-RIB.
 void decision_process_3(java.util.ArrayList locribchanges)
          Runs Phase 3 of the Decision Process, which is responsible for disseminating routes to peers.
 void die()
          Kills the BGP process.
 int dop(Route rte)
          Calculates the degree of preference of a route.
static java.lang.String event2str(int eventnum)
          Returns a string representation of a given BGP event number.
 void external_update(java.util.HashMap wds_table, java.util.HashMap ads_table)
          Tries to send update messages to each external peer if there is any new route information in Adj-RIBs-Out to be shared with them.
 void force_send(Message msg, PeerEntry peer)
          Sends a message immediately without incurring any CPU delay.
 void force_send(Message msg, PeerEntry peer, int casenum)
          Sends a message immediately.
 void ftadd(RouteInfo info)
          Adds a route to the local forwarding table.
 void ftrmv(RouteInfo info)
          Removes a route to the local forwarding table.
 boolean handle_event()
          This process handles both externally and internally generated BGP events.
 void handle_mrai_exp(TimeoutMessage tmsg, PeerEntry peer)
          Handles an MRAI Timer expiration.
 void handle_update(UpdateMessage msg)
          This method takes all necessary action when an update message is received.
 void init()
          Creates an SSF process whose primary purpose is to perform certain one-time-only BGP setup tasks.
 void listen()
          Wait for a completed socket connection (with a neighbor).
static long nh2cl(java.lang.String nh)
          Returns a unique cluster number associated with a given NHI prefix address.
 int nh2peerind(java.lang.String nh)
          Returns the index of a peer given it's NH address.
 long now()
          Returns the current simulation time in ticks.
 double nowsec()
          Returns the current simulation time in seconds.
 boolean push(ProtocolMessage message, ProtocolSession fromSession)
          This process optionally imposes a processing delay for certain BGP events, then passes them on to the receive method to be handled.
 void remove_all_routes(PeerEntry peer)
          Removes from the Loc-RIB all routes learned from a given peer, then runs Phases 2 and 3 of the Decision Process to replace the routes with backups (if possible), and update neighbors with the changes.
 void reset_timer(PeerEntry peer, int timertype)
          Resets the indicated type of timer for the given peer (if applicable).
 void restart()
          Restarts the BGP process.
 void routeAddedBy(RoutingInfo rinfo, java.lang.String protocolName)
          Notification that the named protocol has added a new entry to the forwarding table on this host.
 void routeDeletedBy(RoutingInfo rinfo, java.lang.String protocolName)
          Notification that the named protocol has removed an entry from the forwarding table on this host.
 void send(Message msg, PeerEntry peer)
          Generic procedure to take any kind of BGP message and push it onto the protocol below this one in the stack.
 void send(Message msg, PeerEntry peer, int casenum)
          Generic procedure to take any kind of BGP message and push it onto the protocol below this one in the stack.
 void set_timer(Timer timer)
          Sets the given BGP timer and also notes the time at which it was set.
 void set_timer(Timer timer, long amount)
          Sets the given BGP timer and also notes the time at which it was set.
static double ticks2secs(long numticks)
          Convenience method to convert simulation logical clock ticks into seconds.
 void try_send_update(UpdateMessage msg, java.util.ArrayList senders, PeerEntry peer)
          Handles the sending of an update message.
 java.lang.String version()
          Returns the developer's version string of this BGP-4 implementation.
 
Methods inherited from class SSF.OS.ProtocolSession
close, closed, debugIdentifier, inGraph, open, opened, pushAfterDelay, pushAfterDelayFailed, setGraph
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
The developer's version string of this implementation of BGP-4.

See Also:
Constant Field Values

PROTOCOL_NUM

public static final int PROTOCOL_NUM
The well-known BGP protocol number.

See Also:
Constant Field Values

PORT_NUM

public static final int PORT_NUM
The well-known port number for BGP.

See Also:
Constant Field Values

HOLD_TIMER_DEFAULT

public static final long HOLD_TIMER_DEFAULT
Default Hold Timer Interval (in clock ticks) to be used with peers for whom it is not specifically configured.


KEEP_ALIVE_DEFAULT

public static final long KEEP_ALIVE_DEFAULT
Default Keep Alive Timer Interval (in clock ticks) to be used with peers for whom it is not specifically configured.


EBGP_MRAI_DEFAULT

public static final long EBGP_MRAI_DEFAULT
The "system" default Minimum Route Advertisement Timer Interval (in clock ticks) for external neighbors. It is only used when (a) a timer's value is not specifically configured and (b) no "user" global default timer value for external neighbors is configured.


IBGP_MRAI_DEFAULT

public static final long IBGP_MRAI_DEFAULT
The "system" default Minimum Route Advertisement Timer Interval (in clock ticks) for internal neighbors. It is only used when (a) a timer's value is not specifically configured and (b) no "user" global default timer value for internal neighbors is configured.


IDLE

public static final byte IDLE
Indicates the Idle state in the BGP finite state machine (FSM).

See Also:
Constant Field Values

CONNECT

public static final byte CONNECT
Indicates the Connect state in the BGP finite state machine (FSM).

See Also:
Constant Field Values

ACTIVE

public static final byte ACTIVE
Indicates the Active state in the BGP finite state machine (FSM).

See Also:
Constant Field Values

OPENSENT

public static final byte OPENSENT
Indicates the OpenSent state in the BGP finite state machine (FSM).

See Also:
Constant Field Values

OPENCONFIRM

public static final byte OPENCONFIRM
Indicates the OpenConfirm state in the BGP finite state machine (FSM).

See Also:
Constant Field Values

ESTABLISHED

public static final byte ESTABLISHED
Indicates the Established state in the BGP finite state machine (FSM).

See Also:
Constant Field Values

statestr

public static final java.lang.String[] statestr
An array of string versions of the state names.


BGPrun

public static final int BGPrun
Indicates an event that causes the BGP process to start up.

See Also:
Constant Field Values

BGPstart

public static final int BGPstart
Indicates the BGP Start event type.

See Also:
Constant Field Values

BGPstop

public static final int BGPstop
Indicates the BGP Stop event type.

See Also:
Constant Field Values

TransConnOpen

public static final int TransConnOpen
Indicates the BGP Transport Connection Open event type.

See Also:
Constant Field Values

TransConnClose

public static final int TransConnClose
Indicates the BGP Transport Connection Closed event type.

See Also:
Constant Field Values

TransConnOpenFail

public static final int TransConnOpenFail
Indicates the BGP Transport Connection Open Failed event type.

See Also:
Constant Field Values

TransFatalError

public static final int TransFatalError
Indicates the BGP Transport Fatal Error event type.

See Also:
Constant Field Values

ConnRetryTimerExp

public static final int ConnRetryTimerExp
Indicates the ConnectRetry Timer Expired event type.

See Also:
Constant Field Values

HoldTimerExp

public static final int HoldTimerExp
Indicates the Hold Timer Expired event type.

See Also:
Constant Field Values

KeepAliveTimerExp

public static final int KeepAliveTimerExp
Indicates the KeepAlive Timer Expired event type.

See Also:
Constant Field Values

RecvOpen

public static final int RecvOpen
Indicates the Receive Open Message event type.

See Also:
Constant Field Values

RecvKeepAlive

public static final int RecvKeepAlive
Indicates the Receive KeepAlive Message event type.

See Also:
Constant Field Values

RecvUpdate

public static final int RecvUpdate
Indicates the Receive Update Message event type.

See Also:
Constant Field Values

RecvNotification

public static final int RecvNotification
Indicates the Receive Notification Message event type.

See Also:
Constant Field Values

MRAITimerExp

public static final int MRAITimerExp
Indicates that an MRAI Timer expired. Not in RFC 1771.

See Also:
Constant Field Values

NoticeUpdate

public static final int NoticeUpdate
Indicates that an Update message arrived. Not in RFC 1771.

See Also:
Constant Field Values

ReadTransConnOpen

public static final int ReadTransConnOpen
Indicates the BGP Read Transport Connection Open event type. Not in RFC 1771.

See Also:
Constant Field Values

WriteTransConnOpen

public static final int WriteTransConnOpen
Indicates the BGP Write Transport Connection Open event type. Not in RFC 1771.

See Also:
Constant Field Values

WriteTransConnOpenFail

public static final int WriteTransConnOpenFail
Indicates the BGP Write Transport Connection Open Failed event type. Not in RFC 1771.

See Also:
Constant Field Values

eventNames

public static final java.lang.String[] eventNames
String representations of the different BGP event types.


alive

public boolean alive
Whether or not the BGP process represented by this BGPSession object is actually alive. If it is not (for example, if its router has crashed), then the protocol will not interact with anything else in the simulation until the process is restarted.


topnet

public static Net topnet
A reference to the top-level Net.


socketmaster

public socketMaster socketmaster
A reference to the Sockets protocol running on the local router.


listensocket

public tcpSocket listensocket
A socket listening for connection requests from (potential) peers (both internal and external).


fwd_table

public RoutingTable fwd_table
The forwarding table, kept in the IP protocol session, which is the "live" table used for lookups when this router forwards packets (currently, IP is responsible for doing the forwarding).


ip

public IP ip
A reference to the instance of IP running on the local router.


as_nh

public java.lang.String as_nh
The NHI address prefix uniquely identifying this BGP speaker's AS. We use this in lieu of an AS number whenever possible since it is easier to use and functionally equivalent. Should we ever need an actual AS number instead of an NHI prefix, a mapping is kept in Util.AS_descriptor.

See Also:
AS_descriptor

as_num

public int as_num
The AS number of this BGP speaker's AS.


as_prefix

public IPaddress as_prefix
The IP address prefix which is representative of this BGP's AS.


nh

public java.lang.String nh
The NH part of the NHI address for this BGP's router.


nhparts

public int[] nhparts
An array containing the individual numbers which make up the BGP speaker's NHI address. It has no more informational content than the NHI address, and is for convenience only.


bgp_id

public IPaddress bgp_id
The BGP Identifier for this BGP speaker. Each BGP speaker (router running BGP) has a BGP Identifier. A given BGP speaker sets the value of its BGP Identifier to an IP address assigned to that BGP speaker. It is chosen at startup and never changes.


loc_rib

public LocRIB loc_rib
The Loc-RIB. It stores the local routing information that this BGP speaker has selected by applying its local policies to the routing information contained in the Adj-RIBs-In.


reflector

public boolean reflector
Whether or not this instance of BGP serves as a route reflector.


cluster_num

public long cluster_num
If this is a route reflector, the number of the cluster of which it is a member.


nbs

public PeerEntry[] nbs
An array of data for each neighboring router (potential BGP peer). A router is considered a neighbor of the local router if there is a point-to-point connection between the two. Every neighboring router ("neighbor" for short) is considered to be a potential peer at simulation start-up. A peer is simply a neighbor with whom a BGP connection, or peering session, has been established. Thus, a neighbor is not necessarily a peer, but a peer is always a neighbor. This difference between neighbors and peers is important, and the terminology used here attempts to be consistent with these definitions.


connretry_interval

public long connretry_interval
The amount of time (in clock ticks) that should elapse between attempts to establish a session with a particular peer.


masoi

public long masoi
The Minimum AS Origination Interval: the minimum amount of time (in clock ticks) that must elapse between successive advertisements of update messages that report changes within this BGP speaker's AS.


keep_alive_jitter

public double keep_alive_jitter
Jitter factor for Keep Alive Interval.


masoi_jitter

public double masoi_jitter
Jitter factor for Minimum AS Origination Interval.


mrai_jitter

public double mrai_jitter
Jitter factor for Minimum Route Advertisement Interval.


rate_limit_by_dest

public static boolean rate_limit_by_dest
Whether or not rate-limiting should be applied on a per-peer, per-destination basis. The default is false: rate-limiting is applied only on a per-peer basis, without regard to destination.


masoiTimer

public EventTimer masoiTimer
The Minimum AS Origination Timer.


outbuf

public java.util.ArrayList outbuf
A buffer, which is a FIFO queue, which holds arbitrary processes to be executed (in the form of a Continuation objects) immediately after the current BGP event (from the incoming buffer, inbuf) is handled. Three types of processes may currently be added to outbuf: those which send a message, those which close the sockets for a peer, and those which set the MRAI timer. Items in this buffer are added while handling a BGP event, and are removed and executed in the order they are added. Each item may optionally specify an amount of CPU time to be charged for processing that item. For example, the processing of a HoldTimerExp event for peer P might result in a Notification message being sent to that peer as well as several Update messages (containing withdrawals) being sent to other peers. If our model is charging a CPU delay for composing/sending messages, then processes to send each of the Updates and Notification would be added to outbuf with the appropriate CPU delay, to be charged once the current HoldTimerExp event has been handled and has had CPU delay charged for it. Since the sockets for peer P need to be closed as well, and because that cannot be done until after the Notification is sent, we add a 'close sockets' process to outbuf as well, after adding the process to send the Notification.


self

public PeerEntry self
A special peer entry which represents the local BGP speaker. Obviously, this entry does not actually represent a peer at all, but it is useful when dealing with routes which were originated by this BGP speaker or configured statically.


auto_advertise

public boolean auto_advertise
Whether or not this BGP speaker should automatically advertise its AS's network prefix to all neighbors.


debug

public Debug debug
A helper to manage debugging.


mon

public Monitor mon
A monitor to record events of interest.


distrib_done

public static boolean distrib_done
Whether or not it has yet been determined if the simulator is running in a distributed fashion or on a single computer.


rng1

public RandomStream rng1
A random number generator for workload generation. (In other words, assigning delay values for the processing of updates.)


rng2

public RandomStream rng2
A random number generator for uses other than workload generation. It is used, among other things, for calculating jitter for certain timers and when using randomized MRAI timers.


rfd

public boolean rfd
Whether route flap damping is turned on for this BGP speaker.


dampedRoutes

public java.util.HashMap dampedRoutes
Keeps track of damped routes. Indexed by NLRI prefix.


SCC

public Continuation SCC
A socket close Continuation.


RSCC

public Continuation RSCC
A read socket close Continuation.

Constructor Detail

BGPSession

public BGPSession()
Constructs a BGP protocol session.

Method Detail

nh2cl

public static long nh2cl(java.lang.String nh)
Returns a unique cluster number associated with a given NHI prefix address.

Parameters:
nh - The NH address to be converted.
Returns:
the unique cluster number associated with the NH address

event2str

public static java.lang.String event2str(int eventnum)
Returns a string representation of a given BGP event number.

Parameters:
eventnum - An integer representing a BGP event.
Returns:
a string representation of a BGP event

ftadd

public void ftadd(RouteInfo info)
Adds a route to the local forwarding table.

Parameters:
info - Route information about the route to be added.

ftrmv

public void ftrmv(RouteInfo info)
Removes a route to the local forwarding table.

Parameters:
info - Route information about the route to be removed.

routeAddedBy

public void routeAddedBy(RoutingInfo rinfo,
                         java.lang.String protocolName)
Notification that the named protocol has added a new entry to the forwarding table on this host.

Specified by:
routeAddedBy in interface FIBChangeListener
Parameters:
rinfo - Information about the route added to the FIB.
protocolName - The name of the protocol that added the route.

routeDeletedBy

public void routeDeletedBy(RoutingInfo rinfo,
                           java.lang.String protocolName)
Notification that the named protocol has removed an entry from the forwarding table on this host.

Specified by:
routeDeletedBy in interface FIBChangeListener
Parameters:
rinfo - Information about the route deleted from the FIB.
protocolName - The name of the protocol that deleted the route.

config

public void config(com.renesys.raceway.DML.Configuration cfg)
            throws com.renesys.raceway.DML.configException
Sets configurable values for BGP. If the DML 'autoconfig' attribute is set (in the DML configuration file), then most values will be determined in the init method.

Specified by:
config in interface com.renesys.raceway.DML.Configurable
Overrides:
config in class ProtocolSession
Parameters:
cfg - contains the values for configurable BGP parameters
Throws:
com.renesys.raceway.DML.configException - if any of the calls to find or findSingle throw such an exception.

init

public void init()
Creates an SSF process whose primary purpose is to perform certain one-time-only BGP setup tasks.

Overrides:
init in class ProtocolSession

listen

public final void listen()
Wait for a completed socket connection (with a neighbor).


now

public long now()
Returns the current simulation time in ticks. Just a convenience so that any functions, not just Processes, can get the current simulation time.

Returns:
the current simulation time in ticks

nowsec

public double nowsec()
Returns the current simulation time in seconds.

Returns:
the current simulation time in seconds

ticks2secs

public static double ticks2secs(long numticks)
Convenience method to convert simulation logical clock ticks into seconds.

Parameters:
numticks - The number of ticks to be converted to seconds.
Returns:
the number of seconds

version

public final java.lang.String version()
Returns the developer's version string of this BGP-4 implementation.

Overrides:
version in class ProtocolSession
Returns:
the developer's version string

set_timer

public void set_timer(Timer timer)
Sets the given BGP timer and also notes the time at which it was set.

Parameters:
timer - The timer to be set.

set_timer

public void set_timer(Timer timer,
                      long amount)
Sets the given BGP timer and also notes the time at which it was set.

Parameters:
timer - The timer to be set.
amount - The length of time which the timer will be set for.

reset_timer

public void reset_timer(PeerEntry peer,
                        int timertype)
Resets the indicated type of timer for the given peer (if applicable). If the timer had not been previously set, then the cancel has no effect, but the timer is still set normally.

Parameters:
peer - The peer entry for the peer with whom the timer is associated (if applicable).
timertype - The type of timer to be reset.

nh2peerind

public final int nh2peerind(java.lang.String nh)
Returns the index of a peer given it's NH address.


handle_update

public void handle_update(UpdateMessage msg)
This method takes all necessary action when an update message is received. This includes handling optional attributes, adding/removing entries from Adj-RIBs-In, running the Decision Process, etc.

Parameters:
msg - An update message received by this BGP speaker.

dop

public final int dop(Route rte)
Calculates the degree of preference of a route. It is a non-negative integer, and higher values indicate more preferable routes.

Parameters:
rte - A route for which to calculate the degree of preference.
Returns:
the degree of preference of the route

decision_process_1

public final void decision_process_1(java.util.ArrayList infolist)
Runs Phase 1 of the Decision Process, which is responsible for calculating the degree of preference of newly added or updated routes.

Parameters:
infolist - A list of route information for which to calculate the degrees of preference.

remove_all_routes

public void remove_all_routes(PeerEntry peer)
Removes from the Loc-RIB all routes learned from a given peer, then runs Phases 2 and 3 of the Decision Process to replace the routes with backups (if possible), and update neighbors with the changes.

Parameters:
peer - The peer whose routes are to be invalidated.

decision_process_2

public final java.util.ArrayList decision_process_2(java.util.ArrayList changedroutes,
                                                    boolean dampReuse)
Runs Phase 2 of the Decision Process, which is responsible for selecting which routes (from Adj-RIBs-In) should be installed in Loc-RIB.

Parameters:
changedroutes - A list of info on recent route changes.
dampReuse - Whether called by dampReuseTimer callback.
Returns:
a list of route changes made to the Loc-RIB

decision_process_3

public final void decision_process_3(java.util.ArrayList locribchanges)
Runs Phase 3 of the Decision Process, which is responsible for disseminating routes to peers. This is done by inserting certain routes from Loc-RIB into Adj-RIBs-Out.

Parameters:
locribchanges - A list of changes to the Loc-RIB.

external_update

public void external_update(java.util.HashMap wds_table,
                            java.util.HashMap ads_table)
Tries to send update messages to each external peer if there is any new route information in Adj-RIBs-Out to be shared with them. Currently, this method also handles updating internal peers.

Parameters:
wds_table - A table of NLRI of withdrawn routes which need to be sent.
ads_table - A table of routes which need to be advertised.

handle_mrai_exp

public void handle_mrai_exp(TimeoutMessage tmsg,
                            PeerEntry peer)
Handles an MRAI Timer expiration.


send

public final void send(Message msg,
                       PeerEntry peer)
Generic procedure to take any kind of BGP message and push it onto the protocol below this one in the stack. If CPU delay is in use, then they are simply added to a CPU delay queue and will be sent when they reach the front of it.

Parameters:
msg - The BGP message to be sent out.
peer - The entry for the peer to whom the message should be sent.

send

public final void send(Message msg,
                       PeerEntry peer,
                       int casenum)
Generic procedure to take any kind of BGP message and push it onto the protocol below this one in the stack. If CPU delay is in use, then they are simply added to a CPU delay queue and will be sent when they reach the front of it.

Parameters:
msg - The BGP message to be sent out.
peer - The entry for the peer to whom the message should be sent.
casenum - Indicates info about this send for event recording.

force_send

public final void force_send(Message msg,
                             PeerEntry peer)
Sends a message immediately without incurring any CPU delay. Exactly the same as sendmsg, except that it is a public method. The intended use of this method is by widgets (fake protocol sessions) on top of BGP in the protocol stack whose only purpose is to inject certain events at certain times. It is used in some validation tests and may also be used for experimental purposes.

Parameters:
msg - The BGP message to be sent out.
peer - The entry for the peer to whom the message should be sent.

force_send

public final void force_send(Message msg,
                             PeerEntry peer,
                             int casenum)
Sends a message immediately. See documentation for force_send(Message,PeerEntry).

Parameters:
msg - The BGP message to be sent out.
peer - The entry for the peer to whom the message should be sent.
casenum - Indicates info about this send for event recording.

try_send_update

public final void try_send_update(UpdateMessage msg,
                                  java.util.ArrayList senders,
                                  PeerEntry peer)
Handles the sending of an update message. If for any reason it cannot be sent right away, it takes the proper actions.

Parameters:
msg - The update message to send.
senders - The NHI addresses of the senders of each route in the update message; this information is required if the route cannot be advertised right away.
peer - The peer to whom the message should be sent.

push

public boolean push(ProtocolMessage message,
                    ProtocolSession fromSession)
This process optionally imposes a processing delay for certain BGP events, then passes them on to the receive method to be handled. All thirteen types of events (both externally and internally generated) pass through this method in the BGP flow of control. For externally generated events, push is not called by the protocol directly below BGP (which is Sockets) to pass a message up, but is called by BGP methods which are reading from sockets. If the option to model processing delay is in use, this method uses a queue to delay certain events/messages accordingly. Message ordering is always preserved for all messages coming through push.

Specified by:
push in class ProtocolSession
Parameters:
message - The incoming event/message.
fromSession - The protocol session from which the message came.
Returns:
true if the method executed without error

handle_event

public boolean handle_event()
This process handles both externally and internally generated BGP events.

Returns:
true if the method executes without error

die

public void die()
Kills the BGP process. All BGP activity stops.


restart

public void restart()
Restarts the BGP process. Ideally, all state should be reset to its initial state. However, the current implementation is kludgy and not all state is lost when BGP dies.