SSF.OS.BGP4
Class PeerEntry

java.lang.Object
  |
  +--SSF.OS.BGP4.PeerEntry

public class PeerEntry
extends java.lang.Object

This class encapsulates the data that a BGP speaker would keep for one of its peers. The member data are generally named and explained from the point of view of a BGPSession instance.


Field Summary
 java.util.HashMap adv_nlri
          A table of NLRI recently advertised to this peer, used only when rate limiting is done on a per-peer, per-destination basis.
 java.lang.String as_nh
          The NHI address prefix of the AS in which this peer resides.
 BGPSession bgp
          The BGPSession to which this peer information applies.
 IPaddress bgp_id
          The BGP ID of this peer.
static byte CLIENT_FLAG
          The value of the flag bit which indicates if this peer is a route reflector client.
static byte CONNECTED_FLAG
          The value of the flag bit which indicates whether or not a connection with this (potential) peer has been established yet.
 byte connection_state
          The state that the local BGP speaker is in for this peer.
 EventTimer crt
          The ConnectRetry Timer, for spacing out attempts to establish a connection with this peer.
 boolean down_initialized
          Whether or not the down phase of a certain type of experiment has yet begun.
static java.lang.Boolean FALSE
          Indicates a null value which is treated as the boolean 'false'.
static byte FIRSTCONNECT_FLAG
          The value of the flag bit which indicates whether or not a socket connection has yet been attempted with this peer.
 byte flags
          Flags for indicating several attributes of this peer, including whether or not is internal; whether or not it is a route reflector client; and what state its write socket is in.
 long hold_timer_interval
          The maximum amount of time (in clock ticks) which can elapse without any BGP message being received from this peer before the connection is broken.
 EventTimer ht
          The Hold Timer, for timing out connections with peers.
 NIC iface
          The physical interface on the local router through which outgoing messages to this peer travel.
 Rule in_policy
          The policy rule to be applied for filtering inbound routes.
