From: Dirk Koopman Date: Sun, 16 Sep 2007 17:01:53 +0000 (+0100) Subject: reduce the number of duplicate PC92 for Ext Nodes X-Git-Tag: 1.55~73 X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=93292dcd622b1505d2cbab334277c89e7c8afd27;hp=f7d12c1c29b0653afb72fc84a4463d3c01dd506f;p=spider.git reduce the number of duplicate PC92 for Ext Nodes Try to reduce the no of duplicate PC92C for external PC protocol nodes by listening for others that are out there and bumping up our update time instead of us transmitting more or less the same info as well. --- diff --git a/perl/DXProt.pm b/perl/DXProt.pm index e1bfd6ec..e9fa42b6 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -72,7 +72,7 @@ $obscount = 2; $chatdupeage = 20 * 60; $chatimportfn = "$main::root/chat_import"; $investigation_int = 12*60*60; # time between checks to see if we can see this node -$pc19_version = 5466; # the visible version no for outgoing PC19s generated from pc59 +$pc19_version = 5454; # the visible version no for outgoing PC19s generated from pc59 $pc92_update_period = 60*60; # the period between outgoing PC92 C updates $pc92_short_update_period = 15*60; # shorten the update period after a connection %pc92_find = (); # outstanding pc92 find operations @@ -481,11 +481,20 @@ sub process next unless $dxchan->is_node; # send out a PC92 config record if required for me and - # all my non pc9x dependent nodes. + # all my non pc9x dependent nodes. But for dependent nodes we only do + # this if we have not seen any from anyone else for at least half + # of one update period. This should stop quite a bit of excess C + # records. Someone will win, it does not really matter who, because + # we always believe "us". if ($main::systime >= $dxchan->{next_pc92_update}) { dbg("ROUTE: pc92 broadcast candidate: $dxchan->{call}") if isdbg('obscount'); if ($dxchan == $main::me || !$dxchan->{do_pc9x}) { - $dxchan->broadcast_pc92_update($dxchan->{call}); + my $ref = Route::Node::get($dxchan->{call}); + if ($dxchan == $main::me || ($ref && ($ref->measure_pc9x_t($main::systime-$main::systime_daystart)) >= $pc92_update_period/2)) { + $dxchan->broadcast_pc92_update($dxchan->{call}); + } else { + $dxchan->update_pc92_next($pc92_update_period - rand(60)); + } } } } @@ -925,6 +934,7 @@ sub broadcast_pc92_update return; } my $l = $nref->last_PC92C(gen_my_pc92_config($nref)); + $nref->lastid(last_pc9x_id()); $main::me->broadcast_route_pc9x($main::mycall, undef, $l, 0); $self->update_pc92_next($pc92_update_period); } diff --git a/perl/DXProtHandle.pm b/perl/DXProtHandle.pm index 6b8a4cd8..4d69b1aa 100644 --- a/perl/DXProtHandle.pm +++ b/perl/DXProtHandle.pm @@ -592,16 +592,6 @@ sub handle_18 $self->sort('S'); } # $self->{handle_xml}++ if DXXml::available() && $_[1] =~ /\bxml/; - if ($_[1] =~ /\bpc9x/) { - if ($self->{isolate}) { - dbg("pc9x recognised, but $self->{call} is isolated, using old protocol"); - } elsif (!$self->user->wantpc9x) { - dbg("pc9x explicitly switched off on $self->{call}, using old protocol"); - } else { - $self->{do_pc9x} = 1; - dbg("Do px9x set on $self->{call}"); - } - } } else { dbg("Unknown software"); $self->version(50.0); @@ -609,6 +599,17 @@ sub handle_18 $self->user->version($self->version); } + if ($_[1] =~ /\bpc9x/) { + if ($self->{isolate}) { + dbg("pc9x recognised, but $self->{call} is isolated, using old protocol"); + } elsif (!$self->user->wantpc9x) { + dbg("pc9x explicitly switched off on $self->{call}, using old protocol"); + } else { + $self->{do_pc9x} = 1; + dbg("Do px9x set on $self->{call}"); + } + } + # first clear out any nodes on this dxchannel my @rout = $parent->del_nodes; $self->route_pc21($origin, $line, @rout, $parent) if @rout; @@ -1440,16 +1441,22 @@ sub clear_pc92_changes my $_last_time; my $_last_occurs; +my $_last_pc9x_id; + +sub last_pc9x_id +{ + return $_last_pc9x_id; +} sub gen_pc9x_t { if (!$_last_time || $_last_time != $main::systime) { $_last_time = $main::systime; $_last_occurs = 0; - return $_last_time - $main::systime_daystart; + return $_last_pc9x_id = $_last_time - $main::systime_daystart; } else { $_last_occurs++; - return sprintf "%d.%02d", $_last_time - $main::systime_daystart, $_last_occurs; + return $_last_pc9x_id = sprintf "%d.%02d", $_last_time - $main::systime_daystart, $_last_occurs; } } @@ -1613,8 +1620,10 @@ sub handle_92 } # this is only accepted from my "self". # this also kills configs from PC92 nodes with external PC19 nodes that are also - # locally connected. Local nodes always take precedence. + # locally connected. Local nodes always take precedence. But we remember the lastid + # to try to reduce the number of dupe PC92s for this external node. if (DXChannel::get($call) && $call ne $self->{call}) { + $parent = check_pc9x_t($call, $t, 92); # this will update the lastid time dbg("PCPROT: locally connected node $call from other another node $self->{call}, ignored") if isdbg('chanerr'); return; } @@ -1639,7 +1648,7 @@ sub handle_92 return; } $parent->here(Route::here($here)); - $parent->version($version) if $version && $version > $parent->version; + $parent->version($version || $pc19_version) if $version; $parent->build($build) if $build && $build > $parent->build; $parent->PC92C_dxchan($self->{call}) unless $self->{call} eq $parent->call; shift @ent; diff --git a/perl/DXProtout.pm b/perl/DXProtout.pm index c024724f..4f4da1e5 100644 --- a/perl/DXProtout.pm +++ b/perl/DXProtout.pm @@ -19,7 +19,7 @@ use DXDebug; use strict; -use vars qw($sentencelth); +use vars qw($sentencelth $pc19_version); $sentencelth = 180; @@ -137,6 +137,8 @@ sub pc19 my $here = $ref->here; my $conf = $ref->conf; my $version = $ref->version; + $version = $pc19_version unless $version =~ /^\d\d\d\d$/; + my $str = "^$here^$call^$conf^$version"; if (length($s) + length($str) > $sentencelth) { push @out, "PC19" . $s . sprintf "^%s^", get_hops(19); diff --git a/perl/Route/Node.pm b/perl/Route/Node.pm index c1fcc543..6e7d9315 100644 --- a/perl/Route/Node.pm +++ b/perl/Route/Node.pm @@ -360,6 +360,18 @@ sub reset_obs $self->{obscount} = $obscount; } +sub measure_pc9x_t +{ + my $parent = shift; + my $t = shift; + my $lastid = $parent->{lastid}; + if ($lastid) { + return ($t < $lastid) ? $t+86400-$lastid : $t - $lastid; + } else { + return 86400; + } +} + sub DESTROY { my $self = shift; diff --git a/perl/Version.pm b/perl/Version.pm index 97d0adb5..fce61901 100644 --- a/perl/Version.pm +++ b/perl/Version.pm @@ -11,6 +11,6 @@ use vars qw($version $subversion $build); $version = '1.54'; $subversion = '0'; -$build = '141'; +$build = '142'; 1;