Elections may be called whenever a Consumer is unable to find a Local Master Browser, or when a jealous rival (known as a Preferred Master Browser) shows up. An election can also be forced by sending a zero-filled RequestElection frame. When a RequestElection frame is received by a Potential Browser (including Backup Browsers, the LMB, and the DMB), the Potential Browser switches into election mode. The browser stays in election mode until a winner declares itself by sending a LocalMasterAnnouncement frame. While in election mode, the browser sends and receives RequestElection frames . If another browser's credentials are better, then the browser knows that it has lost the election and will politely shut up, not participating further in the current election. 23.1.1 VotingThere is a bit of timing involved in the election process. If all Potential Browsers were to respond at once, things could get a little noisy . [1] So, as with the AnnouncementRequest frame, when a browser receives a RequestElection frame it will wait a random amount of time before sending its response. The amount of time to wait varies by the status of the node, however. A Potential Browser that is more likely to win the election will send its response to the RequestElection frame sooner than one that is less likely.
It's supposed to work like this:
The goal here is to cut down on network broadcast traffic. If the likely candidate votes first, the chances are good that the others won't have to vote at all. After sending a RequestElection frame, a candidate should wait two or three seconds to be sure that all other candidates have voted. After that, if the candidate has won the round it can send another RequestElection frame. This marks the start of another round. The election runs four rounds, after which the browser still standing (there should be only one) declares itself the winner by sending a LocalMasterAnnouncement frame. The timings above are provided in the Leach/Naik Browser draft. Whether existing implementations follow these guidelines or not is a question for further study. 23.1.2 The BallotThe ballot is contained within the RequestElection frame which, just to review, looks like this: struct { uchar Opcode; uchar Version; ulong Criteria; ulong UpTime; ulong Reserved; uchar *ServerName; } RequestElection; The Opcode and Reserved fields can be ignored. The rest comprise the election ballot. The winner of the election is determined by comparing the ballots using a somewhat arcane formula. Here, plain and simple, is how it works: Test 1
Test 2
Test 3
Test 4
There is one more test suggested in the Leach/Naik Browser draft. It might be "Test 0" in the list above. Test 0 says, essentially , that a browser that has recently lost an election is still a loser and should remain a loser until several seconds have passed. Let's rip apart that Criteria field, shall we? The Criteria field is handled like an unsigned long integer, but it can also be divided into four subfields, like so: struct { uchar OSlevel; uchar BroMajorVers; uchar BroMinorVers; uchar Role; } Criteria; The OSlevel is the highest order byte and, therefore, has the most impact when Criteria values are compared as unsigned longs. There are some known, predefined values, as shown: 0x01 = Windows for Workgroups and Windows 9x 0x10 = Windows NT Workstation 0x14 = Samba default 0x20 = Windows NT Server The higher you crank the OSlevel , the better your chances of winning an election. Moving along, the next subfields are the major and minor Browser Protocol Version numbers . In theory, they should have the values 15 and 1, respectively, but Windows 9x systems use 21 and 4 instead. The final subfield is known as the Role field. It is a bitflag field. There seems to be some disagreement regarding the bits, though. Different sources provide different interpretations. The table below provides reasonable approximations.
It was stated earlier that the LMB election can be rigged so that a specific node always wins. For example, it is necessary that the DMB become the LMB for the LAN. Higher OS level
Preferred Master
NBNS Clients
The DMB
|