def connect_to_peer(peer_uri, peer_host, realm)
      peer = Peer.new(peer_host, realm)
      @peer_table[peer_host] = peer
      @peer_table[peer_host].state = :WAITING
      # Will move to :UP when the CEA is received

      uri = URI(peer_uri)
      cxn = @tcp_helper.setup_new_connection(uri.host, uri.port)
      @peer_table[peer_host].cxn = cxn

      avps = [AVP.create('Origin-Host', @local_host),
              AVP.create('Origin-Realm', @local_realm),
              AVP.create('Host-IP-Address', IPAddr.new('127.0.0.1')),
              AVP.create('Vendor-Id', 100),
              AVP.create('Product-Name', 'ruby-diameter')
             ]
      avps += app_avps
      cer_bytes = Message.new(version: 1, command_code: 257, app_id: 0, request: true, proxyable: false, retransmitted: false, error: false, avps: avps).to_wire
      @tcp_helper.send(cer_bytes, cxn)

      peer
    end
def connect_to_peer(peer_uri, peer_host, realm)
      peer = Peer.new(peer_host, realm)
      @peer_table[peer_host] = peer
      @peer_table[peer_host].state = :WAITING
      # Will move to :UP when the CEA is received

      uri = URI(peer_uri)
      cxn = @tcp_helper.setup_new_connection(uri.host, uri.port)
      @peer_table[peer_host].cxn = cxn

      avps = [AVP.create('Origin-Host', @local_host),
              AVP.create('Origin-Realm', @local_realm),
              AVP.create('Host-IP-Address', IPAddr.new('127.0.0.1')),
              AVP.create('Vendor-Id', 100),
              AVP.create('Product-Name', 'ruby-diameter')
             ]
      avps += app_avps
      cer_bytes = Message.new(version: 1, command_code: 257, app_id: 0, request: true, proxyable: false, retransmitted: false, error: false, avps: avps).to_wire
      @tcp_helper.send(cer_bytes, cxn)

      peer
    end
Creates a Peer connection to a Diameter agent at the specific
 network location indicated by peer_uri.

 @param peer_uri [URI] The aaa:// URI identifying the peer. Should
   contain a hostname/IP; may contain a port (default 3868).
 @param peer_host [String] The DiameterIdentity of this peer, which
   will uniquely identify it in the peer table.
 @param realm [String] The Diameter realm of this peer.
 @return [Peer] The Diameter peer chosen.