INET Framework for OMNeT++/OMNEST
inet::bgp::BGPSession Class Reference

#include <BGPSession.h>

Inheritance diagram for inet::bgp::BGPSession:

Public Member Functions

 BGPSession (BGPRouting &_bgpRouting)
 
virtual ~BGPSession ()
 
void startConnection ()
 
void restartsHoldTimer ()
 
void restartsKeepAliveTimer ()
 
void restartsConnectRetryTimer (bool start=true)
 
void sendOpenMessage ()
 
void sendKeepAliveMessage ()
 
void addUpdateMsgSent ()
 
void listenConnectionFromPeer ()
 
void openTCPConnectionToPeer ()
 
SessionID findAndStartNextSession (BGPSessionType type)
 
void setInfo (SessionInfo info)
 
void setTimers (simtime_t *delayTab)
 
void setlinkIntf (InterfaceEntry *intf)
 
void setSocket (TCPSocket *socket)
 
void setSocketListen (TCPSocket *socket)
 
void getStatistics (unsigned int *statTab)
 
bool isEstablished ()
 
SessionID getSessionID ()
 
BGPSessionType getType ()
 
InterfaceEntrygetLinkIntf ()
 
IPv4Address getPeerAddr ()
 
TCPSocketgetSocket ()
 
TCPSocketgetSocketListen ()
 
IIPv4RoutingTablegetIPRoutingTable ()
 
std::vector< RoutingTableEntry * > getBGPRoutingTable ()
 
Macho::Machine< fsm::TopState > & getFSM ()
 
bool checkExternalRoute (const IPv4Route *ospfRoute)
 
void updateSendProcess (RoutingTableEntry *entry)
 

Private Attributes

SessionInfo _info
 
BGPRouting_bgpRouting
 
simtime_t _StartEventTime
 
cMessage * _ptrStartEvent
 
unsigned int _connectRetryCounter
 
simtime_t _connectRetryTime
 
cMessage * _ptrConnectRetryTimer
 
simtime_t _holdTime
 
cMessage * _ptrHoldTimer
 
simtime_t _keepAliveTime
 
cMessage * _ptrKeepAliveTimer
 
unsigned int _openMsgSent
 
unsigned int _openMsgRcv
 
unsigned int _keepAliveMsgSent
 
unsigned int _keepAliveMsgRcv
 
unsigned int _updateMsgSent
 
unsigned int _updateMsgRcv
 
fsm::TopState::Box * _box
 
Macho::Machine< fsm::TopState > * _fsm
 

Static Private Attributes

static const int BGP_RETRY_TIME = 120
 
static const int BGP_HOLD_TIME = 180
 
static const int BGP_KEEP_ALIVE = 60
 
static const int NB_SEC_START_EGP_SESSION = 1
 

Friends

struct fsm::Idle
 
struct fsm::Connect
 
struct fsm::Active
 
struct fsm::OpenSent
 
struct fsm::OpenConfirm
 
struct fsm::Established
 

Constructor & Destructor Documentation

inet::bgp::BGPSession::BGPSession ( BGPRouting _bgpRouting)
33 {
34  _box = new fsm::TopState::Box(*this);
35  _fsm = new Macho::Machine<fsm::TopState>(_box);
36  _info.sessionEstablished = false;
37 };
cMessage * _ptrStartEvent
Definition: BGPSession.h:85
SessionInfo _info
Definition: BGPSession.h:75
fsm::TopState::Box * _box
Definition: BGPSession.h:103
simtime_t _connectRetryTime
Definition: BGPSession.h:87
unsigned int _connectRetryCounter
Definition: BGPSession.h:86
cMessage * _ptrConnectRetryTimer
Definition: BGPSession.h:88
unsigned int _keepAliveMsgRcv
Definition: BGPSession.h:98
static const int BGP_KEEP_ALIVE
Definition: BGPSession.h:80
unsigned int _openMsgSent
Definition: BGPSession.h:95
cMessage * _ptrKeepAliveTimer
Definition: BGPSession.h:92
bool sessionEstablished
Definition: BGPCommon.h:65
cMessage * _ptrHoldTimer
Definition: BGPSession.h:90
Macho::Machine< fsm::TopState > * _fsm
Definition: BGPSession.h:104
simtime_t _holdTime
Definition: BGPSession.h:89
unsigned int _updateMsgRcv
Definition: BGPSession.h:100
unsigned int _updateMsgSent
Definition: BGPSession.h:99
simtime_t _keepAliveTime
Definition: BGPSession.h:91
static const int BGP_HOLD_TIME
Definition: BGPSession.h:79
unsigned int _openMsgRcv
Definition: BGPSession.h:96
static const int BGP_RETRY_TIME
Definition: BGPSession.h:78
unsigned int _keepAliveMsgSent
Definition: BGPSession.h:97
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
inet::bgp::BGPSession::~BGPSession ( )
virtual
40 {
45  delete _info.socket;
46  delete _info.socketListen;
47  delete _fsm;
48 }
cMessage * _ptrStartEvent
Definition: BGPSession.h:85
SessionInfo _info
Definition: BGPSession.h:75
cMessage * _ptrConnectRetryTimer
Definition: BGPSession.h:88
TCPSocket * socket
Definition: BGPCommon.h:63
TCPSocket * socketListen
Definition: BGPCommon.h:64
void getCancelAndDelete(cMessage *msg)
Definition: BGPRouting.h:64
cMessage * _ptrKeepAliveTimer
Definition: BGPSession.h:92
cMessage * _ptrHoldTimer
Definition: BGPSession.h:90
Macho::Machine< fsm::TopState > * _fsm
Definition: BGPSession.h:104
BGPRouting & _bgpRouting
Definition: BGPSession.h:76

