code: public boolean setPublicAddress(String host, int port) {
      try {
        // set 'sentBy' in the listening point for outbound messages
        parent.getSipProvider().getListeningPoints()[0].setSentBy(host + ":" + port);
  
        // update my contact info
        SipURI my_uri = (SipURI) contactInfo.getContactHeader().getAddress().getURI();
        my_uri.setHost(host);
        my_uri.setPort(port);
  
        // update my via header
        ViaHeader my_via = (ViaHeader) viaHeaders.get(0);
        my_via.setHost(host);
        my_via.setPort(port);
  
        // update my host
        myhost = host;
      } catch (Exception ex) {
        setException(ex);
        setErrorMessage("Exception: " + ex.getClass().getName() + ": " + ex.getMessage());
        setReturnCode(EXCEPTION_ENCOUNTERED);
        return false;
      }
  
      // LOG.info("my public IP {}", host);
      // LOG.info("my public port = {}", port);
      // LOG.info("my sentby = {}",
      //  parent.getSipProvider().getListeningPoints()[0].getSentBy());
  
      return true;
    }
docs: This method replaces the host/port values currently being used in this Sip agent's contact
  address, via, and listening point 'sentby' components with the given host and port parameters.
  
  <p>
  Call this method when you are running a SipUnit testcase behind a NAT and need to register with
  a proxy on the public internet. Before creating the SipStack and SipPhone, you'll need to first
  obtain the public IP address/port using a mechanism such as the Stun4j API. See the
  TestWithStun.java file in the sipunit test/examples directory for an example of how to do it.
  
  @param host The publicly accessible IP address for this Sip client (ex: 66.32.44.112).
  @param port The port to be used with the publicly accessible IP address.
  @return true if the parameters are successfully parsed and this client's information is
  updated, false otherwise.