Package: volttron-dnp3-outstation
volttron-dnp3-outstationDistributed Network Protocol (DNP
orDNP3)
has achieved a large-scale acceptance since its introduction in 1993. This
protocol is an immediately deployable solution for monitoring remote sites because it was developed for communication of
critical infrastructure status, allowing for reliable remote control.DNP3 is typically used between centrally located masters and distributed remotes.
Application layer fragments from Master DNP3 stations are typically requests for operations on data
objects, and application layer fragments from Slave DNP3 stations (i.e., Outstation) are typically responses to those
requests. A DNP3 Outstation may also transmit a message without a request (an unsolicited response).
The volttron-dnp3-outstation is an implementation of the DNP3 master following
theVOLTTRON Agent Specifications.Note: to fully desmonstate the volttron-dnp3-outstation features, including polling data, setting point
values, etc., it is suggested to establish connection between an outstation and a DNP3 master instance.
Thednp3-pythoncan provide the essential master functionality,
and as
part of the volttron-dnp3-outstation dependency, it is immediately available after the volttron-dnp3-outstation is
installed.PrerequisitesPython 3 (tested with Python3.8, Python3.9, Python3.10)PythonTo install specific Python version (e.g., Python 3.8), we recommend usingpyenv.# install pyenvgitclonehttps://github.com/pyenv/pyenv~/.pyenv# setup pyenv (you should also put these three lines in .bashrc or similar)exportPATH="${HOME}/.pyenv/bin:${PATH}"exportPYENV_ROOT="${HOME}/.pyenv"eval"$(pyenvinit-)"# install Python 3.10pyenvinstall3.10# make it available globallypyenvglobalsystem3.10InstallationThe following recipe walks through the steps to install and configure a DNP3 agent. Note that it uses default setup to
work out-of-the-box. Please feel free to refer to related documentations for details.Create and activate a virtual environment.It is recommended to use a virtual environment for installing volttron.python-mvenvenvsourceenv/bin/activate

