protected Transmission createTransmission(String connectionId, SelectionKey key, String hostname, int port,
      PortType portType, SSLFactory.Mode mode) throws IOException {
    Transmission transmission;
    if (portType == PortType.PLAINTEXT) {
      transmission = new PlainTextTransmission(connectionId, channel(key), key, time, metrics, networkConfig);
    } else if (portType == PortType.SSL) {
      try {
        transmission =
            new SSLTransmission(sslFactory, connectionId, channel(key), key, hostname, port, time, metrics, mode,
                networkConfig);
        metrics.sslTransmissionInitializationCount.inc();
      } catch (IOException e) {
        metrics.sslTransmissionInitializationErrorCount.inc();
        logger.error("SSLTransmission initialization error ", e);
        throw e;
      }
    } else {
      throw new IllegalArgumentException("Unsupported portType " + portType + " passed in");
    }
    return transmission;
  }
Create a new {@link Transmission} to represent a live connection. This method is exposed so that it can be
unit tests can override it.
@param connectionId a unique ID for this connection.
@param key the {@link SelectionKey} used to communicate socket events.
@param hostname the remote hostname for the connection, used for SSL host verification.
@param portType used to select between a plaintext or SSL transmission.
@param mode for SSL transmissions, whether to operate in client or server mode.
@return either a {@link Transmission} or {@link SSLTransmission}.
@throws IOException
ambry-network/src/main/java/com/github/ambry/network/Selector.java