Skip to content

New ServiceBrowsers now request QU in the first outgoing when unspecified#812

Merged
bdraco merged 2 commits into
python-zeroconf:masterfrom
bdraco:service_browser_first_question_qu_unspecified
Jun 22, 2021
Merged

New ServiceBrowsers now request QU in the first outgoing when unspecified#812
bdraco merged 2 commits into
python-zeroconf:masterfrom
bdraco:service_browser_first_question_qu_unspecified

Conversation

@bdraco

@bdraco bdraco commented Jun 22, 2021

Copy link
Copy Markdown
Member

https://datatracker.ietf.org/doc/html/rfc6762#section-5.4

When we start a ServiceBrowser and zeroconf has just started up, the known
answer list will be small. By asking a QU question first, it is likely
that we have a large known answer list by the time we ask the QM question
a second later (current default which is likely too low but would be
a breaking change to increase). This reduces the amount of traffic on
the network, and has the secondary advantage that most responders will
answer a QU question without the typical delay answering QM questions.

…fied

https://datatracker.ietf.org/doc/html/rfc6762#section-5.4

When we start a ServiceBrowser and zeroconf has just started up, the known
answer list will be small. By asking a QU question first, it is likely
that we have a large known answer list by the time we ask the QM question
a second later (current default). This reduces the amount of traffic on
the network, and has the secondary advantage that most responders will
answer a QU question without the typical delay answering QM questions.
@bdraco bdraco force-pushed the service_browser_first_question_qu_unspecified branch from 2656889 to c4fe8f4 Compare June 22, 2021 21:19
@codecov-commenter

codecov-commenter commented Jun 22, 2021

Copy link
Copy Markdown

Codecov Report

Merging #812 (c4fe8f4) into master (13c558c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #812   +/-   ##
=======================================
  Coverage   98.69%   98.69%           
=======================================
  Files          22       22           
  Lines        2298     2303    +5     
  Branches      393      395    +2     
=======================================
+ Hits         2268     2273    +5     
  Misses         18       18           
  Partials       12       12           
Impacted Files Coverage Δ
zeroconf/_services/browser.py 98.16% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13c558c...c4fe8f4. Read the comment docs.

@bdraco

bdraco commented Jun 22, 2021

Copy link
Copy Markdown
Member Author

Looks like PyPy is taking longer to get the first query started. We probably need some way to synchronize the threads a bit better in the test or move it to asyncio

also explains why #768 fails

DEBUG    zeroconf:net.py:175 Creating new socket with port 5353, ip_version IPVersion.V4Only, apple_p2p False and bind_addr ('',)
DEBUG    zeroconf:net.py:229 Created socket <socket.socket fd=14, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 5353)>
DEBUG    zeroconf:net.py:243 Adding '127.0.0.1' (socket 14) to multicast group
DEBUG    zeroconf:net.py:175 Creating new socket with port 5353, ip_version IPVersion.V4Only, apple_p2p False and bind_addr ('127.0.0.1',)
DEBUG    zeroconf:net.py:229 Created socket <socket.socket fd=16, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)>
DEBUG    zeroconf:net.py:292 Configuring socket <socket.socket fd=16, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)> with multicast interface 127.0.0.1
DEBUG    zeroconf:_core.py:293 Listen socket <socket.socket fd=14, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 5353)>, respond sockets [<socket.socket fd=16, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 5353)>]
DEBUG    zeroconf:_protocol.py:595 offsets = questions=0, answers=0, authorities=0, additionals=0
DEBUG    zeroconf:_protocol.py:602 lengths = questions=1, answers=0, authorities=0, additionals=0
DEBUG    zeroconf:_protocol.py:624 now offsets = questions=1, answers=0, authorities=0, additionals=0
DEBUG    zeroconf:_core.py:667 Sending to (None, 5353) (39 bytes #1) <DNSOutgoing:{multicast=True, flags=0, questions=[ptr[question,QU,in,_quservice._tcp.local.]], answers=[], authorities=[], additionals=[]}> as b'\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\n_quservice\x04_tcp\x05local\x00\x00\x0c\x80\x01'...
DEBUG    zeroconf:_core.py:228 Received from '127.0.0.1':5353 (socket 14): <DNSIncoming:{id=0, flags=0, truncated=False, n_q=1, n_ans=0, n_auth=0, n_add=0, questions=[ptr[question,QU,in,_quservice._tcp.local.]], answers=[]}> (39 bytes) as [b'\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\n_quservice\x04_tcp\x05local\x00\x00\x0c\x80\x01']
DEBUG    zeroconf:_protocol.py:595 offsets = questions=0, answers=0, authorities=0, additionals=0
DEBUG    zeroconf:_protocol.py:602 lengths = questions=1, answers=0, authorities=0, additionals=0
DEBUG    zeroconf:_protocol.py:624 now offsets = questions=1, answers=0, authorities=0, additionals=0
DEBUG    zeroconf:_core.py:667 Sending to (None, 5353) (39 bytes #1) <DNSOutgoing:{multicast=True, flags=0, questions=[ptr[question,QM,in,_quservice._tcp.local.]], answers=[], authorities=[], additionals=[]}> as b'\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\n_quservice\x04_tcp\x05local\x00\x00\x0c\x00\x01'...

@bdraco

bdraco commented Jun 22, 2021

Copy link
Copy Markdown
Member Author

We can decrease time between queries to work around the pypy startup delay. I'll look into making a helper that synchronizes the startup

@bdraco bdraco merged commit e32bb5d into python-zeroconf:master Jun 22, 2021
@bdraco bdraco deleted the service_browser_first_question_qu_unspecified branch June 22, 2021 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants