code: def throw_punch(self, args, tries=1):
          
  
          # Parse arguments.
          if len(args) != 3:
              return 0
          sock, node_ip, remote_port = args
          if sock is None or node_ip is None or remote_port is None:
              return 0
  
          # Generous timeout.
          con = Sock(blocking=1, interface=self.interface)
          con.set_sock(sock)
          local = 0
          if is_ip_private(node_ip):
              """
              When simulating nodes on the same computer a delay needs to be set
              for the loop back interface to simulate the delays that occur over
              a WAN link. This requirement may also be needed for nodes on a LAN.
  
              sudo tc qdisc replace dev lo root handle 1:0 netem delay 0.5sec
  
              Speculation: The simulation problem may be to do with CPU cores.
              If the program is run on the same core then the connects will always
              be out of sync. If that's the case -- tries will need to be set to
              ~1000 which was what it was before. Perhaps a delay could be
              simulated by sleeping for random periods if its a local connection?
              That could help punch through at least once and then just set the
              tries to >= 1000.
              """
              tries = 20  # 20
              local = 1
  
          source_port = sock.getsockname()[1]
          error = 0
          log.debug("Throwing punch")
          for i in range(0, tries):
              # Attempt to connect.
              try:
                  con.connect(node_ip, remote_port)
                  log.debug("Sim open success!")
  
                  # FATALITY.
  
                  # Atomic operation so mutex not required.
                  # Record hole made.
                  con.set_blocking(blocking=0, timeout=5)
                  self.simultaneous_cons.append(con)
                  return 1
              except Exception as e:
                  # Punch was blocked, opponent is strong.
                  e = str(parse_exception(e))
                  log.debug(e)
                  error = 1
                  continue
  
          if error:
              sock.close()
  
          return 0
docs: Attempt to open a hole by TCP hole punching. This
          function is called by the simultaneous fight function
          and its the code that handles doing the actual hole
          punching / connecting.