Member Function Documentation

void inet::bgp::BGPSession::addUpdateMsgSent ( )
inline
47 { _updateMsgSent++; }
unsigned int _updateMsgSent
Definition: BGPSession.h:99
bool inet::bgp::BGPSession::checkExternalRoute ( const IPv4Route ospfRoute)
inline
71 { return _bgpRouting.checkExternalRoute(ospfRoute); }
bool checkExternalRoute(const IPv4Route *ospfRoute)
check if the route is in OSPF external IPv4RoutingTable
Definition: BGPRouting.cc:448
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
SessionID inet::bgp::BGPSession::findAndStartNextSession ( BGPSessionType  type)
inline
50 { return _bgpRouting.findNextSession(type, true); }
SessionID findNextSession(BGPSessionType type, bool startSession=false)
find the next SessionID compared to his type and start this session if boolean is true ...
Definition: BGPRouting.cc:799
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
std::vector<RoutingTableEntry *> inet::bgp::BGPSession::getBGPRoutingTable ( )
inline
69 { return _bgpRouting.getBGPRoutingTable(); }
std::vector< RoutingTableEntry * > getBGPRoutingTable()
Definition: BGPRouting.h:68
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
Macho::Machine<fsm::TopState>& inet::bgp::BGPSession::getFSM ( )
inline

Referenced by inet::bgp::BGPRouting::handleTimer().

