Пример #1
0
    def _handle_bmp_session(self, socket):

        self._socket = socket
        # send init message
        init_info = {
            'type': bmp.BMP_INIT_TYPE_STRING,
            'value': u'This is Ryu BGP BMP message'
        }
        init_msg = bmp.BMPInitiation([init_info])
        self._send(init_msg)

        # send peer-up message for each peers
        peer_manager = self._core_service.peer_manager

        for peer in (p for p in peer_manager.iterpeers if p.in_established()):
            msg = self._construct_peer_up_notification(peer)
            self._send(msg)

            for path in peer._adj_rib_in.values():
                msg = self._construct_route_monitoring(peer, path)
                self._send(msg)

        # TODO periodically send stats to bmpstation

        while True:
            # bmpstation shouldn't send any packet to bmpclient.
            # this recv() is only meant to detect socket closed
            ret = self._socket.recv(1)
            if len(ret) == 0:
                LOG.debug('BMP socket is closed. retry connecting..')
                self._socket = None
                self._connect_retry_event.set()
                break
Пример #2
0
 def test_initiation(self):
     initiation_info = [{
         'type': bmp.BMP_INIT_TYPE_STRING,
         'value': u'This is Ryu BGP BMP message'
     }]
     msg = bmp.BMPInitiation(info=initiation_info)
     binmsg = msg.serialize()
     msg2, rest = bmp.BMPMessage.parser(binmsg)
     eq_(msg.to_jsondict(lambda v: v), msg2.to_jsondict(lambda v: v))
     eq_(rest, b'')