Skip to content

Commit

Permalink
replace SSRC source from IPv4 address to random number
Browse files Browse the repository at this point in the history
Previous implementation uses SSRC as IPv4 address that is same behaviour
of Kenwood's NXDN repeater.

RFC 3350 RTP protocol recommends SSRC uses random number.
So I use MT19937 random number generator instead of IP address.

And if this is no problem, I will do two changes.

- replace rand() in DMRNetwork.cpp and DStarNetwork.cpp to MT19937
- remove getLocalAddress() in UDPSocket.cpp
  • Loading branch information
jg1uaa committed Jul 1, 2020
1 parent 9742514 commit 79b3eaa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions NXDNKenwoodNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ m_rtcpTimer(1000U, 0U, 200U),
m_hangTimer(1000U, 5U),
m_hangType(0U),
m_hangSrc(0U),
m_hangDst(0U)
m_hangDst(0U),
m_random()
{
assert(localPort > 0U);
assert(!gwyAddress.empty());
Expand All @@ -65,6 +66,10 @@ m_hangDst(0U)
m_sacch = new unsigned char[10U];

m_address = CUDPSocket::lookup(gwyAddress);

std::random_device rd;
std::mt19937 mt(rd());
m_random = mt;
}

CNXDNKenwoodNetwork::~CNXDNKenwoodNetwork()
Expand All @@ -87,7 +92,7 @@ bool CNXDNKenwoodNetwork::open()
return false;
}

m_ssrc = m_rtpSocket.getLocalAddress();
m_ssrc = m_random();

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions NXDNKenwoodNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <cstdint>
#include <string>
#include <random>

class CNXDNKenwoodNetwork : public INXDNNetwork {
public:
Expand Down Expand Up @@ -69,6 +70,7 @@ class CNXDNKenwoodNetwork : public INXDNNetwork {
unsigned char m_hangType;
unsigned short m_hangSrc;
unsigned short m_hangDst;
std::mt19937 m_random;

bool processIcomVoiceHeader(const unsigned char* data);
bool processIcomVoiceData(const unsigned char* data);
Expand Down

0 comments on commit 79b3eaa

Please sign in to comment.