70 { return *_fsm; }
Macho::Machine< fsm::TopState > * _fsm
Definition: BGPSession.h:104
IIPv4RoutingTable* inet::bgp::BGPSession::getIPRoutingTable ( )
inline
68 { return _bgpRouting.getIPRoutingTable(); }
IIPv4RoutingTable * getIPRoutingTable()
Definition: BGPRouting.h:67
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
InterfaceEntry* inet::bgp::BGPSession::getLinkIntf ( )
inline
64 { return _info.linkIntf; }
SessionInfo _info
Definition: BGPSession.h:75
InterfaceEntry * linkIntf
Definition: BGPCommon.h:62
IPv4Address inet::bgp::BGPSession::getPeerAddr ( )
inline
65 { return _info.peerAddr; }
SessionInfo _info
Definition: BGPSession.h:75
IPv4Address peerAddr
Definition: BGPCommon.h:61
SessionID inet::bgp::BGPSession::getSessionID ( )
inline
62 { return _info.sessionID; }
SessionInfo _info
Definition: BGPSession.h:75
SessionID sessionID
Definition: BGPCommon.h:57
TCPSocket* inet::bgp::BGPSession::getSocket ( )
inline
66 { return _info.socket; }
SessionInfo _info
Definition: BGPSession.h:75
TCPSocket * socket
Definition: BGPCommon.h:63
TCPSocket* inet::bgp::BGPSession::getSocketListen ( )
inline
67 { return _info.socketListen; }
SessionInfo _info
Definition: BGPSession.h:75
TCPSocket * socketListen
Definition: BGPCommon.h:64
void inet::bgp::BGPSession::getStatistics ( unsigned int *  statTab)
138 {
139  statTab[0] += _openMsgSent;
140  statTab[1] += _openMsgRcv;
141  statTab[2] += _keepAliveMsgSent;
142  statTab[3] += _keepAliveMsgRcv;
143  statTab[4] += _updateMsgSent;
144  statTab[5] += _updateMsgRcv;
145 }
unsigned int _keepAliveMsgRcv
Definition: BGPSession.h:98
unsigned int _openMsgSent
Definition: BGPSession.h:95
unsigned int _updateMsgRcv
Definition: BGPSession.h:100
unsigned int _updateMsgSent
Definition: BGPSession.h:99
unsigned int _openMsgRcv
Definition: BGPSession.h:96
unsigned int _keepAliveMsgSent
Definition: BGPSession.h:97
BGPSessionType inet::bgp::BGPSession::getType ( )
inline
63 { return _info.sessionType; }
SessionInfo _info
Definition: BGPSession.h:75
BGPSessionType sessionType
Definition: BGPCommon.h:58
bool inet::bgp::BGPSession::isEstablished ( )
inline
61 { return _info.sessionEstablished; }
SessionInfo _info
Definition: BGPSession.h:75
bool sessionEstablished
Definition: BGPCommon.h:65
void inet::bgp::BGPSession::listenConnectionFromPeer ( )
inline
SessionInfo _info
Definition: BGPSession.h:75
void listenConnectionFromPeer(SessionID sessionID)
active listenSocket for a given session (used by fsm)
Definition: BGPRouting.cc:130
SessionID sessionID
Definition: BGPCommon.h:57
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
void inet::bgp::BGPSession::openTCPConnectionToPeer ( )
inline
SessionInfo _info
Definition: BGPSession.h:75
SessionID sessionID
Definition: BGPCommon.h:57
void openTCPConnectionToPeer(SessionID sessionID)
active TCPConnection for a given session (used by fsm)
Definition: BGPRouting.cc:146
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
void inet::bgp::BGPSession::restartsConnectRetryTimer ( bool  start = true)
113 {
115  if (!start) {
117  }
118 }
simtime_t _connectRetryTime
Definition: BGPSession.h:87
cMessage * _ptrConnectRetryTimer
Definition: BGPSession.h:88
simtime_t getSimTime()
Definition: BGPRouting.h:63
cMessage * getCancelEvent(cMessage *msg)
Definition: BGPRouting.h:65
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
void getScheduleAt(simtime_t t, cMessage *msg)
Definition: BGPRouting.h:62
void inet::bgp::BGPSession::restartsHoldTimer ( )
99 {
100  if (_holdTime != 0) {
103  }
104 }
simtime_t getSimTime()
Definition: BGPRouting.h:63
cMessage * _ptrHoldTimer
Definition: BGPSession.h:90
simtime_t _holdTime
Definition: BGPSession.h:89
cMessage * getCancelEvent(cMessage *msg)
Definition: BGPRouting.h:65
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
void getScheduleAt(simtime_t t, cMessage *msg)
Definition: BGPRouting.h:62
void inet::bgp::BGPSession::restartsKeepAliveTimer ( )
107 {
110 }
simtime_t getSimTime()
Definition: BGPRouting.h:63
cMessage * _ptrKeepAliveTimer
Definition: BGPSession.h:92
simtime_t _keepAliveTime
Definition: BGPSession.h:91
cMessage * getCancelEvent(cMessage *msg)
Definition: BGPRouting.h:65
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
void getScheduleAt(simtime_t t, cMessage *msg)
Definition: BGPRouting.h:62
void inet::bgp::BGPSession::sendKeepAliveMessage ( )
131 {
132  BGPKeepAliveMessage *keepAliveMsg = new BGPKeepAliveMessage("BGPKeepAlive");
133  _info.socket->send(keepAliveMsg);
135 }
SessionInfo _info
Definition: BGPSession.h:75
TCPSocket * socket
Definition: BGPCommon.h:63
void send(cMessage *msg)
Sends data packet.
Definition: TCPSocket.cc:175
unsigned int _keepAliveMsgSent
Definition: BGPSession.h:97
void inet::bgp::BGPSession::sendOpenMessage ( )
121 {
122  BGPOpenMessage *openMsg = new BGPOpenMessage("BGPOpen");
123  openMsg->setMyAS(_info.ASValue);
124  openMsg->setHoldTime(_holdTime);
125  openMsg->setBGPIdentifier(_info.socket->getLocalAddress().toIPv4());
126  _info.socket->send(openMsg);
127  _openMsgSent++;
128 }
SessionInfo _info
Definition: BGPSession.h:75
TCPSocket * socket
Definition: BGPCommon.h:63
unsigned int _openMsgSent
Definition: BGPSession.h:95
L3Address getLocalAddress()
Definition: TCPSocket.h:215
simtime_t _holdTime
Definition: BGPSession.h:89
void send(cMessage *msg)
Sends data packet.
Definition: TCPSocket.cc:175
IPv4Address toIPv4() const
Definition: L3Address.h:76
ASID ASValue
Definition: BGPCommon.h:59
void inet::bgp::BGPSession::setInfo ( SessionInfo  info)

