async def main(self, args):

        # Create endpoint objects
        ep = taps.RemoteEndpoint()
        if args.remote_address:
            ep.with_address(args.remote_address)
        elif args.remote_host:
            ep.with_hostname(args.remote_host)
        if args.remote_port:
            ep.with_port(args.remote_port)
        lp = None
        sp = None
        if args.interface or args.local_address or args.local_port:
            lp = taps.LocalEndpoint()
            if args.interface:
                lp.with_interface(args.interface)
            if args.local_address:
                lp.with_port(args.local_address)
            if args.local_port:
                lp.with_port(args.local_port)

        logger.info("Created endpoint objects.")

        if args.secure or args.trust_ca or args.local_identity:
            # Use TLS
            sp = taps.SecurityParameters()
            if args.trust_ca:
                sp.add_trust_ca(args.trust_ca)
            if args.local_identity:
                sp.add_identity(args.local_identity)
            logger.info("Created SecurityParameters.")

        # Create transportProperties Object and set properties
        # Does nothing yet
        tp = taps.TransportProperties()
        # tp.prohibit("reliability")
        tp.ignore("congestion-control")
        tp.ignore("preserve-order")
        # tp.add("Reliable_Data_Transfer", taps.preferenceLevel.REQUIRE)

        # Create the preconnection object with the two prev created EPs
        self.preconnection = taps.Preconnection(remote_endpoint=ep,
                                                local_endpoint=lp,
                                                transport_properties=tp,
                                                security_parameters=sp)
        # Set callbacks
        self.preconnection.on_initiate_error(self.handle_initiate_error)
        self.preconnection.on_ready(self.handle_ready)
        # Set the framer
        framer = TestFramer()
        self.preconnection.add_framer(framer)
        logger.info("Created preconnection object and set cbs.")
        # Initiate the connection
        self.connection = await self.preconnection.initiate()
        # msgref = await self.connection.send_message("Hello\n")
        logger.info("Called initiate, connection object created.")
Exemple #2
0
    async def main(self):
        ep = taps.RemoteEndpoint()
        ep.with_hostname("localhost")
        ep.with_port(6666)
        tp = taps.TransportProperties()

        tp.prohibit("reliability")
        tp.ignore("congestion-control")
        tp.ignore("preserve-order")

        self.preconnection = taps.Preconnection(remote_endpoint=ep,
                                                transport_properties=tp)
        self.preconnection.on_ready(self.handle_ready)
        self.connection = await self.preconnection.initiate()
    async def main(self,
                   data_to_send="Hello\n",
                   stop_at_sent=False,
                   remote_hostname="localhost",
                   remote_port=6666,
                   reliable=False,
                   yangfile=None,
                   trust_ca=None,
                   local_identity=None):
        self.data_to_send = data_to_send
        self.stop_at_sent = stop_at_sent
        self.yangfile = yangfile

        ep = taps.RemoteEndpoint()
        ep.with_hostname(remote_hostname)
        ep.with_port(remote_port)
        tp = taps.TransportProperties()

        if not reliable:
            tp.prohibit("reliability")
        tp.ignore("congestion-control")
        tp.ignore("preserve-order")

        if trust_ca or local_identity:
            sp = taps.SecurityParameters()
            if trust_ca:
                sp.addTrustCA(trust_ca)
            if local_identity:
                sp.addIdentity(local_identity)
        else:
            sp = None

        if self.yangfile:
            self.preconnection = taps.\
                Preconnection.from_yangfile(self.yangfile,
                                            remote_endpoint=ep,
                                            transport_properties=tp,
                                            security_parameters=sp,
                                            event_loop=asyncio.get_event_loop()
                                            )
        else:
            self.preconnection = taps.\
                Preconnection(remote_endpoint=ep,
                              transport_properties=tp,
                              security_parameters=sp,
                              event_loop=asyncio.get_event_loop()
                              )

        self.preconnection.on_ready(self.handle_ready)
        self.connection = await self.preconnection.initiate()
    async def main(self):
        lp = taps.LocalEndpoint()
        lp.with_hostname("localhost")
        lp.with_port(6666)
        tp = taps.TransportProperties()

        tp.prohibit("reliability")
        tp.ignore("congestion-control")
        tp.ignore("preserve-order")

        self.preconnection = taps.Preconnection(local_endpoint=lp,
                                                transport_properties=tp)
        self.preconnection.on_connection_received(
                                    self.handle_connection_received)
        await self.preconnection.listen()
