code: protected ByteBuf toByteBuf(final SipMessage msg) {
          try {
              final Buffer b = msg.toBuffer();
              final int capacity = b.capacity() + 2;
              final ByteBuf buffer = this.channel.alloc().buffer(capacity, capacity);
  
              for (int i = 0; i < b.getReadableBytes(); ++i) {
                  buffer.writeByte(b.getByte(i));
              }
              buffer.writeByte(SipParser.CR);
              buffer.writeByte(SipParser.LF);
              return buffer;
          } catch (final IOException e) {
              // shouldn't be possible since the underlying buffer
              // from the msg is backed by a byte-array.
              // TODO: do something appropriate other than this
              throw new RuntimeException("Unable to convert SipMessage to a ByteBuf due to IOException", e);
          }
      }
docs: All {@link Connection}s needs to convert the msg to a {@link ByteBuf}
  before writing it to the {@link ChannelHandlerContext}.
  
  @param msg
  the {@link SipMessage} to convert.
  @return the resulting {@link ByteBuf}