webrtcnatstuniceopenwebrtc

Chrome not detecting STUN success responses even if I can see the response sent via wireshark


I am working on a hobby project to implement WebRTC from scrach in C , I am facing some problem while doing stun connectivity checks.

there are two agent C client Agent and Browser Agent that are trying to connect p2p mode.

Agent 1 C client ----- offer -----> Agent 2 Browser
Agent 1 C client <---- answer ------ Agent 2 Browser
Agent 1 <---- share ice candidates------> Agent 2 Browser

after negotiating SDP and ice candidates I am trying to do stun connectivity.

agent 1 recv request bind request from agent 2
Agent 1 C client <<--------- bind req ----- agent 2 browser
Agent 1 C client --------- bind resp ----->> agent 2 browser

once I receive the connectivity check stun bind request from Agent 2 (chrome) in c client , I am sending back a Success Response from C client Back to Agent 2 ( Browser) for hmac I am using the ice-password of agent 1 (C client).But on Browser WebRTC internal stats it shows that there was no response received.

for hmac calcuation message length is set as len up to and including hmac attribute.

enter image description here

I can see on wireshark that the response is sent back to correct IP and port and I have also verified that the computed HMAC is correct and sent correctly in the response packet.for fingerprint i am calculating the CRC of stun packet up to msg integrity attribute and xored it with 0x5354554e and use this value and fingerprint

for crc calculation message length is set as total len of stun packet including the len of crc attribute

   uint32_t stun_message_crc32 =
        crc32(0, stun_message,
              stunpacketsize) ^
        0x5354554e;

enter image description here

What could be the case for chrome to not detect my response from C client.

for further debugging this I have connected Chrome to Chrome in peer to peer and inspected the stun response that is sent from browser and compared it to the stun response that I am sending from C client but I don't see any difference.

here is the response from chrome to chrome when the response is detected correctly in chrome statistics. enter image description here


Solution

  • After spending almost two day trying every thing at the end I found out that I was not sending the response with the same transaction id as the request.and that fixed the issue