pipinstallvolttronInstall volttron and start the platform.Note:
According to thevolttron-core#README, setup VOLTTRON_HOME
environment variable is mandatory:
... if you have/had in the past, a monolithic VOLTTRON version that used the default VOLTTRON_HOME
$HOME/.volttron. This modular version of VOLTTRON cannot work with volttron_home used by monolithic version of
VOLTTRON(version 8.3 or earlier)# Setup environment variable `VOLTTRON_HOME`exportVOLTTRON_HOME=<path-to-volttron_home-dir># Start platform with output going to volttron.logvolttron-vv-lvolttron.log&Install the "volttron-dnp3-outstation" dependency.There are two options to install the DNP3 Driver. You can install this library using the version on PyPi or install
it from the source code (git clonemight be required.)
Note: thevctl installcommand in the following step can handle dependency installation using pypi. However, in
this demo we demonstrate what is happening under the neath the hood by separating the dependency installation and agent registry
steps.# option 1: install from pypipipinstallvolttron-dnp3-outstation# option 2: install from the source code (Note: `-e` option to use editable mode, useful for development.)pipinstall[-e]<path-to-the-source-code-root>/volttron-dnp3-outstation/Install and start the "volttron-dnp3-outstation" agent.Prepare the default config files:# Create config file place holdersmkdirconfig
touchconfig/dnp3-outstation-config.jsonEdit thednp3-outstation-config.jsonas follows:{"outstation_ip":"0.0.0.0","master_id":2,"outstation_id":1,"port":21000}Usevctl installcommand to register to the volttron home path.
Note: for demo purposes and reproducibility, we assign vip-identity as "dnp3_outstation", but you can choose
any other valid agent identity as desired.vctlinstallvolttron-dnp3-outstation--agent-config<path-to-agent-config>\--vip-identitydnp3_outstation\--start(Optional) Usevctl stautsto verify the installation(env)kefei@ubuntu-22:~/sandbox/dnp3-outstation-sandbox$vctlstatus
UUIDAGENTIDENTITYTAGPRIORITYSTATUSHEALTH
evolttron-dnp3-outstation-0.0.1rc0dnp3_outstationrunning[3408]GOODBasic Usage ExampleLike other VOLTTRON agent, the volttron-dnp3-outstation agent provides public interface and can be evoked by VOLTTRON
RPC calls. The volttron-dnp3-outstation provided a commandline interfacevdnp3_outstationas an RPC method wrapper.
Please seerun_volttron_dnp3_outstation_cli.pyfor
implementation details of the RPC examples.(Optional) Inspect the dnp3 outstation cli help menu.(env)kefei@ubuntu-22:~/sandbox/dnp3-driver-sandbox$python-mvdnp3_outstation.run_volttron_dnp3_outstation_cli-h
usage:dnp3-outstation[-h][-aid<peer-name>]Runadnp3outstationagent.Specifyagentidentity,bydefault`dnp3_outstation`options:-h,--helpshowthishelpmessageandexit-aid<peer-name>,--agent-identity<peer-name>specifyagentidentity(parsedaspeer-nameforrpccall),default'dnp3_outstation'.Start the dnp3 outstation cliStart the volttron-dnp3-outstation cli. If you
follow along this demo, the agent vip-identity should be "dnp3_outstation".(env)kefei@ubuntu-22:~/sandbox/dnp3-agent-sandbox$python-mvdnp3_outstation.run_volttron_dnp3_outstation_cli--agent-identitydnp3_outstation2023-03-2311:51:25,975rootDEBUG:CreatingZMQCoreNone2023-03-2311:51:25,975volttron.client.vip.agent.coreDEBUG:address:ipc://@/home/kefei/.volttron/run/vip.socket2023-03-2311:51:25,975volttron.client.vip.agent.coreDEBUG:identity:08953498-18e6-4070-9576-521bad3e82be2023-03-2311:51:25,975volttron.client.vip.agent.coreDEBUG:agent_uuid:None2023-03-2311:51:25,975volttron.client.vip.agent.coreDEBUG:serverkey:None2023-03-2311:51:25,976volttron.client.vip.agent.coreDEBUG:environkeys:dict_keys(['SHELL','SESSION_MANAGER','QT_ACCESSIBILITY','COLORTERM','XDG_CONFIG_DIRS','SSH_AGENT_LAUNCHER','XDG_MENU_PREFIX','GNOME_DESKTOP_SESSION_ID','CONDA_EXE','_CE_M','GNOME_SHELL_SESSION_MODE','SSH_AUTH_SOCK','HOMEBREW_PREFIX','XMODIFIERS','DESKTOP_SESSION','GTK_MODULES','PWD','LOGNAME','XDG_SESSION_DESKTOP','XDG_SESSION_TYPE','MANPATH','SYSTEMD_EXEC_PID','XAUTHORITY','VOLTTRON_HOME','HOME','USERNAME','IM_CONFIG_PHASE','LANG','LS_COLORS','XDG_CURRENT_DESKTOP','VIRTUAL_ENV','VTE_VERSION','WAYLAND_DISPLAY','GNOME_TERMINAL_SCREEN','INFOPATH','GNOME_SETUP_DISPLAY','LESSCLOSE','XDG_SESSION_CLASS','TERM','_CE_CONDA','LESSOPEN','USER','HOMEBREW_CELLAR','GNOME_TERMINAL_SERVICE','CONDA_SHLVL','DISPLAY','SHLVL','QT_IM_MODULE','HOMEBREW_REPOSITORY','VIRTUAL_ENV_PROMPT','CONDA_PYTHON_EXE','XDG_RUNTIME_DIR','PS1','XDG_DATA_DIRS','PATH','GDMSESSION','DBUS_SESSION_BUS_ADDRESS','_','RABBITMQ_NOT_AVAILABLE'])2023-03-2311:51:25,976volttron.client.vip.agent.coreDEBUG:serverkeyfromenvNone2023-03-2311:51:25,976volttron.client.vip.agent.coreDEBUG:AGENTRUNNINGonZMQCore08953498-18e6-4070-9576-521bad3e82be2023-03-2311:51:25,976volttron.client.vip.agent.coreDEBUG:keys:server:_M0Ds3SfjECMrmXulHQZtPIlsYW7JwzXMXJH1Koy2T4public:_M0Ds3SfjECMrmXulHQZtPIlsYW7JwzXMXJH1Koy2T4,secret:yfjc9g5znWMEjTSX3kfINGwhCvaDI80fK8vN76-C7SQ2023-03-2311:51:25,977volttron.client.vip.zmq_connectionDEBUG:ZMQconnection08953498-18e6-4070-9576-521bad3e82be2023-03-2311:51:25,977volttron.client.vip.zmq_connectionDEBUG:connectingtourlipc://@/home/kefei/.volttron/run/vip.socket?publickey=_M0Ds3SfjECMrmXulHQZtPIlsYW7JwzXMXJH1Koy2T4&secretkey=yfjc9g5znWMEjTSX3kfINGwhCvaDI80fK8vN76-C7SQ&serverkey=_M0Ds3SfjECMrmXulHQZtPIlsYW7JwzXMXJH1Koy2T42023-03-2311:51:25,977volttron.client.vip.zmq_connectionDEBUG:urltypeis<class'str'>2023-03-2311:51:25,981volttron.client.vip.agent.coreINFO:Connectedtoplatform:identity:08953498-18e6-4070-9576-521bad3e82beversion:1.02023-03-2311:51:25,981volttron.client.vip.agent.coreDEBUG:Runningonstartmethods.=========================MENU==================================<ai>-setanalog-inputpointvalue
<ao>-setanalog-outputpointvalue
<bi>-setbinary-inputpointvalue
<bo>-setbinary-outputpointvalue<dd>-displaydatabase
<di>-display(outstation)info
<cr>-configthenrestartoutstation=================================================================!!!!!!!!!WARNING:TheoutstationisNOTconnected!!!!!!!!!{'outstation_ip_str':'0.0.0.0','port':20000,'masterstation_id_int':2,'outstation_id_int':1,'peer':'dnp3_outstation'}========YourInputHere:==(DNP3OutStationAgent)======Start a dnp3 master to establish connection.If there is no connection between an outstation and a master, you may see the
warning!!!!!!!!! WARNING: The outstation is NOT connected !!!!!!!!!. To establish such a connection,open
another terminal, and
rundnp3demo master. (More details about the "dnp3demo" module, please
seednp3demo-Module.md)=====MasterOperationMENU==================================<ao>-setanalog-outputpointvalue(forremotecontrol)<bo>-setbinary-outputpointvalue(forremotecontrol)<dd>-display/polling(outstation)database<dc>-displayconfiguration=========================================================================YourInputHere:==(master)======Note: by default, both the volttron-dnp3-outstation and the dnp3demo master uses configurations to
assure valid connection out-of-the-box. e.g., port=20000. Feel free to configure the connection parameters as
desired.Basic volttron-dnp3-outstation operations======== Your Input Here: ==(DNP3 OutStation Agent)======
ai
You chose <ai> - set analog-input point value
Type in <float> and <index>. Separate with space, then hit ENTER. e.g., `1.4321, 1`.
Type 'q', 'quit', 'exit' to main menu.

