本文整理汇总了Python中exabgp.bgp.timer.ReceiveTimer.check_ka方法的典型用法代码示例。如果您正苦于以下问题:Python ReceiveTimer.check_ka方法的具体用法?Python ReceiveTimer.check_ka怎么用?Python ReceiveTimer.check_ka使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exabgp.bgp.timer.ReceiveTimer
的用法示例。
在下文中一共展示了ReceiveTimer.check_ka方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _accept
# 需要导入模块: from exabgp.bgp.timer import ReceiveTimer [as 别名]
# 或者: from exabgp.bgp.timer.ReceiveTimer import check_ka [as 别名]
def _accept (self):
self._incoming.fsm.change(FSM.CONNECT)
# we can do this as Protocol is a mutable object
proto = self._incoming.proto
# send OPEN
message = Message.CODE.NOP
for message in proto.new_open(self._restarted):
if ord(message.TYPE) == Message.CODE.NOP:
yield ACTION.NOW
proto.negotiated.sent(message)
self._incoming.fsm.change(FSM.OPENSENT)
# Read OPEN
wait = environment.settings().bgp.openwait
opentimer = ReceiveTimer(self.me,wait,1,1,'waited for open too long, we do not like stuck in active')
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check without going to the other peer
for message in proto.read_open(self.neighbor.peer_address.top()):
opentimer.check_ka(message)
if ord(message.TYPE) == Message.CODE.NOP:
yield ACTION.LATER
self._incoming.fsm.change(FSM.OPENCONFIRM)
proto.negotiated.received(message)
proto.validate_open()
if self._outgoing.fsm == FSM.OPENCONFIRM:
self.logger.network('incoming connection finds the outgoing connection is in openconfirm')
local_id = self.neighbor.router_id.pack()
remote_id = proto.negotiated.received_open.router_id.pack()
if local_id < remote_id:
self.logger.network('closing the outgoing connection')
self._stop(self._outgoing,'collision local id < remote id')
yield ACTION.LATER
else:
self.logger.network('aborting the incoming connection')
raise Interrupted(self._incoming)
# Send KEEPALIVE
for message in self._incoming.proto.new_keepalive('OPENCONFIRM'):
yield ACTION.NOW
# Start keeping keepalive timer
self.recv_timer = ReceiveTimer(self.me,proto.negotiated.holdtime,4,0)
# Read KEEPALIVE
for message in proto.read_keepalive():
self.recv_timer.check_ka(message)
yield ACTION.NOW
self._incoming.fsm.change(FSM.ESTABLISHED)
# let the caller know that we were sucesfull
yield ACTION.NOW
示例2: _accept
# 需要导入模块: from exabgp.bgp.timer import ReceiveTimer [as 别名]
# 或者: from exabgp.bgp.timer.ReceiveTimer import check_ka [as 别名]
def _accept (self):
# we can do this as Protocol is a mutable object
proto = self._['in']['proto']
# send OPEN
for message in proto.new_open(self._restarted):
if ord(message.TYPE) == Message.ID.NOP:
yield ACTION.immediate
proto.negotiated.sent(message)
self._['in']['state'] = STATE.opensent
# Read OPEN
wait = environment.settings().bgp.openwait
opentimer = ReceiveTimer(self.me,wait,1,1,'waited for open too long, we do not like stuck in active')
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check without going to the other peer
for message in proto.read_open(self.neighbor.peer_address.ip):
opentimer.check_ka(message)
if ord(message.TYPE) == Message.ID.NOP:
yield ACTION.later
self._['in']['state'] = STATE.openconfirm
proto.negotiated.received(message)
proto.validate_open()
if self._['out']['state'] == STATE.openconfirm:
self.logger.network('incoming connection finds the outgoing connection is in openconfirm')
local_id = self.neighbor.router_id.packed
remote_id = proto.negotiated.received_open.router_id.packed
if local_id < remote_id:
self.logger.network('closing the outgoing connection')
self._stop('out','collision local id < remote id')
yield ACTION.later
else:
self.logger.network('aborting the incoming connection')
stop = Interrupted()
stop.direction = 'in'
raise stop
# Send KEEPALIVE
for message in self._['in']['proto'].new_keepalive('OPENCONFIRM'):
yield ACTION.immediate
# Start keeping keepalive timer
self.recv_timer = ReceiveTimer(self.me,proto.negotiated.holdtime,4,0)
# Read KEEPALIVE
for message in proto.read_keepalive():
self.recv_timer.check_ka(message)
yield ACTION.immediate
self._['in']['state'] = STATE.established
# let the caller know that we were sucesfull
yield ACTION.immediate
示例3: _read_open
# 需要导入模块: from exabgp.bgp.timer import ReceiveTimer [as 别名]
# 或者: from exabgp.bgp.timer.ReceiveTimer import check_ka [as 别名]
def _read_open (self):
wait = environment.settings().bgp.openwait
opentimer = ReceiveTimer(self.proto.connection.session,wait,1,1,'waited for open too long, we do not like stuck in active')
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check without going to the other peer
for message in self.proto.read_open(self.neighbor.peer_address.top()):
opentimer.check_ka(message)
# XXX: FIXME: change the whole code to use the ord and not the chr version
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check
if ordinal(message.TYPE) == Message.CODE.NOP:
yield ACTION.NOW
yield message
示例4: _read_open
# 需要导入模块: from exabgp.bgp.timer import ReceiveTimer [as 别名]
# 或者: from exabgp.bgp.timer.ReceiveTimer import check_ka [as 别名]
def _read_open (self):
wait = environment.settings().bgp.openwait
opentimer = ReceiveTimer(self.proto.connection.session,wait,1,1,'waited for open too long, we do not like stuck in active')
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check without going to the other peer
for message in self.proto.read_open(self.neighbor.peer_address.top()):
opentimer.check_ka(message)
# XXX: FIXME: change the whole code to use the ord and not the chr version
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check
if ordinal(message.TYPE) == Message.CODE.NOP:
# If a peer does not reply to OPEN message, or not enough bytes
# yielding ACTION.NOW can cause ExaBGP to busy spin trying to
# read from peer. See GH #723 .
yield ACTION.LATER
yield message
示例5: Peer
# 需要导入模块: from exabgp.bgp.timer import ReceiveTimer [as 别名]
# 或者: from exabgp.bgp.timer.ReceiveTimer import check_ka [as 别名]
#.........这里部分代码省略.........
connected = False
try:
for connected in generator:
if connected:
break
if self._teardown:
raise Stop()
# we want to come back as soon as possible
yield ACTION.LATER
self.proto = proto
except Stop:
# Connection failed
if not connected and self.proto:
self.proto.close('connection to %s:%d failed' % (self.neighbor.peer_address,self.neighbor.connect))
# A connection arrived before we could establish !
if not connected or self.proto:
yield ACTION.NOW
raise Interrupted()
def _send_open (self):
message = Message.CODE.NOP
for message in self.proto.new_open():
if ordinal(message.TYPE) == Message.CODE.NOP:
yield ACTION.NOW
yield message
def _read_open (self):
wait = environment.settings().bgp.openwait
opentimer = ReceiveTimer(self.proto.connection.session,wait,1,1,'waited for open too long, we do not like stuck in active')
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check without going to the other peer
for message in self.proto.read_open(self.neighbor.peer_address.top()):
opentimer.check_ka(message)
# XXX: FIXME: change the whole code to use the ord and not the chr version
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check
if ordinal(message.TYPE) == Message.CODE.NOP:
# If a peer does not reply to OPEN message, or not enough bytes
# yielding ACTION.NOW can cause ExaBGP to busy spin trying to
# read from peer. See GH #723 .
yield ACTION.LATER
yield message
def _send_ka (self):
for message in self.proto.new_keepalive('OPENCONFIRM'):
yield ACTION.NOW
def _read_ka (self):
# Start keeping keepalive timer
for message in self.proto.read_keepalive():
self.recv_timer.check_ka_timer(message)
yield ACTION.NOW
def _establish (self):
# try to establish the outgoing connection
self.fsm.change(FSM.ACTIVE)
if not self.proto:
for action in self._connect():
if action in ACTION.ALL:
yield action
self.fsm.change(FSM.CONNECT)
# normal sending of OPEN first ...
if self.neighbor.local_as:
示例6: _connect
# 需要导入模块: from exabgp.bgp.timer import ReceiveTimer [as 别名]
# 或者: from exabgp.bgp.timer.ReceiveTimer import check_ka [as 别名]
def _connect (self):
# try to establish the outgoing connection
proto = Protocol(self)
generator = proto.connect()
connected = False
try:
while not connected:
connected = generator.next()
# we want to come back as soon as possible
yield ACTION.later
except StopIteration:
# Connection failed
if not connected:
proto.close('connection to peer failed')
# A connection arrived before we could establish !
if not connected or self._['in']['proto']:
stop = Interrupted()
stop.direction = 'out'
raise stop
self._['out']['state'] = STATE.connect
self._['out']['proto'] = proto
# send OPEN
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to set the state without going to the other peer
for message in proto.new_open(self._restarted):
if ord(message.TYPE) == Message.ID.NOP:
yield ACTION.immediate
proto.negotiated.sent(message)
self._['out']['state'] = STATE.opensent
# Read OPEN
wait = environment.settings().bgp.openwait
opentimer = ReceiveTimer(self.me,wait,1,1,'waited for open too long, we do not like stuck in active')
for message in self._['out']['proto'].read_open(self.neighbor.peer_address.ip):
opentimer.check_ka(message)
# XXX: FIXME: change the whole code to use the ord and not the chr version
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check
if ord(message.TYPE) == Message.ID.NOP:
yield ACTION.later
self._['out']['state'] = STATE.openconfirm
proto.negotiated.received(message)
proto.validate_open()
if self._['in']['state'] == STATE.openconfirm:
self.logger.network('outgoing connection finds the incoming connection is in openconfirm')
local_id = self.neighbor.router_id.packed
remote_id = proto.negotiated.received_open.router_id.packed
if local_id < remote_id:
self.logger.network('aborting the outgoing connection')
stop = Interrupted()
stop.direction = 'out'
raise stop
else:
self.logger.network('closing the incoming connection')
self._stop('in','collision local id < remote id')
yield ACTION.later
# Send KEEPALIVE
for message in proto.new_keepalive('OPENCONFIRM'):
yield ACTION.immediate
# Start keeping keepalive timer
self.recv_timer = ReceiveTimer(self.me,proto.negotiated.holdtime,4,0)
# Read KEEPALIVE
for message in self._['out']['proto'].read_keepalive():
self.recv_timer.check_ka(message)
yield ACTION.immediate
self._['out']['state'] = STATE.established
# let the caller know that we were sucesfull
yield ACTION.immediate
示例7: Peer
# 需要导入模块: from exabgp.bgp.timer import ReceiveTimer [as 别名]
# 或者: from exabgp.bgp.timer.ReceiveTimer import check_ka [as 别名]
#.........这里部分代码省略.........
# if the other side fails, we go back to idle
if self._['in']['proto'] not in (True,False,None):
self.logger.network('we already have a peer at this address')
return False
self._['in']['proto'] = Protocol(self).accept(connection)
# Let's make sure we do some work with this connection
self._['in']['generator'] = None
self._['in']['state'] = STATE.connect
return True
def established (self):
return self._['in']['state'] == STATE.established or self._['out']['state'] == STATE.established
def _accept (self):
# we can do this as Protocol is a mutable object
proto = self._['in']['proto']
# send OPEN
for message in proto.new_open(self._restarted):
if ord(message.TYPE) == Message.ID.NOP:
yield ACTION.immediate
proto.negotiated.sent(message)
self._['in']['state'] = STATE.opensent
# Read OPEN
wait = environment.settings().bgp.openwait
opentimer = ReceiveTimer(self.me,wait,1,1,'waited for open too long, we do not like stuck in active')
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check without going to the other peer
for message in proto.read_open(self.neighbor.peer_address.ip):
opentimer.check_ka(message)
if ord(message.TYPE) == Message.ID.NOP:
yield ACTION.later
self._['in']['state'] = STATE.openconfirm
proto.negotiated.received(message)
proto.validate_open()
if self._['out']['state'] == STATE.openconfirm:
self.logger.network('incoming connection finds the outgoing connection is in openconfirm')
local_id = self.neighbor.router_id.packed
remote_id = proto.negotiated.received_open.router_id.packed
if local_id < remote_id:
self.logger.network('closing the outgoing connection')
self._stop('out','collision local id < remote id')
yield ACTION.later
else:
self.logger.network('aborting the incoming connection')
stop = Interrupted()
stop.direction = 'in'
raise stop
# Send KEEPALIVE
for message in self._['in']['proto'].new_keepalive('OPENCONFIRM'):
yield ACTION.immediate
# Start keeping keepalive timer
self.recv_timer = ReceiveTimer(self.me,proto.negotiated.holdtime,4,0)
# Read KEEPALIVE
for message in proto.read_keepalive():
self.recv_timer.check_ka(message)
yield ACTION.immediate
示例8: _connect
# 需要导入模块: from exabgp.bgp.timer import ReceiveTimer [as 别名]
# 或者: from exabgp.bgp.timer.ReceiveTimer import check_ka [as 别名]
def _connect (self):
# try to establish the outgoing connection
self._outgoing.fsm.change(FSM.CONNECT)
proto = Protocol(self)
generator = proto.connect()
connected = False
try:
while not connected:
if self._teardown:
raise StopIteration()
connected = generator.next()
# we want to come back as soon as possible
yield ACTION.LATER
except StopIteration:
# Connection failed
if not connected:
proto.close('connection to %s:%d failed' % (self.neighbor.peer_address,proto.port))
# A connection arrived before we could establish !
if not connected or self._incoming.proto:
yield ACTION.NOW
raise Interrupted(self._outgoing)
self._outgoing.proto = proto
# send OPEN
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to set the state without going to the other peer
message = Message.CODE.NOP
for message in proto.new_open(self._restarted):
if ord(message.TYPE) == Message.CODE.NOP:
yield ACTION.NOW
proto.negotiated.sent(message)
self._outgoing.fsm.change(FSM.OPENSENT)
# Read OPEN
wait = environment.settings().bgp.openwait
opentimer = ReceiveTimer(self.me,wait,1,1,'waited for open too long, we do not like stuck in active')
for message in self._outgoing.proto.read_open(self.neighbor.peer_address.top()):
opentimer.check_ka(message)
# XXX: FIXME: change the whole code to use the ord and not the chr version
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check
if ord(message.TYPE) == Message.CODE.NOP:
yield ACTION.LATER
self._outgoing.fsm.change(FSM.OPENCONFIRM)
proto.negotiated.received(message)
proto.validate_open()
if self._incoming.fsm == FSM.OPENCONFIRM:
self.logger.network('outgoing connection finds the incoming connection is in openconfirm')
local_id = self.neighbor.router_id.pack()
remote_id = proto.negotiated.received_open.router_id.pack()
if local_id < remote_id:
self.logger.network('aborting the outgoing connection')
raise Interrupted(self._outgoing)
else:
self.logger.network('closing the incoming connection')
self._stop(self._incoming,'collision local id < remote id')
yield ACTION.LATER
# Send KEEPALIVE
for message in proto.new_keepalive('OPENCONFIRM'):
yield ACTION.NOW
# Start keeping keepalive timer
self.recv_timer = ReceiveTimer(self.me,proto.negotiated.holdtime,4,0)
# Read KEEPALIVE
for message in self._outgoing.proto.read_keepalive():
self.recv_timer.check_ka(message)
yield ACTION.NOW
self._outgoing.fsm.change(FSM.ESTABLISHED)
# let the caller know that we were sucesfull
yield ACTION.NOW
示例9: Peer
# 需要导入模块: from exabgp.bgp.timer import ReceiveTimer [as 别名]
# 或者: from exabgp.bgp.timer.ReceiveTimer import check_ka [as 别名]
#.........这里部分代码省略.........
# self._incoming.fsm.change(FSM.ACTIVE)
self._incoming.proto = Protocol(self).accept(connection)
# Let's make sure we do some work with this connection
self._incoming.generator = None
return True
def established (self):
return self._incoming.fsm == FSM.ESTABLISHED or self._outgoing.fsm == FSM.ESTABLISHED
def _accept (self):
self._incoming.fsm.change(FSM.CONNECT)
# we can do this as Protocol is a mutable object
proto = self._incoming.proto
# send OPEN
message = Message.CODE.NOP
for message in proto.new_open(self._restarted):
if ord(message.TYPE) == Message.CODE.NOP:
yield ACTION.NOW
proto.negotiated.sent(message)
self._incoming.fsm.change(FSM.OPENSENT)
# Read OPEN
wait = environment.settings().bgp.openwait
opentimer = ReceiveTimer(self.me,wait,1,1,'waited for open too long, we do not like stuck in active')
# Only yield if we have not the open, otherwise the reactor can run the other connection
# which would be bad as we need to do the collission check without going to the other peer
for message in proto.read_open(self.neighbor.peer_address.top()):
opentimer.check_ka(message)
if ord(message.TYPE) == Message.CODE.NOP:
yield ACTION.LATER
self._incoming.fsm.change(FSM.OPENCONFIRM)
proto.negotiated.received(message)
proto.validate_open()
if self._outgoing.fsm == FSM.OPENCONFIRM:
self.logger.network('incoming connection finds the outgoing connection is in openconfirm')
local_id = self.neighbor.router_id.pack()
remote_id = proto.negotiated.received_open.router_id.pack()
if local_id < remote_id:
self.logger.network('closing the outgoing connection')
self._stop(self._outgoing,'collision local id < remote id')
yield ACTION.LATER
else:
self.logger.network('aborting the incoming connection')
raise Interrupted(self._incoming)
# Send KEEPALIVE
for message in self._incoming.proto.new_keepalive('OPENCONFIRM'):
yield ACTION.NOW
# Start keeping keepalive timer
self.recv_timer = ReceiveTimer(self.me,proto.negotiated.holdtime,4,0)
# Read KEEPALIVE
for message in proto.read_keepalive():
self.recv_timer.check_ka(message)
yield ACTION.NOW
self._incoming.fsm.change(FSM.ESTABLISHED)