original_docstring: Retrieves the closest node from the network for the requesting client. Decision is based on the given discovery protocol:
          baseline: the optimal discovery as a baseline 
          vivaldi: discovery via the vivaldi virtual coordinates
          
docstring: Retrieves the closest node from the network for the requesting client. Decision is based on the given discovery protocol:
  baseline: the optimal discovery as a baseline
  vivaldi: discovery via the vivaldi virtual coordinates
docstring_tokens: Retrieves the closest node from the network for the requesting client . Decision is based on the given discovery protocol : baseline : the optimal discovery as a baseline vivaldi : discovery via the vivaldi virtual coordinates
code: def vivaldi_get_closest_node(self, in_msg):
          """Retrieves the closest node from the network for the requesting client. Decision is based on the given discovery protocol:
          baseline: the optimal discovery as a baseline 
          vivaldi: discovery via the vivaldi virtual coordinates
          """
          client = self.env.get_participant(in_msg.send_id)
          # Calculating the closest node based on the omniscient environment.
          # Should not be used for realisitic measurements but as a baseline to compare other protocols to
          if (self.discovery_protocol == "baseline"):
              closest_node_id = self.env.get_closest_node(client.id)
              
          if (self.discovery_protocol == "random"):
              closest_node_id = self.env.get_random_node()
  
          # Calculating the closest node based on the vivaldi virtual coordinates
          elif(self.discovery_protocol == "vivaldi"):
              estimates = []
              for node in filter(lambda x: x.get('type') == type(self).__name__ and x.get("available_slots") > 0, self.gossip):
                  cj = node.get("position")
                  est_rtt = cj.estimateRTT(client.get_virtual_position())
                  estimates.append({"id": node.get('id'), "rtt": est_rtt})
              sorted_estimates = sorted(estimates, key=itemgetter('rtt'))
              if sorted_estimates:
                  closest_node_id = sorted_estimates[0]["id"]
              else:
                  closest_node_id = None
  
          # send message containing the closest node
          client_id = in_msg.send_id
          start = time.perf_counter()
          msg = self.env.send_message(self.id, client_id,
                                      closest_node_id, gossip=self.gossip, msg_type=2, response=True, prev_msg=in_msg)
          self.out_msg_history.append(msg)
          self.discovery_performance = time.perf_counter() - start
code_tokens: def vivaldi_get_closest_node ( self , in_msg ) : client = self . env . get_participant ( in_msg . send_id ) if ( self . discovery_protocol == "baseline" ) : closest_node_id = self . env . get_closest_node ( client . id ) if ( self . discovery_protocol == "random" ) : closest_node_id = self . env . get_random_node ( ) elif ( self . discovery_protocol == "vivaldi" ) : estimates = [ ] for node in filter ( lambda x : x . get ( 'type' ) == type ( self ) . __name__ and x . get ( "available_slots" ) > 0 , self . gossip ) : cj = node . get ( "position" ) est_rtt = cj . estimateRTT ( client . get_virtual_position ( ) ) estimates . append ( { "id" : node . get ( 'id' ) , "rtt" : est_rtt } ) sorted_estimates = sorted ( estimates , key = itemgetter ( 'rtt' ) ) if sorted_estimates : closest_node_id = sorted_estimates [ 0 ] [ "id" ] else : closest_node_id = None client_id = in_msg . send_id start = time . perf_counter ( ) msg = self . env . send_message ( self . id , client_id , closest_node_id , gossip = self . gossip , msg_type = 2 , response = True , prev_msg = in_msg ) self . out_msg_history . append ( msg ) self . discovery_performance = time . perf_counter ( ) - start
short_docstring: Retrieves the closest node from the network for the requesting client.
short_docstring_tokens: Retrieves the closest node from the network for the requesting client .
comment: """Retrieves the closest node from the network for the requesting client. Decision is based on the given discovery protocol:
          baseline: the optimal discovery as a baseline 
          vivaldi: discovery via the vivaldi virtual coordinates
          """$SEP$# Calculating the closest node based on the omniscient environment.
  $SEP$# Should not be used for realisitic measurements but as a baseline to compare other protocols to
  $SEP$# Calculating the closest node based on the vivaldi virtual coordinates
  $SEP$# send message containing the closest node
  