A single multicast address is used for PTP traffic.

This commit is contained in:
Andrea Bondavalli 2020-02-03 17:26:50 +01:00
parent 0c32e8e698
commit a9ad806c12
3 changed files with 9 additions and 19 deletions

View File

@ -1,4 +1,5 @@
# Note:
# currently ptp4l disables IP_MULTICAST_LOOP, so sockets on the same host cannot receive ptp4l traffic.
# Only exception is for lo network interface.
# Only exception is for loopback network interface.
#
sudo ptp4l -i $1 -m -l7 -E -S

View File

@ -918,10 +918,8 @@ bool SessionManager::worker() {
sap_.set_multicast_interface(config_->get_ip_addr_str());
// join PTP multicast address for specific domain
uint32_t ptp_addr = ip::address_v4::from_string(ptp_dflt_mcast_addr).to_ulong() +
config_->get_ptp_domain();
igmp_.join(config_->get_ip_addr_str(), ip::address_v4(ptp_addr).to_string());
// join PTP multicast addresses
igmp_.join(config_->get_ip_addr_str(), ptp_primary_mcast_addr);
while (running_) {
// check if it's time to update the PTP status
@ -973,17 +971,6 @@ bool SessionManager::worker() {
(void)driver_->set_sample_rate(driver_->get_current_sample_rate());
}
}
// update PTP multicast join
uint32_t new_ptp_addr = ip::address_v4::from_string(ptp_dflt_mcast_addr).to_ulong() +
ptp_config.ui8Domain;
if (new_ptp_addr != ptp_addr) {
// leave old PTP multicast address for specific domain
igmp_.leave(config_->get_ip_addr_str(), ip::address_v4(ptp_addr).to_string());
ptp_addr = new_ptp_addr;
// join new PTP multicast address for specific domain
igmp_.join(config_->get_ip_addr_str(), ip::address_v4(ptp_addr).to_string());
}
}
ptp_interval = 10;
}
@ -1024,8 +1011,9 @@ bool SessionManager::worker() {
// send deletion for this source
sap_.deletion(static_cast<uint16_t>(msg_id_hash), addr, sdp);
}
// leave PTP primary multicast
igmp_.leave(config_->get_ip_addr_str(), ip::address_v4(ptp_addr).to_string());
// leave PTP multicast addresses
igmp_.leave(config_->get_ip_addr_str(), ptp_primary_mcast_addr);
return true;
}

View File

@ -147,7 +147,8 @@ class SessionManager {
size_t process_sap();
protected:
constexpr static const char ptp_dflt_mcast_addr[] = "224.0.1.129";
constexpr static const char ptp_primary_mcast_addr[] = "224.0.1.129";
constexpr static const char ptp_pdelay_mcast_addr[] = "224.0.1.107";
std::string get_removed_source_sdp_(uint32_t id, uint32_t src_addr) const;
std::string get_source_sdp_(uint32_t id, const StreamInfo& info) const;