Skip to content

Commit

Permalink
further optimize sync
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Sep 24, 2020
1 parent 87fbd62 commit 8754719
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion mlat/server/clocktrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def receiver_sync(self, receiver,

# No existing match. Validate the messages and maybe create a new sync point

if receiver.sync_range_exceeded or receiver.bad_syncs > 1:
if receiver.sync_range_exceeded or receiver.bad_syncs > 2:
return

# basic validity
Expand Down
3 changes: 0 additions & 3 deletions mlat/server/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ def __init__(self, uuid, user, connection, clock, position_llh, privacy, connect

def update_interest_sets(self, new_sync, new_mlat, new_adsb):

if len(new_sync) > config.MAX_SYNC_AC:
new_sync = set(random.sample(new_sync, k=config.MAX_SYNC_AC))

if self.bad_syncs > 2:
new_sync = set(random.sample(new_sync, k=round(config.MAX_SYNC_AC / 4)))

Expand Down
11 changes: 6 additions & 5 deletions mlat/server/jsonclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,14 +577,15 @@ def process_message(self, line):
self.mc_start = now
r = self.receiver
if now - r.last_clock_reset < 60:
self.mrate_limit = 40
elif r.bad_syncs > 3 or r.sync_range_exceeded or r.sync_peers < 1:
self.mrate_limit = 3
#if self.receiver.user == 'euerdorf1':
# logging.warning("mrate_limit = 3")
self.mrate_limit = 60
elif r.sync_range_exceeded or r.sync_peers < 1 or r.bad_syncs > 2:
self.mrate_limit = 5
else:
self.mrate_limit = 40

#if self.receiver.user == 'euerdorf1':
# logging.warning("mrate_limit = 3")

if self.message_counter < self.mrate_limit * elapsed + 10:
self.coordinator.receiver_sync(self.receiver,
float(sync['et']),
Expand Down
23 changes: 17 additions & 6 deletions mlat/server/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import asyncio
import time
from mlat import profile
from mlat.server import kalman
from mlat.server import kalman, config


class TrackedAircraft(object):
Expand Down Expand Up @@ -162,12 +162,17 @@ def update_interest(self, receiver):
latest tracking and rate report data."""

new_adsb = set()
earlier = time.monotonic() - 300
now = time.monotonic()

if receiver.last_rate_report is None:
# Legacy client, no rate report, we cannot be very selective.
new_sync = {ac for ac in receiver.tracking if len(ac.tracking) > 1}
new_mlat = {ac for ac in receiver.tracking if ac.allow_mlat and (len(ac.adsb_seen) < 3 or ac.last_syncpoint_time < earlier)}
new_mlat = {ac for ac in receiver.tracking if ac.allow_mlat and (len(ac.adsb_seen) < 3 or ac.last_syncpoint_time < now - 300)}
if now - receiver.last_clock_reset < 30:
new_sync = set(receiver.tracking)
elif len(new_sync) > config.MAX_SYNC_AC:
new_sync = set(random.sample(new_sync, k=config.MAX_SYNC_AC))

receiver.update_interest_sets(new_sync, new_mlat, new_adsb)
asyncio.get_event_loop().call_soon(receiver.refresh_traffic_requests)
return
Expand All @@ -182,7 +187,7 @@ def update_interest(self, receiver):
if not ac:
continue

if rate < 0.20:
if rate < 0.25:
continue

if rate > 0.5:
Expand All @@ -199,7 +204,7 @@ def update_interest(self, receiver):
else:
rate1 = r1.last_rate_report.get(icao, 0.0)

rp = rate * rate1 / 4.0
rp = rate * rate1 / 2.25
if rp < 0.10:
continue

Expand All @@ -215,21 +220,27 @@ def update_interest(self, receiver):
if ac in new_sync_set:
continue # already added

if len(new_sync_set) >= config.MAX_SYNC_AC:
break

if ntotal.get(r1, 0.0) < 1.0:
# use this aircraft for sync
new_sync_set.add(ac)
# update rate-product totals for all receivers that see this aircraft
for rp2, r2, ac2 in ac_to_ratepair_map[ac]:
ntotal[r2] = ntotal.get(r2, 0.0) + rp2

if now - receiver.last_clock_reset < 30:
new_sync = set(receiver.tracking)

# for multilateration we are interesting in
# all aircraft that we are tracking but for
# which we have no ADS-B rate (i.e. are not
# transmitting positions)
new_mlat_set = set()

for ac in receiver.tracking:
if ac.icao not in receiver.last_rate_report and ac.allow_mlat and (len(ac.adsb_seen) < 3 or ac.last_syncpoint_time < earlier):
if ac.allow_mlat and (len(ac.adsb_seen) < 3 or ac.last_syncpoint_time < now - 300):
new_mlat_set.add(ac)

receiver.update_interest_sets(new_sync_set, new_mlat_set, new_adsb)
Expand Down

0 comments on commit 8754719

Please sign in to comment.