From a40b8c07f49bd9ad2748430eb9e79680059458fd Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Sat, 7 Sep 2013 15:49:38 -0400 Subject: Apply multicast rate limits to my own multicasts. Will run locally and on a variety of system types to test the result of this. --- node/Switch.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'node/Switch.cpp') diff --git a/node/Switch.cpp b/node/Switch.cpp index 157ecec8..5ba56555 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -100,13 +100,18 @@ void Switch::onLocalEthernet(const SharedPtr &network,const MAC &from,c MulticastGroup mg(to,0); if (to.isBroadcast()) { - // Handle broadcast special cases - // Cram IPv4 IP into ADI field to make IPv4 ARP broadcast channel specific and scalable if ((etherType == ZT_ETHERTYPE_ARP)&&(data.size() == 28)&&(data[2] == 0x08)&&(data[3] == 0x00)&&(data[4] == 6)&&(data[5] == 4)&&(data[7] == 0x01)) mg = MulticastGroup::deriveMulticastGroupForAddressResolution(InetAddress(data.field(24,4),4,0)); } + // Check our own multicasts against the global rate for this network + // just to be polite. + if (!network->updateAndCheckMulticastBalance(_r->identity.address(),mg,data.size())) { + LOG("didn't send local multicast %u byte multicast packet to network %.16llx: not within budget for multicast group %s",(unsigned int)data.size(),(unsigned long long)network->id(),mg.toString().c_str()); + return; + } + Multicaster::MulticastBloomFilter bloom; SharedPtr propPeers[ZT_MULTICAST_PROPAGATION_BREADTH]; unsigned int np = _r->multicaster->pickSocialPropagationPeers( -- cgit v1.2.3