Exemple #5
0
    async def start(self, connection):

        # Set the parameters required for Manifest hashing
        self.source = ipaddress.ip_address(
            connection.remote_endpoint.address[0])
        self.group = ipaddress.ip_address(connection.local_endpoint.address[0])
        self.group_port = connection.local_endpoint.port

        # Create new transport properties, since we want a TCP (TLS) conenction, the defaults are fine
        tp = taps.TransportProperties()
        # Create a new preconnection, set the ready callback and initiate it
        self.preconnection = taps.Preconnection(
            remote_endpoint=self.remote_endpoint,
            local_endpoint=self.local_endpoint,
            transport_properties=tp)
        self.preconnection.on_ready(self.handle_ready)
        self.connection = await self.preconnection.initiate()
    async def main(self, args):
        # Create endpoint object
        lp = taps.LocalEndpoint()
        if args.interface:
            lp.with_interface(args.interface)
        if args.local_address:
            lp.with_address(args.local_address)
        if args.local_host:
            lp.with_hostname(args.local_host)
        # If nothing to listen on has been specified, listen on localhost
        if not args.interface and not args.local_address\
           and not args.local_host:
            lp.with_hostname("localhost")
        if args.local_port:
            lp.with_port(args.local_port)

        taps.print_time("Created endpoint objects.", color)

        sp = None
        if args.secure or args.trust_ca or args.local_identity:
            # Use TLS
            sp = taps.SecurityParameters()
            if args.trust_ca:
                sp.addTrustCA(args.trust_ca)
            if args.local_identity:
                sp.addIdentity(args.local_identity)
            taps.print_time("Created SecurityParameters.", color)

        tp = taps.TransportProperties()
        tp.ignore("congestion-control")
        tp.ignore("preserve-order")
        if self.reliable == "False":
            tp.prohibit("reliability")
        if self.reliable == "Both":
            tp.ignore("reliability")

        self.preconnection = taps.Preconnection(local_endpoint=lp,
                                                transport_properties=tp,
                                                security_parameters=sp)
        self.preconnection.on_connection_received(
            self.handle_connection_received)
        self.preconnection.on_listen_error(self.handle_listen_error)
        self.preconnection.on_stopped(self.handle_stopped)
        # self.preconnection.frame_with(taps.TlvFramer())
        await self.preconnection.listen()
Exemple #7
0
    async def main(self):
        # Create (local) multicast group endpoint
        mcg = taps.LocalEndpoint()
        mcg.with_address(args.group_address)
        mcg.with_port(args.group_port)

        # Create (remote) source endpoint
        ssm = taps.RemoteEndpoint()
        ssm.with_address(args.ssm_address)
        ssm.with_port(args.ssm_port)

        # Create endpoint for the remote for AMBI
        rambi = taps.RemoteEndpoint()
        rambi.with_address(args.remote_ambi_address)
        rambi.with_port(args.remote_ambi_port)

        # Create endpoint for the local for AMBI
        if args.local_ambi_address is not None:
            lambi = taps.LocalEndpoint()
            lambi.with_address(args.local_ambi_address)
            lambi.with_port(args.local_ambi_port)
        else:
            lambi = None

        # Set the transportpropterties necessary to get a multicast stream
        tp = taps.TransportProperties()
        tp.add("direction", "unidirection-receive")
        tp.prohibit("reliability")
        tp.ignore("congestion-control")
        tp.ignore("preserve-order")

        # Configure the preconnection
        self.preconnection = taps.Preconnection(remote_endpoint=ssm,
                                                local_endpoint=mcg,
                                                transport_properties=tp)

        # Set the new connection callback
        self.preconnection.on_connection_received(
            self.handle_connection_received)
        # Create a new AMBI framer object and set it on the preconnection.
        ambi = AmbiFramer(remote_endpoint=rambi, local_endpoint=lambi)
        self.preconnection.add_framer(ambi)
        # Initiate the preconnection so it can start to received multicast packets
        self.listener = await self.preconnection.listen()