static byte INTERNAL_FLAG
          The value of the flag bit which indicates if this is an internal (IBGP) peer.
 int inupdates
          The number of updates received from this peer during the current session.
 IPaddress ip_addr
          The IP address of the interface on the peer's router which is linked to an interface on the local router.
 EventTimer ka
          The KeepAlive Timer, for helping to ensure this peer doesn't time out its connection with us.
 long keep_alive_interval
          The maximum amount of time (in clock ticks) which can elapse between messages sent to this peer (or else there's a risk that the peer could break the connection).
 double keephold_ratio
          The ratio between the configured values of the Keep Alive and Hold Timer Intervals.
 java.util.HashMap last_sent
          Keeps track of the routes most recently sent to this peer for each destination.
 int latest_sent_burst_id
          The ID of the latest burst of updates which were sent.
 long mrai
          The Minimum Route Advertisement Interval.
 java.util.HashMap mrais
          A table of Minimum Route Advertisement Interval Timers.
 EventTimer mraiTimer
          The Minimum Route Advertisement Interval Timer used when per-peer rate-limiting only (no per-destination) is in use.
 java.lang.String nh
          The NH part of the NHI address of this peer.
 java.lang.String nhi
          The NHI address of this peer.
 boolean noticeUpdateWaiting
          Whether or not a NoticeUpdate event from this peer is waiting in the WeightedInBuffer after another non-NoticeUpdate event.
 Rule out_policy
          The policy rule to be applied for filtering outbound routes.
 int outupdates
          The number of updates sent to this peer during the current session.
 tcpSocket readsocket
          The socket for receiving messages from this peer.
 boolean reset_flag
          A flag to indicate that as soon as a new write socket is established with this peer, a Notification should be sent to reset on it.
 IPaddress return_ip
          The local IP address that this peer uses as a destination when sending packets here.
 AdjRIBIn rib_in
          The section of Adj-RIBs-In associated with this peer.
 AdjRIBOut rib_out
          The section of Adj-RIBs-Out associated with this peer.
static java.lang.Boolean TRUE
          Indicates a non-null value which is treated as the boolean 'true'.
 java.util.HashMap waiting_adv
          A table of prefixes that are waiting to be advertised to this peer.
 java.util.HashMap waiting_wds
          A table of prefixes which are waiting to be withdrawn from this peer.
 java.util.HashMap wdn_nlri
          A table of NLRI recently withdrawn from this peer, used only when rate limiting is done on a per-peer, per-destination basis.
static byte WRITECONNECTED_FLAG
          The value of the flag bit which indicates whether or not an outgoing socket connection has been established.
static byte WRITECONNECTING_FLAG
          The value of the flag bit which, if set, indicates that either the outgoing socket connection has been established, or there is an attempt currently underway to establish it.
 java.util.ArrayList writeq
          A queue of writes waiting to be performed on the write socket.
 tcpSocket writesocket
          The socket for sending message to this peer.
static byte WRITING_FLAG
          The value of the flag bit which indicates whether or not the socket used for sending messages to this peer is busy.
 
Constructor Summary
PeerEntry(BGPSession b)
          Constructs a special peer entry which represents the local BGP speaker.
PeerEntry(BGPSession b, boolean in, boolean cli, int ind)
          Constructs a peer entry with a reference to the associated BGP protocol session as well as type information.
PeerEntry(BGPSession b, java.lang.String nhipre, int ind)
          Constructs a peer entry with a reference to the associated BGP protocol session and the NHI prefix of the peer.
 
Method Summary
 java.lang.String addr(boolean usenhi)
          Returns the address of the interface on the peer's router to which the local router has a point-to-point connection (whether virtual or not).
 void cancel_timers()
          Cancels all timers associated with this peer.
 boolean client()
          Returns whether or not the peer is a route reflector client.
 void close()
          Close socket connections with this peer, but not immediately.
 void connect()
          Attempts to establish a socket connection with this peer.
 boolean connected()
          Returns whether or not a connection with this (potential) peer has been established yet.
 void doclose()
          Close socket connections with this peer (both read and write).
 void doclose(boolean closeRead, boolean closeWrite)
          Close socket connections with this peer.
 boolean equals(java.lang.Object pe)
          Determines whether two peer entries are equal.
 boolean firstconnect()
          Returns whether or not a socket connection has yet been attempted with this peer.
 int hashCode()
          Returns a hash code value which can be used if a peer entry is used as a key in a hash table.
 boolean internal()
          Returns whether or not the peer is internal (IBGP).
 boolean reading(tcpSocket rsock)
          Returns whether or not the socket used for receiving messages from this peer is busy.
 void receive()
          Receives BGP messages from the socket connection with this peer.
 void reset()
          Resets peer to initial state (when a peering session is terminated, for example).
 void send(Message msg)
          Attempt to send a message to this peer.
 void set_client(boolean b)
          Sets whether or not the peer is a route reflector client.
 void set_connected(boolean b)
          Sets whether or not a connection with this (potential) peer has been established yet.
 void set_firstconnect(boolean b)
          Sets whether or not a socket connection has yet been attempted with this peer.
 void set_internal(boolean b)
          Sets whether or not the peer is internal (IBGP).
 void set_reading(tcpSocket rsock, boolean b)
          Sets whether or not the socket used for receiving messages from this peer is busy
 void set_writeconnected(tcpSocket wsock, boolean b)
          Sets whether or not an outgoing socket connection has been established.
 void set_writeconnecting(tcpSocket wsock, boolean b)
          Sets a flag which, if true, indicates that either the outgoing socket connection has been established, or there is an attempt currently underway to establish it.
 void set_writing(tcpSocket wsock, boolean b)
          Sets whether or not the socket used for sending messages to this peer is busy.
 void write_close(tcpSocket wsocket)
          Close write socket connection with this peer.
 boolean writeconnected(tcpSocket wsock)
          Returns whether or not an outgoing socket connection has been established.
 boolean writeconnecting(tcpSocket wsock)
          If either the outgoing socket connection has been established, or there is an attempt currently underway to establish it, then true is returned.
 boolean writing(tcpSocket wsock)
          Returns whether or not the socket used for sending messages to this peer is busy.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERNAL_FLAG

public static final byte INTERNAL_FLAG
The value of the flag bit which indicates if this is an internal (IBGP) peer.

See Also:
Constant Field Values

CLIENT_FLAG

public static final byte CLIENT_FLAG
The value of the flag bit which indicates if this peer is a route reflector client. The flag is only relevant if the peer is internal.

See Also:
flags, Constant Field Values

CONNECTED_FLAG

public static final byte CONNECTED_FLAG
The value of the flag bit which indicates whether or not a connection with this (potential) peer has been established yet.

See Also:
flags, Constant Field Values

FIRSTCONNECT_FLAG

public static final byte FIRSTCONNECT_FLAG
The value of the flag bit which indicates whether or not a socket connection has yet been attempted with this peer.

See Also:
flags, Constant Field Values

WRITING_FLAG

public static final byte WRITING_FLAG
The value of the flag bit which indicates whether or not the socket used for sending messages to this peer is busy. A busy socket means that a write is currently in progress.

See Also:
flags, Constant Field Values

WRITECONNECTING_FLAG

public static final byte WRITECONNECTING_FLAG
The value of the flag bit which, if set, indicates that either the outgoing socket connection has been established, or there is an attempt currently underway to establish it. The two cases can be distinguished by the corresponding value of the 'writeconnected' bit.

See Also:
flags, Constant Field Values

WRITECONNECTED_FLAG

public static final byte WRITECONNECTED_FLAG
The value of the flag bit which indicates whether or not an outgoing socket connection has been established.

See Also:
flags, Constant Field Values

bgp

public BGPSession bgp
The BGPSession to which this peer information applies.


flags

public byte flags
Flags for indicating several attributes of this peer, including whether or not is internal; whether or not it is a route reflector client; and what state its write socket is in.

See Also:
INTERNAL_FLAG, CLIENT_FLAG, CONNECTED_FLAG, FIRSTCONNECT_FLAG, WRITING_FLAG, WRITECONNECTING_FLAG, WRITECONNECTED_FLAG

nhi

public java.lang.String nhi
The NHI address of this peer. Specifically, the NHI address of the interface on the peer's router.


nh

public java.lang.String nh
The NH part of the NHI address of this peer.


return_ip

public IPaddress return_ip
The local IP address that this peer uses as a destination when sending packets here. For internal peers, this is typically the address of a virtual (loopback) interface, and for external peers it is typically the address of a physical interface on a point-to-point link directly connecting the two BGP speakers.


ip_addr

public IPaddress ip_addr
The IP address of the interface on the peer's router which is linked to an interface on the local router.


bgp_id

public IPaddress bgp_id
The BGP ID of this peer.


as_nh

public java.lang.String as_nh
The NHI address prefix of the AS in which this peer resides.


iface

public NIC iface
The physical interface on the local router through which outgoing messages to this peer travel.


connection_state

public byte connection_state
The state that the local BGP speaker is in for this peer.


readsocket

public tcpSocket readsocket
The socket for receiving messages from this peer.


writesocket

public tcpSocket writesocket
The socket for sending message to this peer.


writeq

public java.util.ArrayList writeq
A queue of writes waiting to be performed on the write socket. The queue is necessary since a write may be issued before the previous write has successfully completed. (For a write to successfully complete, the underlying TCP session must receive an acknowledgement for the bytes that were sent.)


hold_timer_interval

public long hold_timer_interval
The maximum amount of time (in clock ticks) which can elapse without any BGP message being received from this peer before the connection is broken.


keep_alive_interval

public long keep_alive_interval
The maximum amount of time (in clock ticks) which can elapse between messages sent to this peer (or else there's a risk that the peer could break the connection).


mrai

public long mrai
The Minimum Route Advertisement Interval. It is the minimum amount of time (in clock ticks) which must elapse between the transmission of any two advertisements containing the same destination (NLRI) to this peer. This is the value of MRAI after jitter has been applied.


keephold_ratio

public double keephold_ratio
The ratio between the configured values of the Keep Alive and Hold Timer Intervals.


crt

public EventTimer crt
The ConnectRetry Timer, for spacing out attempts to establish a connection with this peer. (The terminology used here is not quite correct--technically, it's not a peer until the connection is established, only a potential peer.)


ht

public EventTimer ht
The Hold Timer, for timing out connections with peers.


ka

public EventTimer ka
The KeepAlive Timer, for helping to ensure this peer doesn't time out its connection with us.


mrais

public java.util.HashMap mrais
A table of Minimum Route Advertisement Interval Timers. These timers help ensure that this peer isn't flooded with several updates regarding the same destination (NLRI) in a short time. It does not apply to internal peers. The table is keyed by the NLRI.


mraiTimer

public EventTimer mraiTimer
The Minimum Route Advertisement Interval Timer used when per-peer rate-limiting only (no per-destination) is in use.


adv_nlri

public java.util.HashMap adv_nlri
A table of NLRI recently advertised to this peer, used only when rate limiting is done on a per-peer, per-destination basis. It is kept because BGP has limits on the number of times that the same NLRI can be sent within a given period of time to a given external peer. The NLRI is used as both key and value in the table.


wdn_nlri

public java.util.HashMap wdn_nlri
A table of NLRI recently withdrawn from this peer, used only when rate limiting is done on a per-peer, per-destination basis. It is analogous to adv_nlri, to be used when the Minimum Route Advertisement restriction is being applied to withdrawals. The NLRI is used as both key and value in the table.


waiting_adv

public java.util.HashMap waiting_adv
A table of prefixes that are waiting to be advertised to this peer. More specifically, each entry is keyed by such a prefix, but the value is a pair of objects indicating the route and the sender of the advertisement for the route. Prefixes can be waiting to be sent either because 1) an update with the same NLRI was sent recently (if per-peer, per-destination rate limiting is in use) or 2) an update with any prefix was sent recently (if per-peer rate limiting is in use).


waiting_wds

public java.util.HashMap waiting_wds
A table of prefixes which are waiting to be withdrawn from this peer. This is similar to the waiting_adv field, and is only used when the option to apply the Minimum Route Advertisement Interval restriction to withdrawals is in use. The prefix is used as both key and value in the table.


out_policy

public Rule out_policy
The policy rule to be applied for filtering outbound routes.


in_policy

public Rule in_policy
The policy rule to be applied for filtering inbound routes.


rib_in

public AdjRIBIn rib_in
The section of Adj-RIBs-In associated with this peer.


rib_out

public AdjRIBOut rib_out
The section of Adj-RIBs-Out associated with this peer.


last_sent

public java.util.HashMap last_sent
Keeps track of the routes most recently sent to this peer for each destination. If the most recent message for a given destination is a withdrawal, then there will be no entry for that destination in the table. Most of the time this information need not be kept, however, there are at least two cases for which it may be desired. Case 1: Suppose route X is advertised to the peer. Then, all within one MRAI, the following two changes occur: 1) route Y is chosen to replace X, and 2) route Y is invalidated, and route X is reverted to as the current best. If the MRAI ends without further route changes, X will be advertised to the peer, making two consecutive identical advertisements, which is not desirable. Case 2: Suppose route X is advertised to the peer. Then, within the following MRAI, these events occur: 1) X is explicitly withdrawn, 2) Y is learned and chosen for advertisement to the peer, but put in the waiting list because the MRAI Timer has not yet expired, 3) Y is invalidated, and as a consequence it is removed from the waiting list AND a withdrawal is sent to the peer, making it the second consecutive withdrawal. Without knowing that the previously sent message was a withdrawal, the second withdrawal must be sent, because there's no way of knowing whether or not the waiting update Y was going to serve as an implicit withdrawal had it been sent.


