original_docstring: The connect process of the node.
          Waits for a new message to come in and distinguishes between the message types
          Type 1: Regular task message from client, node simply responses
          Type 2: Clostest node request from client, node triggers the probe event to discover closest node asynchronously
          Type 3: Probing response or request from other node, at response the own VivaldiPosition is updated, at request, a response is sent
          Yields:
              simpy.Event: the incoming message in msg_pipe
              simpy.Event: the latency as a timeout
          
docstring: The connect process of the node.
  Waits for a new message to come in and distinguishes between the message types
  Type 1: Regular task message from client, node simply responses
  Type 2: Clostest node request from client, node triggers the probe event to discover closest node asynchronously
  Type 3: Probing response or request from other node, at response the own VivaldiPosition is updated, at request, a response is sent
docstring_tokens: The connect process of the node . Waits for a new message to come in and distinguishes between the message types Type 1 : Regular task message from client node simply responses Type 2 : Clostest node request from client node triggers the probe event to discover closest node asynchronously Type 3 : Probing response or request from other node at response the own VivaldiPosition is updated at request a response is sent
code: def vivaldi_connect(self):
          """The connect process of the node.
          Waits for a new message to come in and distinguishes between the message types
          Type 1: Regular task message from client, node simply responses
          Type 2: Clostest node request from client, node triggers the probe event to discover closest node asynchronously
          Type 3: Probing response or request from other node, at response the own VivaldiPosition is updated, at request, a response is sent
          Yields:
              simpy.Event: the incoming message in msg_pipe
              simpy.Event: the latency as a timeout
          """
          while True:
              in_msg = yield self.msg_pipe.get()
              self.in_msg_history.append(in_msg)
  
              if self.verbose:
                  print("Node {}: {}".format(self.id, in_msg))
              # Update gossip
              self.update_gossip(in_msg)
  
              # Message type 1 = Regular Message from client
              if(in_msg.msg_type == 1):
                  # check if client is a current client
                  current_client = next(
                      (client for client in self.clients if client.get('id') == in_msg.send_id), None)
                  # Update if client is already registered
                  if current_client:
                      current_client.update({'timestamp': self.env.now})
                  # Append to list if client is not already registered
                  elif len(self.clients) < self.slots:
                      self.clients.append(
                          {'id': in_msg.send_id, 'timestamp': self.env.now})
                  # if we have no capacity for the client we simply do not answer
                  else:
                      continue
                  
                  out_msg = self.env.send_message(
                      self.id, in_msg.send_id, "Reply from node", gossip=self.gossip, response=True, msg_type=1, prev_msg=in_msg)
                  self.out_msg_history.append(out_msg)
  
              # Message type 2 = Node Request -> Trigger search for closest node
              elif(in_msg.msg_type == 2):
                  self.vivaldi_get_closest_node(in_msg)
  
              # Message type 3 = Network Probing -> update VivaldiPosition at response or respond at Request
              elif(in_msg.msg_type == 3):
                  # If is a response from a node the virtual position is updated
                  if(in_msg.response):
                      self.update_virtual_position(in_msg)
  
                  # If it is a request we simply answer
                  else:
                      out_msg = self.env.send_message(
                          self.id, in_msg.send_id, "Probe reply from Node", gossip=self.gossip, response=True, prev_msg=in_msg, msg_type=3)
                      self.out_msg_history.append(out_msg)
  
              # unknown message type
              else:
                  if self.verbose:
                      print("Node {} received unknown message type: {}".format(
                          self.id, in_msg.msg_type))
code_tokens: def vivaldi_connect ( self ) : while True : in_msg = yield self . msg_pipe . get ( ) self . in_msg_history . append ( in_msg ) if self . verbose : print ( "Node {}: {}" . format ( self . id , in_msg ) ) self . update_gossip ( in_msg ) if ( in_msg . msg_type == 1 ) : current_client = next ( ( client for client in self . clients if client . get ( 'id' ) == in_msg . send_id ) , None ) if current_client : current_client . update ( { 'timestamp' : self . env . now } ) elif len ( self . clients ) < self . slots : self . clients . append ( { 'id' : in_msg . send_id , 'timestamp' : self . env . now } ) else : continue out_msg = self . env . send_message ( self . id , in_msg . send_id , "Reply from node" , gossip = self . gossip , response = True , msg_type = 1 , prev_msg = in_msg ) self . out_msg_history . append ( out_msg ) elif ( in_msg . msg_type == 2 ) : self . vivaldi_get_closest_node ( in_msg ) elif ( in_msg . msg_type == 3 ) : if ( in_msg . response ) : self . update_virtual_position ( in_msg ) else : out_msg = self . env . send_message ( self . id , in_msg . send_id , "Probe reply from Node" , gossip = self . gossip , response = True , prev_msg = in_msg , msg_type = 3 ) self . out_msg_history . append ( out_msg ) else : if self . verbose : print ( "Node {} received unknown message type: {}" . format ( self . id , in_msg . msg_type ) )
short_docstring: The connect process of the node.
short_docstring_tokens: The connect process of the node .
comment: """The connect process of the node.
          Waits for a new message to come in and distinguishes between the message types
          Type 1: Regular task message from client, node simply responses
          Type 2: Clostest node request from client, node triggers the probe event to discover closest node asynchronously
          Type 3: Probing response or request from other node, at response the own VivaldiPosition is updated, at request, a response is sent
          Yields:
              simpy.Event: the incoming message in msg_pipe
              simpy.Event: the latency as a timeout
          """$SEP$# Update gossip
  $SEP$# Message type 1 = Regular Message from client
  $SEP$# check if client is a current client
  $SEP$# Update if client is already registered
  $SEP$# Append to list if client is not already registered
  $SEP$# if we have no capacity for the client we simply do not answer
  $SEP$# Message type 2 = Node Request -> Trigger search for closest node
  $SEP$# Message type 3 = Network Probing -> update VivaldiPosition at response or respond at Request
  $SEP$# If is a response from a node the virtual position is updated
  $SEP$# If it is a request we simply answer
  $SEP$# unknown message type
  