ds-unlinkd
German Version
This perl-script unlinks a connection from the DStar-gateway to another
gateway or a reflector based on different criterias.
The criterias for unlinking may be:
-
timeout of local traffic, where a single beaconing station will not
trigger the timer
-
local users work with direct adresses (not CQCQCQ like usual for
linked repeaters)
-
users work with area adresses
The script can also set up a specified default link.
This setup can start after a specified wait time after last local
traffic. This timer is not triggered by a single beaconing station.
Area adressed traffic can also be ignored where needed.
The script reads the logfile created by dplus continuesly.
Currently it expects the format of dplus version 2.2c - 2.2f.
The script runs as a daemon.
The callsign and the ID of the repeater module need to be set in the
configuration file.
Several instances can be run with different configuration files for
different repeater modules.
Example call with callsign and module-ID:
./ds-unlinkd /etc/ds-unlinkd-b.conf
&
This command will start ds-unlinkd with configuration file /etc/unlinkd-b.conf.
./ds-unlinkd -d
/etc/ds-unlinkd-b.conf
This command will do the same but will show debug output on the screen
and to a debug logfile in the /var/log directory.
Example call with standard configfile /etc/ds-unlinkd.conf:
./ds-unlinkd &
If the first commandline parameter is -d the debug mode is switched
on, the script will then show some information about the different timers.
The commandline parameter -h or -? at the first position
shows a short help and then exits.
For those who are not familiar with Linux:
The "&" at the end of the command will force the shell to fork
the script to a new shell running in the background.
This is necessary if you do not want to keep the shell open, for example
when starting it from an ssh-session which will be closed later.
In the configfile you need to configure a few things:
-
the timeout of local traffic after which you want to unlink the modul
-
the time to wait after local traffic until a default link should be set up
Here a sample:
#-----------------------------------------------------------------------------
# Configuration Part:
#-----------------------------------------------------------------------------
#
# the BASE-Callsign of the repeater:
$RptrCall = "XX0XXX";
#
# the ID of the module that you want to unlink:
$Module = "B";
#
# idle timeout for local traffic (in minutes) until a link is unlinked
# (0 = never)
$LocalTimeout = 15;
#
# Waittime after local traffic until the defaultlink will be set up
again (in minutes)
# (0 = never)
$SetupWaittime = 10;
#
# beacon interval in minutes (standard beacon and defaultlink-announcement)
# (a value of 0 switches the beacons off)
$BeaconTimer = 0;
#
# beacon text sent if not linked (max 20 characters!)
# |12345678901234567890|
$BeaconText = "this is a sampletext";
#
# Number of maximum direct adressed frames from local stations before
unlink
# (0 = don't care)
$MaxDirAdrLoc = 2;
#
# Maximum number of remote frames until unlink
# (0 = don't care)
$MaxDirAdrRem = 10;
#
# allow area repeating when linked (1 = yes / 0 = no)
# "no" will treat area adressing like direct adressing
$AreaRep = 1;
#
#-----------------------------------------------------------------------------
# please change the following settings only if really necessary!
#-----------------------------------------------------------------------------
#
# path and name of the dplus-logfile
##$dplogfile = "/var/log/dplus.log";
#
# path and name of our logfile (switch off logging by using /dev/null)
##$logfile = "/var/log/ds-unlinkd-$Module.log";
#
#-----------------------------------------------------------------------------
# End of configuration part!
#-----------------------------------------------------------------------------
A default-link can be defined in the file
/dstar/tmp/defaultlink-?
where the "?" is the letter for the module on which it should be established.
The content of this file must be the callsign or reflectorname filled
up with spaces to 7 chars, followed by the module ID at the 8th position
and a final linefeed.
Example:
In my case I have a file /dstar/tmp/defaultlink-b and
it's content is "REF006 D"
This connects my module B to REF006 Module D.
Another control file is
/dstar/tmp/ds-unlink-?-off
example:
/dstar/tmp/ds-unlink-b-off
If this file exists the script controlling module "B" will not disconnect
after a timeout.
How it works:
-
If /dstar/tmp/ds-unlink-?-off exists the script will
not check for timeout.
-
If the defaultlink is defined in /dstar/tmp/defaultlink-? and established
the script will do nothing.
-
If a different link is established it will check for the timeout after
the last local user activity. In case of a timeout the link is disconnected.
After the defined wait time the defaultlink is set up.
-
If no link is set up - the last user disconnected manual - the script checks
also for the waittime after last local usertraffic and sets up the defaultlink.
I don't like to set up a link during a QSO, so it waits for timeout at
this place also.
Defaultlinks can easily be set und unset by cron:
-
If the file defining the defaultlink is removed, the link will run into
a normal timeout.
-
If a new file defining a defaultlink is created, the link will be set up
after the timeout period.
That means a link is only set up when the repeater is not in use, not
during a running QSO.
-
If the content of the file defining the defaultlink is changed, the old
link will run into a timeout and the new will be set up.
- The script creates a file /tmp/no.beacon . This can be used to prevent
any other tools from sending beacons during voice traffic.
Example: I am using this flag to stop the time beacons on every full hour.
Cron deletes the file 2 minutes before the hour, if the time beacon script
finds a new flag at the full hour it just ends and does not announce the time.
The script will send an own voice beacon after the time specified in the parameter
"BeaconTime" without traffic. In this case "traffic" means both, local and remote.
The script uses 2 different beacons depending on the linkstatus of the repeater.
At my gateway a voice message "DB0MYK" is sent in case the repeater is not linked
and a longer version "DB0MYK linked to Reflector 6 delta" if the defaultlink is established.
This beacons are stored in the usual dvtool-format in the files
- /dstar/dv/beacon.dvtool and
- /dstar/dv/defaultlink-?.dvtool
with the modulename instead of "?" (lower case).
This script only uses the logfile of dplus and interfaces that have
been documented by the DPlus group.
The script triggers the timers only based on frames which show changing
mycall-entries.
This is a simple try to eliminate beacons from one single station,
it will not work when more than one station is sending regular beacons.
It may be necessary to modify other settings if the dplus-installation
is not default.
The logfiles will get different names for each module automatically,
the modulname is always appended to the basename of the logfile.
Better do not change anything on that unless you know what you are
doing.
Do not use the same logfile for different modules / instances of this
tool, it will mess up the log or create errors!
If you have only limited diskspace you may switch logging off by setting
$logfile="/dev/null";
This script needs to be started after dplus. You may start it automatically
from a startscript after dplus is up or you may modify the startup script
of dplus.
A sample startscript will follow with a future version.
The script creates a module specific PID-file /var/run/ds-unlinkd-<ID>.pid
which may be used to stop it.
That should be all!
If you have any questions or remarks please let me know.
Thanks to all who brought in some good ideas!
Finally the Download-Link:
http://download.prgm.org/dl5di-soft/dstar-tools/dstar-unlinkd/ds-unlinkd-latest.tgz
This daemon is a replacement for the unlink-script.
If you are updating from the old version to
this new please don't forget to remove the startup in the crontab!
July 06th 2009
73 de Hans, DL5DI
Email: dl5di - at - prgm.org
Web: http://dl5di.prgm.org