VOLTTRON / dnp3-python

Apache License 2.0
9 stars 8 forks source link

Create example demo to show master outstation communication at different VM (i.e., with different IP) #13

Closed kefeimo closed 1 year ago

kefeimo commented 1 year ago

Issue

Create example demo to show master outstation communication at different VM (i.e., with different IP)

One typical use case

image

craig8 commented 1 year ago

@kefeimo bump

portal-cat commented 1 year ago

To demonstrate master outstation communication at different VMs:

  1. Create two virtual machines (VMs) with different IP addresses, then install the dnp3-python library on both VMs (We can use virtualization software such as VirtualBox or VMware to create the VMs.)
    • After creating two VMs, use the command line to confirm the IP address of each VM:
    • VM 1:
      nino@nino-vm:~$ ip addr show
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
          inet 127.0.0.1/8 scope host lo
             valid_lft forever preferred_lft forever
          inet6 ::1/128 scope host 
             valid_lft forever preferred_lft forever
      2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
          link/ether 00:0c:29:ca:3a:e4 brd ff:ff:ff:ff:ff:ff
          altname enp2s1
          inet 192.168.14.165/24 brd 192.168.14.255 scope global dynamic noprefixroute ens33
             valid_lft 1697sec preferred_lft 1697sec
          inet6 fe80::db21:86ae:a9de:5d4e/64 scope link noprefixroute 
             valid_lft forever preferred_lft forever
    • VM 2:
      nino@nino-vm:~$ ip addr show
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
          inet 127.0.0.1/8 scope host lo
             valid_lft forever preferred_lft forever
          inet6 ::1/128 scope host 
             valid_lft forever preferred_lft forever
      2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
          link/ether 00:50:56:31:73:4c brd ff:ff:ff:ff:ff:ff
          altname enp2s1
          inet 192.168.14.167/24 brd 192.168.14.255 scope global dynamic noprefixroute ens33
             valid_lft 1702sec preferred_lft 1702sec
          inet6 fe80::2f65:e8c7:a44d:b72b/64 scope link noprefixroute 
             valid_lft forever preferred_lft forever
    • Use the command to install the dnp3-python package on each VM:
      pip install -i https://test.pypi.org/simple/ dnp3-python==0.2.3b2

      If there is an error code: “No module named 'argcomplete'”, please install argcomplete package:

      pip install argcomplete
  2. Set one of the VMs to act as the master. Here's a simple example script that sends a request to link the outstation:
    dnp3demo master --outstation-ip= 192.168.14.167
  3. Set the other VM to act as the outstation. Here's a simple example script that sends a request to link the master:
    dnp3demo outstation
  4. Verify that the communication is working by checking the output of the master, It should print the following contents:

    • Master:
      
      ms(1680886137163) INFO    tcpclient - Connecting to: 192.168.14.167
      ms(1680886137167) INFO    tcpclient - Connected to: 192.168.14.167
      channel state change: OPEN
      ==== Master Operation MENU ==================================
      <ao> - set analog-output point value (for remote control)
      <bo> - set binary-output point value (for remote control)
      <dd> - display/polling (outstation) database
      <dc> - display configuration
      =================================================================

    ======== Your Input Here: ==(master)======

    - Outstation:
    ```shell
    ms(1680886137121) INFO    server - Accepted connection from: 192.168.14.165
    ==== Outstation Operation MENU ==================================
    <ai> - update analog-input point value (for local reading)
    <ao> - update analog-output point value (for local control)
    <bi> - update binary-input point value (for local reading)
    <bo> - update binary-output point value (for local control)
    <dd> - display database
    <dc> - display configuration
    =================================================================
    
    ======== Your Input Here: ==(outstation)======

This is just a simple example to demonstrate the basic communication between a master and an outstation. We can modify the agents to send and receive more complex data and handle other types of requests.

kefeimo commented 1 year ago

@portal-cat , this looks a good start. Can you create a PR, adding a file called "Outstation-and-Master-Connection-Demo.md" to "docs/" folder: https://github.com/VOLTTRON/dnp3-python/tree/main/docs. to develop branch.

In that way, it would be easier to make inline comment and feedback. So far,

Thank you.

portal-cat commented 1 year ago

I just submitted a pull request on the GitHub https://github.com/portal-cat/dnp3-python/tree/develop/docs

kefeimo commented 1 year ago

Closed with PR #37