=== Step 12: Link the shared memory to remote host === * To read and write channel data from and to the shared memory, please refer [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step10|step10]] and [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step11|step11]] * Here we try to link the channel data in shared memory at CAL low-latency machine to the DMG machine * We can use "framelink" program in GDS (gds-2.18.7/Utilities/FrUtils/framelink.cc) * Check the existing shared memory partition with "smlist" and kill it with "smkill" if it already exists {{{#!python part = options.partition lbuf = options.lbuf port = ':'+options.port sl = commands.getoutput('smlist') ss = sl.split('\n') if len(ss) > 1: for s in ss[1:]: cc = s.split() if cc[1] == part: print 'Killing the current partition:',cc[1] os.system('smkill '+cc[1]) }}} * Create a shared memory with specified buffer length, which should be large enough compared with the frame file data size {{{#!python print 'Creating a new partition:',part,'with lbuf=',lbuf os.system('smcreate '+part+' -lbuf '+str(lbuf)) os.system('smlist') }}} * Run "framelink" with either receive or push mode {{{#!python opt = '' if options.debug: opt = ' --verbose /dev/stdout --debug 1000' print 'Starting framelink...' if options.mode == 'receive': os.system('framelink'+opt+' receive 0.0.0.0'+port+' '+part) else: os.system('framelink'+opt+' push '+part+' '+options.host+port) }}} * The python scripts are available at git repository {{{ > kagra-cal/Observation/Phase1/tutorials/flink --help Usage: flink [options] Options: -h, --help show this help message and exit --mode=mode Set the operation mode, either from "receive" or "push". --partition=name Set the name of the shared memory partition to write to. --host=host Set the host name --port=port Set the port number (default= 23232) --lbuf=size Set the shared memory buffer size (default= 200000) --debug Show debug messages }}} * Here is an example to send the shared memory from the CAL machine to DMG machine * At the DMG machine, start the receiver server {{{ > kagra-cal/Observation/Phase1/tutorials/flink --mode=receive --debug Killing the current partition: KGR_hoft Creating a new partition: KGR_hoft with lbuf= 200000 id name nBuf lBuf nTotal 32 KGR_hoft 4 200000 0 Starting framelink... 2018.08.21-08:27:39 Look up peer: 0.0.0.0:PORT 2018.08.21-08:27:39 Starting framelink: $Id: framelink.cc 7922 2017-08-03 00:14:52Z john.zweizig@LIGO.ORG $ 2018.08.21-08:27:39 arguments are: --verbose /dev/stdout --debug 1000 receive 0.0.0.0:PORT KGR_hoft 2018.08.21-08:27:39 Verbose logging enabled to: /dev/stdout 2018.08.21-08:27:39 Binding socket to server address: 0.0.0.0 2018.08.21-08:27:39 Listening to server socket 2018.08.21-08:27:39 Waiting for client connection }}} * At the CAL machine, start the pusher client {{{ > kagra-cal/Observation/Phase1/tutorials/flink --mode push --host HOSTNAME --debug Creating a new partition: KGR_hoft with lbuf= 200000 id name nBuf lBuf nTotal 32 KGR_hoft 4 200000 0 Starting framelink... 2018.08.21-08:33:43 Look up peer: HOSTNAME:PORT 2018.08.21-08:33:43 Starting framelink: $Id: framelink.cc 7922 2017-08-03 00:14:52Z john.zweizig@LIGO.ORG $ 2018.08.21-08:33:43 arguments are: --verbose /dev/stdout --debug 1000 push KGR_hoft HOSTNAME:PORT 2018.08.21-08:33:43 Verbose logging enabled to: /dev/stdout 2018.08.21-08:33:43 Connecting to server: HOSTNAME # Connected to: HOSTNAME 2018.08.21-08:33:43 framelink: Attaching consumer to partition KGR_hoft }}} * At the DMG machine, it shows that the connection is established {{{ 2018.08.21-08:28:53 Client connected 2018.08.21-08:28:53 Keep-alive set 2018.08.21-08:28:53 framelink: Attaching producer to partition KGR_hoft 2018.08.21-08:29:53 framelink: Waiting for frame from 0.0.0.0 }}} * At the CAL machine, run "dpush" as in [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step10|step 10]] you can put a channel data into the shared memory {{{ > kagra-cal/Observation/Phase1/tutorials/dpush --debug --shared-memory-partition=KGR_hoft Opening partition KGR_hoft for output. Opened frame file: 1sec/K-K1_TEST-1209288320-1.gwf Read frame: file-length/rc 68771 / 68771 Opened frame file: 1sec/K-K1_TEST-1209288321-1.gwf Waiting 999874usec. Read frame: file-length/rc 65135 / 65135 Opened frame file: 1sec/K-K1_TEST-1209288322-1.gwf Waiting 999564usec. Read frame: file-length/rc 66984 / 66984 Opened frame file: 1sec/K-K1_TEST-1209288323-1.gwf Waiting 999553usec. ... }}} * At the CAL machine, you can check that the frame data is sent to the DMG machine {{{ 1218875715 get 1209288320 68771 OK. 2018.08.21-08:34:57 sent header block, len, gps, time = {0, 68771, 1209288320, 1} 1218875715 put 1209288320 68771 OK. 1218875716 get 1209288321 65135 OK. 2018.08.21-08:34:58 sent header block, len, gps, time = {1, 65135, 1209288321, 1} 1218875716 put 1209288321 65135 OK. 1218875717 get 1209288322 66984 OK. 2018.08.21-08:34:59 sent header block, len, gps, time = {2, 66984, 1209288322, 1} 1218875717 put 1209288322 66984 OK. 1218875718 get 1209288323 63983 OK. 2018.08.21-08:35:00 sent header block, len, gps, time = {3, 63983, 1209288323, 1} ... }}} * At the DMG machine, you can check that the frame data is received from the CAL machine {{{ 2018.08.21-08:34:57 received header block, len, gps, time = {0, 68771, 1209288320, 1} 2018.08.21-08:34:57 Data length inferred from first block. dt = 1 1218875715 get 1209288320 68771 OK. 1218875715 put 1209288320 68771 OK. 2018.08.21-08:34:58 received header block, len, gps, time = {1, 65135, 1209288321, 1} 1218875716 get 1209288321 65135 OK. 1218875716 put 1209288321 65135 OK. 2018.08.21-08:34:59 received header block, len, gps, time = {2, 66984, 1209288322, 1} 1218875717 get 1209288322 66984 OK. 1218875717 put 1209288322 66984 OK. 2018.08.21-08:35:00 received header block, len, gps, time = {3, 63983, 1209288323, 1} 1218875718 get 1209288323 63983 OK. 1218875718 put 1209288323 63983 OK. 2018.08.21-08:35:01 received header block, len, gps, time = {4, 65568, 1209288324, 1} ... }}} * [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step11|(Prev) Step 11: Write channel data to shared memory]] * [[KAGRA/Subgroups/CAL/GstLAL/tutorials|Tutorials]]