Multicast Network Trigger
The camera supports being triggered by the receipt of a network multicast UDP packet. This is useful when you have multiple cameras that need to be triggered close to the same time but do not need to be genlocked. The advantage of triggering via a network multicast packet is extra cabling between the camera is not needed.
The edgertronic multicast trigger network protocol is straight forward. Only one packet is defined and the payload has 4 bytes data.
|Address||18.104.22.168||Any valid IP multicast address - 22.214.171.124 .. 126.96.36.199|
|Port||600||Any valid UDP port number - 1 .. 65535|
|Payload||0x05AA9544||Any four byte value transmitted in network order.|
The above three values are specified in the multicast-trigger.conf configuration file as described below.
Send a multicast network trigger packet using the supplied python application sctrigger.py with no parameters so the default address, port, and payload value will be used:
Produces the output:
Sending multicast packet to address 188.8.131.52 port 600 with payload 0x05AA9544
Using wireshark, the captured network packet is:
Configuring the camera consists of providing a multicast-trigger.conf configuration file stored on a removable storage device (SD card or USB thumbdrive) and powering on the camera. The camera will copy the multicast-trigger.conf file to internal storage (micro SD card). From that point on, each time the camera is powered on, it can be triggered by sending a well formed multicast IP packet to the camera.
The format of the configuration file complies with the python configuration file format. In summary, a python configuration file consists of sections, led by a [section] header and followed by name=value entries.
The contents of the multicast-trigger.conf configuration file contains one section [multicast-trigger] and three keys:
|address||184.108.40.206||220.127.116.11 .. 18.104.22.168||IP multicast address|
|port||600||1 .. 65535||UDP port number|
|payload||0x05AA9544||0x00000000 .. 0xFFFFFFFF||4 byte payload|
multicast-trigger.conf file example
[multicast-trigger] address = 22.214.171.124 port = 600 payload = 0x05AA9544
You can retrieve the above example file from the camera using the URL http://10.11.12.13/static/sdk/multicast/multicast-trigger.conf
Example python program to trigger cameras
The camera ships with the example python program, sctrigger.py, in source code format. sctrigger.py showing one way to generate a multicast packet that triggers the camera. You can find the program at http://10.11.12.13/static/sdk/multicast/sctrigger.py
The critical portion of sctrigger.py (leaving out command line parameter parsing) is:
import socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 32) print "Sending multicast packet to address %s port %d with payload %s" % (options.multicast_address, options.port, options.cookie_payload) ... sock.sendto(data, (options.multicast_address, options.port))
A socket is created, set to send multicast packets, and then a packet is sent to the specified address and port containing the specified payload. The sctrigger.py that can be retrieved from the camera is a full working example.
You can see the various command line options using the standard --help parameter.
usage: sctrigger.py [-h] [-d DEBUG] [-m MULTICAST_ADDRESS] [-p PORT] [-c COOKIE_PAYLOAD] edgertronic endurance tests optional arguments: -h, --help show this help message and exit -d DEBUG, --debug DEBUG Debug level, 0=none, 1=info, 2=debug -m MULTICAST_ADDRESS, --multicast_address MULTICAST_ADDRESS Multicast IP address to use to trigger the camera -p PORT, --port PORT Multicast IP port to use to trigger the camera -c COOKIE_PAYLOAD, --cookie_payload COOKIE_PAYLOAD Contents of the packet data that is sent
Limitations and comments on multicast network triggering
- There is an unknown and variable amount of delay between when the multicast packet is sent and a camera triggers.
- Cameras receiving the multicast trigger packet will not trigger at exactly the same time.
- The multicast network trigger packet my not arrive at a camera since UDP is not a reliable transport service. Most local area networks have very high packet delivery rates. You can send two trigger packets to reduce the chance a camera doesn't receive a multicast network trigger packet. You can also use CAMAPI to verify the camera triggered properly.
- If you need 100% reliable trigger and/or the ability to correlate frames captured by multiple cameras, you should use wired trigger and/or genlock instead of multicast network trigger.
- If you are using fixed IP addresses, then you likely need to manually add a route. On a Mac, you can add a route via
sudo route -nv add -net 126.96.36.199 -netmask 188.8.131.52 -interface en0 netstat -nr