summaryrefslogtreecommitdiff
path: root/node/Multicaster.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-11-21 10:50:27 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-11-21 10:50:27 -0800
commit7619b0ecbdb3485ff5f2531cea4b660e793b5467 (patch)
tree75f4e0e6b855f53f54bf36b05112e33f071b8d19 /node/Multicaster.hpp
parent0c85b4ef5f406c51454b33ce22f0ce1585dbfb93 (diff)
downloadinfinitytier-7619b0ecbdb3485ff5f2531cea4b660e793b5467.tar.gz
infinitytier-7619b0ecbdb3485ff5f2531cea4b660e793b5467.zip
Send multicasts in random order.
This should not affect most users, but on large networks it should cause service announcements to work a lot better. This is the result of a prolonged discussion with a user about the visibility of game servers on a large network. The old multicast algorithm was de-facto randomized due to its distributed nature, while the new algorithm is more deterministic. This will restore some randomization beyond limit-overflow conditions. It won't affect small networks at all.
Diffstat (limited to 'node/Multicaster.hpp')
-rw-r--r--node/Multicaster.hpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/node/Multicaster.hpp b/node/Multicaster.hpp
index edfb62c6..3aebe57f 100644
--- a/node/Multicaster.hpp
+++ b/node/Multicaster.hpp
@@ -59,23 +59,17 @@ private:
struct MulticastGroupMember
{
MulticastGroupMember() {}
- MulticastGroupMember(const Address &a,const Address &lf,uint64_t ts) : address(a),learnedFrom(lf),timestamp(ts),rank(0) {}
+ MulticastGroupMember(const Address &a,uint64_t ts) : address(a),timestamp(ts) {}
Address address;
- Address learnedFrom;
- uint64_t timestamp; // time of last LIKE/OK(GATHER)
- uint64_t rank; // used by sorting algorithm in clean()
-
- // for sorting in ascending order of rank
- inline bool operator<(const MulticastGroupMember &m) const throw() { return (rank < m.rank); }
+ uint64_t timestamp; // time of last notification
};
struct MulticastGroupStatus
{
- MulticastGroupStatus() : lastExplicitGather(0),totalKnownMembers(0) {}
+ MulticastGroupStatus() : lastExplicitGather(0) {}
uint64_t lastExplicitGather;
- unsigned int totalKnownMembers; // 0 if unknown
std::list<OutboundMulticast> txQueue; // pending outbound multicasts
std::vector<MulticastGroupMember> members; // members of this group
};
@@ -90,13 +84,12 @@ public:
* @param now Current time
* @param nwid Network ID
* @param mg Multicast group
- * @param learnedFrom Address from which we learned this member
* @param member New member address
*/
- inline void add(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 &member)
{
Mutex::Lock _l(_groups_m);
- _add(now,nwid,mg,_groups[std::pair<uint64_t,MulticastGroup>(nwid,mg)],learnedFrom,member);
+ _add(now,nwid,mg,_groups[std::pair<uint64_t,MulticastGroup>(nwid,mg)],member);
}
/**
@@ -107,12 +100,11 @@ public:
* @param now Current time
* @param nwid Network ID
* @param mg Multicast group
- * @param learnedFrom Peer from which we received this list
* @param addresses Raw binary addresses in big-endian format, as a series of 5-byte fields
* @param count Number of addresses
* @param totalKnown Total number of known addresses as reported by peer
*/
- void addMultiple(uint64_t now,uint64_t nwid,const MulticastGroup &mg,const Address &learnedFrom,const void *addresses,unsigned int count,unsigned int totalKnown);
+ void addMultiple(uint64_t now,uint64_t nwid,const MulticastGroup &mg,const void *addresses,unsigned int count,unsigned int totalKnown);
/**
* Append gather results to a packet by choosing registered multicast recipients at random
@@ -177,7 +169,7 @@ public:
void clean(uint64_t now);
private:
- void _add(uint64_t now,uint64_t nwid,const MulticastGroup &mg,MulticastGroupStatus &gs,const Address &learnedFrom,const Address &member);
+ void _add(uint64_t now,uint64_t nwid,const MulticastGroup &mg,MulticastGroupStatus &gs,const Address &member);
const RuntimeEnvironment *RR;
std::map< std::pair<uint64_t,MulticastGroup>,MulticastGroupStatus > _groups;