======== Your Input Here: ==(DNP3 OutStation Agent)======
0.1212 0
{'Analog': {0: 0.1212, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None}}
You chose <ai> - update analog-input point value (for local reading)
Type in <float> and <index>. Separate with space, then hit ENTER.
Type 'q', 'quit', 'exit' to main menu.


======== Your Input Here: ==(DNP3 OutStation Agent)======
1.2323 1
{'Analog': {0: 0.1212, 1: 1.2323, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None}}
You chose <ai> - update analog-input point value (for local reading)
Type in <float> and <index>. Separate with space, then hit ENTER.
Type 'q', 'quit', 'exit' to main menu.Example of interaction with the `vdnp3_outstation` module(env)kefei@ubuntu-22:~/sandbox/dnp3-agent-sandbox$python-mvdnp3_outstation.run_volttron_dnp3_outstation_cli--agent-identitydnp3_outstation
dnp3demo.run_outstation{'command':'outstation','outstation_ip=':'0.0.0.0','port=':20000,'master_id=':2,'outstation_id=':1}ms(1678770551216)INFOmanager-Startingthread(0)2023-03-1400:09:11,216control_workflow_demoINFOConnectionConfig2023-03-1400:09:11,216control_workflow_demoINFOConnectionConfig2023-03-1400:09:11,216control_workflow_demoINFOConnectionConfig
ms(1678770551216)INFOserver-Listeningon:0.0.0.0:200002023-03-1400:09:11,216control_workflow_demoDEBUGInitializationcomplete.Outstationincommandloop.2023-03-1400:09:11,216control_workflow_demoDEBUGInitializationcomplete.Outstationincommandloop.2023-03-1400:09:11,216control_workflow_demoDEBUGInitializationcomplete.Outstationincommandloop.
Connectionerror.
ConnectionConfig{'outstation_ip_str':'0.0.0.0','port':20000,'masterstation_id_int':2,'outstation_id_int':1}Startretry...
Connectionerror.
ConnectionConfig{'outstation_ip_str':'0.0.0.0','port':20000,'masterstation_id_int':2,'outstation_id_int':1}ms(1678770565247)INFOserver-Acceptedconnectionfrom:127.0.0.1====OutstationOperationMENU==================================<ai>-updateanalog-inputpointvalue(forlocalreading)<ao>-updateanalog-outputpointvalue(forlocalcontrol)<bi>-updatebinary-inputpointvalue(forlocalreading)<bo>-updatebinary-outputpointvalue(forlocalcontrol)<dd>-displaydatabase
<dc>-displayconfiguration=========================================================================YourInputHere:==(DNP3OutStationAgent)======ai
Youchose<ai>-updateanalog-inputpointvalue(forlocalreading)Typein<float>and<index>.Separatewithspace,thenhitENTER.
Type'q','quit','exit'tomainmenu.========YourInputHere:==(DNP3OutStationAgent)======0.12120{'Analog':{0:0.1212,1:None,2:None,3:None,4:None,5:None,6:None,7:None,8:None,9:None}}Youchose<ai>-updateanalog-inputpointvalue(forlocalreading)Typein<float>and<index>.Separatewithspace,thenhitENTER.
Type'q','quit','exit'tomainmenu.========YourInputHere:==(DNP3OutStationAgent)======1.23231{'Analog':{0:0.1212,1:1.2323,2:None,3:None,4:None,5:None,6:None,7:None,8:None,9:None}}Youchose<ai>-updateanalog-inputpointvalue(forlocalreading)Typein<float>and<index>.Separatewithspace,thenhitENTER.
Type'q','quit','exit'tomainmenu.========YourInputHere:==(DNP3OutStationAgent)======DevelopmentPlease see the following for contributing
guidelinescontributing.Please see the following helpful guide
aboutdeveloping modular VOLTTRON agentsDisclaimer NoticeThis material was prepared as an account of work sponsored by an agency of the
United States Government. Neither the United States Government nor the United
States Department of Energy, nor Battelle, nor any of their employees, nor any
jurisdiction or organization that has cooperated in the development of these
materials, makes any warranty, express or implied, or assumes any legal
liability or responsibility for the accuracy, completeness, or usefulness or any
information, apparatus, product, software, or process disclosed, or represents
that its use would not infringe privately owned rights.Reference herein to any specific commercial product, process, or service by
trade name, trademark, manufacturer, or otherwise does not necessarily
constitute or imply its endorsement, recommendation, or favoring by the United
States Government or any agency thereof, or Battelle Memorial Institute. The
views and opinions of authors expressed herein do not necessarily state or
reflect those of the United States Government or any agency thereof.