Follow these step if you wish to capture and upload BACnet traffic without the use of the Optigo Capture Tool.
Pre-requisites
- Install Wireshark and allow network capture for your user
- Determine the interface you wish to capture the network traffic (e.g. BACnet traffic) AND confirm you are able to capture network traffic using Powershell.
You have two options to do this:
- Open Wireshark and start capture (double-click on interface). Confirm you are capturing the desired network traffic (e.g. BACnet). If you do not see the interface you need, try running Wireshark in Administrator mode.
- Or, Open Powershell (you may have to run as Administrator), and run "tshark -i X". Replace X with the interface number you wish to capture network traffic on. If you don't know the interface number, use "tshark -D" to get complete list.
Confirm this command lists the desired network traffic (e.g. UDP port 47808 for BACnet)
- Open Wireshark and start capture (double-click on interface). Confirm you are capturing the desired network traffic (e.g. BACnet). If you do not see the interface you need, try running Wireshark in Administrator mode.
Capturing packets using tshark
In some instances, it may be desirable to capture network traffic using wireshark/tshark instead of using the Optigo Capture Tool
- Create a folder where to save PCAP files
- Open
- Run the following tshark command with appropriate changes
tshark.exe -i 1 -f "udp port 47808" -b duration:3600 -b files:20 -w capture_47808.pcapng
- Replace "-i 1" with the interface number to capture from. See Pre-requisites for more details
- Replace "udp port 47808" with the desired capture filter. Here are some examples,
- "udp port 47809" to capture traffic with BACnet packets on UDP port 47809 only
- "udp portrange 47808-47823" to capture BACnet traffic on all UDP ports from 47808 to 47823
- "udp port 47808 && host 192.168.123.45" to BACnet traffic on UDP Port 47808 to and from host/device with IP address 192.168.123.45. This filter can be particularly useful with BMS systems registered to multiple sites using Foreign Device Registration to BACnet traffic only to and from a specific site.
- Replace "-b duration:3600" with the length of time for each file before writing to a new file. "3600" is 1 hour.
- Replace or remove "-b files:20" to limit the maximum number of files it can keep. If exceeded, tshark will keep only the last number of files defined. This can be useful for system with limited disk space or to exceed a total number of files.
- If using custom BACnet ports (e.g. 47807), add the following parameter
-d "udp.port==47807,bvlc"
Notes:
- Multiple instantiations of the tshark.exe command can run simultaneously. This can be useful if you wish to capture traffic of different parameters (e.g. 47808 and 47809) into different folders.
- If you wish to have this tshark capture run automatically upon computer boot-up, you can use the Microsoft Task Scheduler. Note this will open a Windows Command Prompt window and it needs to remain open
- Open Task Scheduler
- Create Basic Task...
- Give the task a Name -> Next
- Select "When the computer starts" -> Next
- Select "Start a program" -> Next
- In Program/script, find "tshark.exe" (e.g. "C:\Program Files\Wireshark\tshark.exe")
- Set "Add arguments" to the following and adjust as appropriate (set step 2 above for details)
"-i 1 -f "udp port 47808" -b duration:3600 -b files:20 -w capture_47808.pcapng" - Set "Start in": to a folder where you want to save the capture files (e.g. c:\Users\Me\test_capture)
- Save
Upload to OptigoVN using Powershell script
This Powershell script will check for presence of PCAP file in a folder and upload these to OptigoVN for a given apiKey. Once a file is successfully uploaded, the file and sub-folders are deleted locally.
- Download the attached upload_and_delete.ps1 script
- Update the apiKey in the above script to match the apiKey of the Monitoring Node to receive the PCAP files
- Create a Microsoft Task Scheduler basic task. Note this will open a Windows Command Prompt window and it needs to remain open
- Open Task Scheduler
- Create Basic Task...
- Give the task a Name -> Next
- Select "Daily" as trigger -> Next
- Select an appropriate start time (note additional modification below for hourly trigger)
- Select "Start a program" -> Next
- In Program/script, "powershell.exe"
- Set "Add arguments" to the following and adjust path to the powershell script created above
"-ExecutionPolicy Bypass -NoProfile -File "D:\upload_and_delete.ps1" - Set "Start in": to a folder where the capture files are saved (e.g. c:\Users\Me\test_capture)
- Save
- Once the task is created. Open it for edit. In the "Triggers" panel, edit the trigger to "Repeat task every: 1 hour"
Comments
0 comments
Article is closed for comments.