def reset_node_configuration(channel): """ RPC used to clear the configuration on a sender node """ # Get the reference of the stub stub = srv6pmService_pb2_grpc.SRv6PMStub(channel) # Create the request message request = srv6pmCommons_pb2.Configuration() # Start the experiment on the reflector and return the response return stub.resetConfiguration(request=request)
def stop_experiment_reflector(channel, sidlist): """ RPC used to stop an experiment on the reflector """ # Get the reference of the stub stub = srv6pmService_pb2_grpc.SRv6PMStub(channel) # Create the request message request = srv6pmCommons_pb2.StopExperimentRequest() # Set the SID list request.sdlist = '/'.join(sidlist) # Stop the experiment on the reflector and return the response return stub.stopExperimentReflector(request=request)
def retrieve_experiment_results_sender(channel, sidlist): """ RPC used to get the results of a running experiment """ # Get the reference of the stub stub = srv6pmService_pb2_grpc.SRv6PMStub(channel) # Create the request message request = srv6pmCommons_pb2.RetriveExperimentDataRequest() # Set the SID list request.sdlist = '/'.join(sidlist) # Retrieve the experiment results from the sender and return them return stub.retriveExperimentResults(request=request)
def set_node_configuration(channel, send_udp_port, refl_udp_port, interval_duration, delay_margin, number_of_color, pm_driver): """ RPC used to set the configuration on a sender node """ # # pylint: disable=too-many-arguments # # Convert string args to int # # PM Driver try: if isinstance(pm_driver, str): pm_driver = srv6pmCommons_pb2.PMDriver.Value(pm_driver) except ValueError: logger.error('Invalid PM Driver: %s', pm_driver) return None # # Get the reference of the stub stub = srv6pmService_pb2_grpc.SRv6PMStub(channel) # Create the request message request = srv6pmCommons_pb2.Configuration() # Set the destination UDP port of the sender request.ss_udp_port = int(send_udp_port) # Set the destination UDP port of the reflector request.refl_udp_port = int(refl_udp_port) # # Set the color options # # Set the interval duration request.color_options.interval_duration = \ int(interval_duration) # pylint: disable=no-member # Set the delay margin request.color_options.delay_margin = \ int(delay_margin) # pylint: disable=no-member # Set the number of color request.color_options.numbers_of_color = \ int(number_of_color) # pylint: disable=no-member # # Set driver request.pm_driver = pm_driver # Start the experiment on the reflector and return the response return stub.setConfiguration(request=request)
def start_experiment_reflector( channel, sidlist, rev_sidlist, # in_interfaces, out_interfaces, measurement_protocol, measurement_type, authentication_mode, authentication_key, loss_measurement_mode): """ RPC used to start an experiment on the reflector """ # pylint: disable=too-many-arguments # # Convert string args to int # # Measurement Protocol try: if isinstance(measurement_protocol, str): measurement_protocol = \ srv6pmCommons_pb2.MeasurementProtocol.Value( measurement_protocol) except ValueError: logger.error('Invalid Measurement protocol: %s', measurement_protocol) return None # Measurement Type try: if isinstance(measurement_type, str): measurement_type = \ srv6pmCommons_pb2.MeasurementType.Value(measurement_type) except ValueError: logger.error('Invalid Measurement Type: %s', measurement_type) return None # Authentication Mode try: if isinstance(authentication_mode, str): authentication_mode = \ srv6pmCommons_pb2.AuthenticationMode.Value(authentication_mode) except ValueError: logger.error('Invalid Authentication Mode: %s', authentication_mode) return None # Loss Measurement Mode try: if isinstance(loss_measurement_mode, str): loss_measurement_mode = \ srv6pmCommons_pb2.MeasurementLossMode.Value( loss_measurement_mode) except ValueError: logger.error('Invalid Loss Measurement Mode: %s', loss_measurement_mode) return None # # Get the reference of the stub stub = srv6pmService_pb2_grpc.SRv6PMStub(channel) # Create the request message request = srv6pmReflector_pb2.StartExperimentReflectorRequest() # Set the SID list request.sdlist = '/'.join(sidlist) # Set the reverse SID list request.sdlistreverse = '/'.join(rev_sidlist) # Set the incoming interfaces # request.in_interfaces.extend(in_interfaces) # # Set the outgoing interfaces # request.out_interfaces.extend(out_interfaces) # # Set the reflector options # # Set the measurement protocol request.reflector_options.measurement_protocol = \ measurement_protocol # pylint: disable=no-member # Set the authentication mode request.reflector_options.authentication_mode = \ authentication_mode # pylint: disable=no-member # Set the authentication key request.reflector_options.authentication_key = \ str(authentication_key) # pylint: disable=no-member # Set the measurement type request.reflector_options.measurement_type = \ measurement_type # pylint: disable=no-member # Set the measurement loss mode request.reflector_options.measurement_loss_mode = \ loss_measurement_mode # pylint: disable=no-member # Start the experiment on the reflector and return the response return stub.startExperimentReflector(request=request)
def start_experiment_sender( channel, sidlist, rev_sidlist, # in_interfaces, out_interfaces, measurement_protocol, measurement_type, authentication_mode, authentication_key, timestamp_format, delay_measurement_mode, padding_mbz, loss_measurement_mode): """ RPC used to start an experiment on the sender """ # # pylint: disable=too-many-arguments, too-many-return-statements # # Convert string args to int # # Measurement Protocol try: if isinstance(measurement_protocol, str): measurement_protocol = \ srv6pmCommons_pb2.MeasurementProtocol.Value( measurement_protocol) except ValueError: logger.error('Invalid Measurement protocol: %s', measurement_protocol) return None # Measurement Type try: if isinstance(measurement_type, str): measurement_type = \ srv6pmCommons_pb2.MeasurementType.Value(measurement_type) except ValueError: logger.error('Invalid Measurement Type: %s', measurement_type) return None # Authentication Mode try: if isinstance(authentication_mode, str): authentication_mode = \ srv6pmCommons_pb2.AuthenticationMode.Value(authentication_mode) except ValueError: logger.error('Invalid Authentication Mode: %s', authentication_mode) return None # Timestamp Format try: if isinstance(timestamp_format, str): timestamp_format = \ srv6pmCommons_pb2.TimestampFormat.Value(timestamp_format) except ValueError: logger.error('Invalid Timestamp Format: %s', timestamp_format) return None # Delay Measurement Mode try: if isinstance(delay_measurement_mode, str): delay_measurement_mode = \ srv6pmCommons_pb2.MeasurementDelayMode.Value( delay_measurement_mode) except ValueError: logger.error('Invalid Delay Measurement Mode: %s', delay_measurement_mode) return None # Loss Measurement Mode try: if isinstance(loss_measurement_mode, str): loss_measurement_mode = \ srv6pmCommons_pb2.MeasurementLossMode.Value( loss_measurement_mode) except ValueError: logger.error('Invalid Loss Measurement Mode: %s', loss_measurement_mode) return None # # Get the reference of the stub stub = srv6pmService_pb2_grpc.SRv6PMStub(channel) # Create the request request = srv6pmSender_pb2.StartExperimentSenderRequest() # Set the SID list request.sdlist = '/'.join(sidlist) # Set the reverse SID list request.sdlistreverse = '/'.join(rev_sidlist) # Set the incoming interfaces # request.in_interfaces.extend(in_interfaces) # # Set the outgoing interfaces # request.out_interfaces.extend(out_interfaces) # # Set the sender options # # Set the measureemnt protocol (request.sender_options.measurement_protocol) = \ measurement_protocol # pylint: disable=no-member # Set the authentication mode request.sender_options.authentication_mode = \ authentication_mode # pylint: disable=no-member # Set the authentication key request.sender_options.authentication_key = \ str(authentication_key) # pylint: disable=no-member # Set the measurement type request.sender_options.measurement_type = \ measurement_type # pylint: disable=no-member # Set the timestamp format request.sender_options.timestamp_format = \ timestamp_format # pylint: disable=no-member # Set the measurement delay mode request.sender_options.measurement_delay_mode = \ delay_measurement_mode # pylint: disable=no-member # Set the padding request.sender_options.padding_mbz = \ int(padding_mbz) # pylint: disable=no-member # Set the measurement loss mode request.sender_options.measurement_loss_mode = \ loss_measurement_mode # pylint: disable=no-member # # Start the experiment on the sender and return the response return stub.startExperimentSender(request=request)