diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-10-02 11:35:37 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-10-02 11:35:37 -0700 |
commit | 49dc47ff38ff27fd8f846a4a6354a60423376671 (patch) | |
tree | ad07f38721f9b47cfcd488a4f22e117e9f1dd605 | |
parent | dee86e2448725d4ac592816cac504e5d43fcb026 (diff) | |
download | infinitytier-49dc47ff38ff27fd8f846a4a6354a60423376671.tar.gz infinitytier-49dc47ff38ff27fd8f846a4a6354a60423376671.zip |
Make multicast gathering a bit smarter.
-rw-r--r-- | node/Constants.hpp | 5 | ||||
-rw-r--r-- | node/IncomingPacket.cpp | 2 | ||||
-rw-r--r-- | node/Multicaster.cpp | 46 | ||||
-rw-r--r-- | node/Multicaster.hpp | 4 | ||||
-rw-r--r-- | node/Switch.cpp | 1 |
5 files changed, 26 insertions, 32 deletions
diff --git a/node/Constants.hpp b/node/Constants.hpp index 0260219f..5d4849c2 100644 --- a/node/Constants.hpp +++ b/node/Constants.hpp @@ -251,11 +251,6 @@ #define ZT_MULTICAST_TRANSMIT_TIMEOUT 5000 /** - * Default number of endpoints to implicitly gather from peers with each multicast frame - */ -#define ZT_MULTICAST_DEFAULT_IMPLICIT_GATHER 8 - -/** * Default maximum number of peers to address with a single multicast (if unspecified in network) */ #define ZT_MULTICAST_DEFAULT_LIMIT 128 diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp index 9d7461ca..ef45ddac 100644 --- a/node/IncomingPacket.cpp +++ b/node/IncomingPacket.cpp @@ -796,7 +796,7 @@ bool IncomingPacket::_doMULTICAST_LIKE(const RuntimeEnvironment *RR,const Shared // Iterate through 18-byte network,MAC,ADI tuples for(unsigned int ptr=ZT_PACKET_IDX_PAYLOAD;ptr<size();ptr+=18) - RR->mc->subscribe(now,at<uint64_t>(ptr),MulticastGroup(MAC(field(ptr + 8,6),6),at<uint32_t>(ptr + 14)),Address(),src); + RR->mc->add(now,at<uint64_t>(ptr),MulticastGroup(MAC(field(ptr + 8,6),6),at<uint32_t>(ptr + 14)),Address(),src); peer->receive(RR,_fromSock,_remoteAddress,hops(),packetId(),Packet::VERB_MULTICAST_LIKE,0,Packet::VERB_NOP,now); } catch (std::exception &ex) { diff --git a/node/Multicaster.cpp b/node/Multicaster.cpp index a3e600d9..8e3e3e29 100644 --- a/node/Multicaster.cpp +++ b/node/Multicaster.cpp @@ -107,7 +107,6 @@ restart_member_scan: void Multicaster::send( const CertificateOfMembership *com, unsigned int limit, - unsigned int gatherLimit, uint64_t now, uint64_t nwid, const MulticastGroup &mg, @@ -129,7 +128,7 @@ void Multicaster::send( nwid, com, limit, - gatherLimit, + 0, src, mg, etherType, @@ -143,25 +142,7 @@ void Multicaster::send( break; } } else { - // If we don't already have enough members, send to the ones we have and then gather (if allowed within gather rate limit delay) - gs.txQueue.push_back(OutboundMulticast()); - OutboundMulticast &out = gs.txQueue.back(); - - out.init( - now, - RR->identity.address(), - nwid, - com, - limit, - gatherLimit, - src, - mg, - etherType, - data, - len); - - for(std::vector<MulticastGroupMember>::const_reverse_iterator m(gs.members.rbegin());m!=gs.members.rend();++m) - out.sendAndLog(*(RR->sw),m->address); + unsigned int gatherLimit = (limit - (unsigned int)gs.members.size()) + 1; if ((now - gs.lastExplicitGather) >= ZT_MULTICAST_GATHER_DELAY) { gs.lastExplicitGather = now; @@ -178,11 +159,32 @@ void Multicaster::send( outp.append((uint8_t)0); mg.mac().appendTo(outp); outp.append((uint32_t)mg.adi()); - outp.append((uint32_t)((limit - (unsigned int)gs.members.size()) + 1)); // +1 just means we'll have an extra in the queue if available + outp.append((uint32_t)gatherLimit); // +1 just means we'll have an extra in the queue if available outp.armor(sn->key(),true); sn->send(RR,outp.data(),outp.size(),now); } + + gatherLimit = 0; // once we've done this we don't need to do it implicitly } + + gs.txQueue.push_back(OutboundMulticast()); + OutboundMulticast &out = gs.txQueue.back(); + + out.init( + now, + RR->identity.address(), + nwid, + com, + limit, + gatherLimit, + src, + mg, + etherType, + data, + len); + + for(std::vector<MulticastGroupMember>::const_reverse_iterator m(gs.members.rbegin());m!=gs.members.rend();++m) + out.sendAndLog(*(RR->sw),m->address); } } diff --git a/node/Multicaster.hpp b/node/Multicaster.hpp index 96207aa0..ae62456c 100644 --- a/node/Multicaster.hpp +++ b/node/Multicaster.hpp @@ -92,7 +92,7 @@ public: * @param learnedFrom Address from which we learned this member or NULL/0 Address if direct * @param member New member address */ - inline void subscribe(uint64_t now,uint64_t nwid,const MulticastGroup &mg,const Address &learnedFrom,const Address &member) + inline void add(uint64_t now,uint64_t nwid,const MulticastGroup &mg,const Address &learnedFrom,const Address &member) { Mutex::Lock _l(_groups_m); _add(now,nwid,_groups[std::pair<uint64_t,MulticastGroup>(nwid,mg)],learnedFrom,member); @@ -124,7 +124,6 @@ public: * @param nwid Network ID * @param com Certificate of membership to include or NULL for none * @param limit Multicast limit - * @param gatherLimit Limit to pass for implicit gather with MULTICAST_FRAME * @param now Current time * @param mg Multicast group * @param from Source Ethernet MAC address @@ -135,7 +134,6 @@ public: void send( const CertificateOfMembership *com, unsigned int limit, - unsigned int gatherLimit, uint64_t now, uint64_t nwid, const MulticastGroup &mg, diff --git a/node/Switch.cpp b/node/Switch.cpp index c254c762..32190a87 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -153,7 +153,6 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c RR->mc->send( ((!nconf->isPublic())&&(nconf->com())) ? &(nconf->com()) : (const CertificateOfMembership *)0, nconf->multicastLimit(), - network->wantMulticastGroup(mg) ? ZT_MULTICAST_DEFAULT_IMPLICIT_GATHER : 0, now, network->id(), mg, |