Referenced by inet::bgp::BGPRouting::createSession().

51 {
52  _info.sessionType = info.sessionType;
53  _info.ASValue = info.ASValue;
54  _info.routerID = info.routerID;
55  _info.peerAddr = info.peerAddr;
56  _info.sessionID = info.sessionID;
57  _info.linkIntf = info.linkIntf;
58  _info.socket = new TCPSocket();
59 }
SessionInfo _info
Definition: BGPSession.h:75
TCPSocket * socket
Definition: BGPCommon.h:63
SessionID sessionID
Definition: BGPCommon.h:57
BGPSessionType sessionType
Definition: BGPCommon.h:58
InterfaceEntry * linkIntf
Definition: BGPCommon.h:62
IPv4Address routerID
Definition: BGPCommon.h:60
IPv4Address peerAddr
Definition: BGPCommon.h:61
ASID ASValue
Definition: BGPCommon.h:59
void inet::bgp::BGPSession::setlinkIntf ( InterfaceEntry intf)
inline
55 { _info.linkIntf = intf; }
SessionInfo _info
Definition: BGPSession.h:75
InterfaceEntry * linkIntf
Definition: BGPCommon.h:62
void inet::bgp::BGPSession::setSocket ( TCPSocket socket)
inline
56 { delete _info.socket; _info.socket = socket; }
SessionInfo _info
Definition: BGPSession.h:75
TCPSocket * socket
Definition: BGPCommon.h:63
void inet::bgp::BGPSession::setSocketListen ( TCPSocket socket)
inline
57 { delete _info.socketListen; _info.socketListen = socket; }
SessionInfo _info
Definition: BGPSession.h:75
TCPSocket * socketListen
Definition: BGPCommon.h:64
void inet::bgp::BGPSession::setTimers ( simtime_t *  delayTab)
62 {
63  _connectRetryTime = delayTab[0];
64  _holdTime = delayTab[1];
65  _keepAliveTime = delayTab[2];
66  if (_info.sessionType == IGP) {
67  _StartEventTime = delayTab[3];
68  }
69  else if (delayTab[3] != SIMTIME_ZERO) {
70  _StartEventTime = delayTab[3];
71  _ptrStartEvent = new cMessage("BGP Start", START_EVENT_KIND);
73  _ptrStartEvent->setContextPointer(this);
74  }
75  _ptrConnectRetryTimer = new cMessage("BGP Connect Retry", CONNECT_RETRY_KIND);
76  _ptrHoldTimer = new cMessage("BGP Hold Timer", HOLD_TIME_KIND);
77  _ptrKeepAliveTimer = new cMessage("BGP Keep Alive Timer", KEEP_ALIVE_KIND);
78 
79  _ptrConnectRetryTimer->setContextPointer(this);
80  _ptrHoldTimer->setContextPointer(this);
81  _ptrKeepAliveTimer->setContextPointer(this);
82 }
cMessage * _ptrStartEvent
Definition: BGPSession.h:85
SessionInfo _info
Definition: BGPSession.h:75
simtime_t _connectRetryTime
Definition: BGPSession.h:87
cMessage * _ptrConnectRetryTimer
Definition: BGPSession.h:88
simtime_t _StartEventTime
Definition: BGPSession.h:84
simtime_t getSimTime()
Definition: BGPRouting.h:63
cMessage * _ptrKeepAliveTimer
Definition: BGPSession.h:92
cMessage * _ptrHoldTimer
Definition: BGPSession.h:90
const unsigned char CONNECT_RETRY_KIND
Definition: BGPCommon.h:37
simtime_t _holdTime
Definition: BGPSession.h:89
BGPSessionType sessionType
Definition: BGPCommon.h:58
simtime_t _keepAliveTime
Definition: BGPSession.h:91
const unsigned char HOLD_TIME_KIND
Definition: BGPCommon.h:38
const unsigned char KEEP_ALIVE_KIND
Definition: BGPCommon.h:39
Definition: BGPCommon_m.h:47
const unsigned char START_EVENT_KIND
Definition: BGPCommon.h:36
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
void getScheduleAt(simtime_t t, cMessage *msg)
Definition: BGPRouting.h:62
void inet::bgp::BGPSession::startConnection ( )
85 {
86  if (_ptrStartEvent == nullptr) {
87  _ptrStartEvent = new cMessage("BGP Start", START_EVENT_KIND);
88  }
89  if (_info.sessionType == IGP) {
92  }
94  _ptrStartEvent->setContextPointer(this);
95  }
96 }
cMessage * _ptrStartEvent
Definition: BGPSession.h:85
SessionInfo _info
Definition: BGPSession.h:75
simtime_t _StartEventTime
Definition: BGPSession.h:84
simtime_t getSimTime()
Definition: BGPRouting.h:63
BGPSessionType sessionType
Definition: BGPCommon.h:58
Definition: BGPCommon_m.h:47
const unsigned char START_EVENT_KIND
Definition: BGPCommon.h:36
BGPRouting & _bgpRouting
Definition: BGPSession.h:76
void getScheduleAt(simtime_t t, cMessage *msg)
Definition: BGPRouting.h:62
void inet::bgp::BGPSession::updateSendProcess ( RoutingTableEntry entry)
inline
SessionInfo _info
Definition: BGPSession.h:75
const unsigned char NEW_SESSION_ESTABLISHED
Definition: BGPCommon.h:47
void updateSendProcess(const unsigned char decisionProcessResult, SessionID sessionIndex, RoutingTableEntry *entry)
RFC 4271, 9.2 : Update-Send Process / Sent or not new UPDATE messages to its peers.
Definition: BGPRouting.cc:385
SessionID sessionID
Definition: BGPCommon.h:57
BGPRouting & _bgpRouting
Definition: BGPSession.h:76