noticeUpdateWaiting

public boolean noticeUpdateWaiting
Whether or not a NoticeUpdate event from this peer is waiting in the WeightedInBuffer after another non-NoticeUpdate event. This is a bit of a hack used to reduce repetitive NoticeUpdate events that can build up when a large number of Update messages are sent at about the same time (such as after a reeboot.)


inupdates

public int inupdates
The number of updates received from this peer during the current session.


outupdates

public int outupdates
The number of updates sent to this peer during the current session.


down_initialized

public boolean down_initialized
Whether or not the down phase of a certain type of experiment has yet begun. Not to be used in normal BGP operation.


reset_flag

public boolean reset_flag
A flag to indicate that as soon as a new write socket is established with this peer, a Notification should be sent to reset on it. This is to avoid cyclic behavior which can happen in some circumstances. See the comments in the code in BGPSession.java where reset_flag is set to true. Yes, this is a hack, but it only comes into play in experimental uses of the simulator (so far).


latest_sent_burst_id

public int latest_sent_burst_id
The ID of the latest burst of updates which were sent. (It doesn't count if they are waiting for the MRAI timer to expire.) Refer to BGPSession.burst_id.


FALSE

public static final java.lang.Boolean FALSE
Indicates a null value which is treated as the boolean 'false'.


TRUE

public static final java.lang.Boolean TRUE
Indicates a non-null value which is treated as the boolean 'true'.

Constructor Detail

PeerEntry

public PeerEntry(BGPSession b,
                 boolean in,
                 boolean cli,
                 int ind)
Constructs a peer entry with a reference to the associated BGP protocol session as well as type information.

Parameters:
b - The BGP protocol session with which this peer entry is associated.
in - A boolean indicating if the peer is internal.
cli - A boolean indicating if the peer is a route reflector client.

PeerEntry

public PeerEntry(BGPSession b,
                 java.lang.String nhipre,
                 int ind)
Constructs a peer entry with a reference to the associated BGP protocol session and the NHI prefix of the peer.

Parameters:
b - The BGP protocol session with which this peer entry is associated.
nhipre - The NHI prefix of the peer.

PeerEntry

public PeerEntry(BGPSession b)
Constructs 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.

Parameters:
b - The BGP protocol session at the local router.
Method Detail

equals

public boolean equals(java.lang.Object pe)
Determines whether two peer entries are equal. They are equal only if their NHI prefixes are equal.

Overrides:
equals in class java.lang.Object
Parameters:
pe - The peer entry with which to make the comparison.
Returns:
whether or not the two peer entries are equal

hashCode

public int hashCode()
Returns a hash code value which can be used if a peer entry is used as a key in a hash table.

Overrides:
hashCode in class java.lang.Object
Returns:
an integer hash code value

internal

public boolean internal()
Returns whether or not the peer is internal (IBGP).

Returns:
whether or not the peer is internal

set_internal

public void set_internal(boolean b)
Sets whether or not the peer is internal (IBGP). If not, it is external (EBGP).

Parameters:
b - Whether or not the peer is internal.

client

public boolean client()
Returns whether or not the peer is a route reflector client. This is only relevant if the peer is internal.

Returns:
whether or not the peer is a route reflector client

set_client

public void set_client(boolean b)
Sets whether or not the peer is a route reflector client. This is only relevant if the peer is internal.

Parameters:
b - Whether or not the peer is a route reflector client.

connected

public boolean connected()
Returns whether or not a connection with this (potential) peer has been established yet.

Returns:
whether or not a connection with this (potential) peer has been established yet

set_connected

public void set_connected(boolean b)
Sets whether or not a connection with this (potential) peer has been established yet.

Parameters:
b - Whether or not there is a connection established with this peer.

firstconnect

public boolean firstconnect()
Returns whether or not a socket connection has yet been attempted with this peer.

Returns:
whether or not a socket connection has yet been attempted with this peer

set_firstconnect

public void set_firstconnect(boolean b)
Sets whether or not a socket connection has yet been attempted with this peer.

Parameters:
b - Whether or not a socket connection has yet been attempted.

reading

public boolean reading(tcpSocket rsock)
Returns whether or not the socket used for receiving messages from this peer is busy. A busy socket means that a read is currently in progress.

Returns:
whether or not the socket used for receiving messages from this peer is busy

set_reading

public void set_reading(tcpSocket rsock,
                        boolean b)
Sets whether or not the socket used for receiving messages from this peer is busy

Parameters:
b - Whether or not the read socket is busy.

writing

public boolean writing(tcpSocket wsock)
Returns whether or not the socket used for sending messages to this peer is busy. A busy socket means that a write is currently in progress.

Returns:
Whether or not the socket used for sending messages to this peer is busy.

set_writing

public void set_writing(tcpSocket wsock,
                        boolean b)
Sets whether or not the socket used for sending messages to this peer is busy.

Parameters:
b - Whether or not the socket used for sending messages to this peer is busy

writeconnecting

public boolean writeconnecting(tcpSocket wsock)
If either the outgoing socket connection has been established, or there is an attempt currently underway to establish it, then true is returned. The two cases can be distinguished by the corresponding writeconnecting() method.

Returns:
true if either the outgoing socket connection has been established, or there is an attempt currently underway to establish it

set_writeconnecting

public void set_writeconnecting(tcpSocket wsock,
                                boolean b)
Sets a flag which, if true, indicates that either the outgoing socket connection has been established, or there is an attempt currently underway to establish it.

Parameters:
b - Whether or not the flag should be set.

writeconnected

public boolean writeconnected(tcpSocket wsock)
Returns whether or not an outgoing socket connection has been established.

Returns:
whether or not an outgoing socket connection has been established

set_writeconnected

public void set_writeconnected(tcpSocket wsock,
                               boolean b)
Sets whether or not an outgoing socket connection has been established.

Parameters:
b - Whether or not an outgoing socket connection has been established

addr

public final java.lang.String addr(boolean usenhi)
Returns the address of the interface on the peer's router to which the local router has a point-to-point connection (whether virtual or not). The address can be in IP or NHI form.

Parameters:
usenhi - Whether or not the address should be given in NHI form.
Returns:
the address of the peer's interface

connect

public final void connect()
Attempts to establish a socket connection with this peer.


receive

public final void receive()
Receives BGP messages from the socket connection with this peer.


send

public final void send(Message msg)
Attempt to send a message to this peer. If the socket is busy, the data to be written will be enqueued until the socket is free.

Parameters:
msg - A BGP message to be sent to the peer.

close

public final void close()
Close socket connections with this peer, but not immediately. Any messages in the outgoing buffer will be written first.


doclose

public final void doclose()
Close socket connections with this peer (both read and write).


doclose

public final void doclose(boolean closeRead,
                          boolean closeWrite)
Close socket connections with this peer. Either the read socket, write socket, or both may be closed.

Parameters:
closeRead - Whether or not to close the read socket.
closeWrite - Whether or not to close the write socket.

write_close

public final void write_close(tcpSocket wsocket)
Close write socket connection with this peer.


reset

public void reset()
Resets peer to initial state (when a peering session is terminated, for example).


cancel_timers

public void cancel_timers()
Cancels all timers associated with this peer.