Friends And Related Function Documentation

friend struct fsm::Active
friend
friend struct fsm::Connect
friend
friend struct fsm::Established
friend
friend struct fsm::Idle
friend
friend struct fsm::OpenConfirm
friend
friend struct fsm::OpenSent
friend

Member Data Documentation

fsm::TopState::Box* inet::bgp::BGPSession::_box
private

Referenced by BGPSession().

unsigned int inet::bgp::BGPSession::_connectRetryCounter
private
simtime_t inet::bgp::BGPSession::_connectRetryTime
private
Macho::Machine<fsm::TopState>* inet::bgp::BGPSession::_fsm
private

Referenced by BGPSession(), and ~BGPSession().

simtime_t inet::bgp::BGPSession::_holdTime
private
unsigned int inet::bgp::BGPSession::_keepAliveMsgRcv
private

Referenced by getStatistics().

unsigned int inet::bgp::BGPSession::_keepAliveMsgSent
private
simtime_t inet::bgp::BGPSession::_keepAliveTime
private
unsigned int inet::bgp::BGPSession::_openMsgRcv
private

Referenced by getStatistics().

unsigned int inet::bgp::BGPSession::_openMsgSent
private

Referenced by getStatistics(), and sendOpenMessage().

cMessage* inet::bgp::BGPSession::_ptrConnectRetryTimer
private
cMessage* inet::bgp::BGPSession::_ptrHoldTimer
private
cMessage* inet::bgp::BGPSession::_ptrKeepAliveTimer
private
cMessage* inet::bgp::BGPSession::_ptrStartEvent
private
simtime_t inet::bgp::BGPSession::_StartEventTime
private

Referenced by setTimers(), and startConnection().

unsigned int inet::bgp::BGPSession::_updateMsgRcv
private

Referenced by getStatistics().

unsigned int inet::bgp::BGPSession::_updateMsgSent
private

Referenced by getStatistics().

const int inet::bgp::BGPSession::BGP_HOLD_TIME = 180
staticprivate
const int inet::bgp::BGPSession::BGP_KEEP_ALIVE = 60
staticprivate
const int inet::bgp::BGPSession::BGP_RETRY_TIME = 120
staticprivate
const int inet::bgp::BGPSession::NB_SEC_START_EGP_SESSION = 1
staticprivate

The documentation for this class was generated from the following files: