# DP Data Formats

## Introduction

The Digital Processor (DP) will output data three types: DRX, TBW, and TBN. The Mark5C specification [1] is a starting point for the Data Payload output format for the DRX, TBN and TBW data. Customizations to the Mark5C format were made for the LWA data structures. While future compatibility with Mark5C recorders is a desire, it is not a requirement in this specification and is not guaranteed.

All data values are signed numbers in two’s complement format. It should also be noted that only the Mark 5C portion of the packet is recorded.

## Data Formats

### DRX Output Interface

Figure 1 describes the LWA DRX Output Format.

The DRX Output will utilize Ethernet (shown in gray), IP [3] (shown in blue), UDP [4] (shown in purple), and Mark 5C [1] (shown in yellow) headers. The Data Payload size is fixed (4156 bytes) and fits within an Ethernet jumbo packet. Each data frame will contain data of one polarization (X or Y), one DRX tuning, and 4096 samples. The Mark 5C header will include an ID field that identifies which polarization and tuning is associated with the data, as described in Table 1.

The Mark 5C header will include Frame Count and Seconds Count fields for compatibility purposes but both of these fields will always be set to zero. The Data Frame header will include a Decimation Factor field that describes the decimation factor used in producing the output data. The output sample rate is fs/Decimation Factor. The Data Frame header will also include a Time Offset field that provides the known time offset (Tnom in LWA Memo 151 [2]), in units of 1/fs since the beginning of the second. The Data Frame will include a Time field (t1 in LWA Memo 151 [2]) in units of 1/fs since 1970 January 1 00:00 UTC. For the i-th sample of the frame, the time at that sample is related to the frame time tag through:

$t_i = \mbox{time} + (i-1) \times \frac{\mbox{DecimationFactor}}{f_s}$.


The Data Frame will also include a tuning word, a unsigned 32-bit integer, which specifies the central tuning of the DRX data. This tuning word, w, can be converted to a frequency in Hz via:

$f = \frac{w}{2^{32}} f_s$,


where fs is defined as 196 MHz. The status/flags field in the Data Frame is currently unimplemented in the DRX firmware and is set to zero for all frames.

Each sample is 8 bits total (4 bits I and 4 bits Q). Therefore 4096 samples require 4096 bytes. Inside each 32-bit word, the data will be arranged in the following order (from MSB to LSB):

I0 (bits 31-28), Q0 (bits 27-24), I1 (bits 23-20), Q1 (bits 19-16),
I2 (bits 15-12), Q2 (bits 11-8), I3 (bits 7-4), Q3 (bits 3-0).


The numbers in paraphrases are the bits within each sample such that 0 is the LSB.

### TBN Output Interface

TBN data will be 16 bits (8 bits each of I and Q). Figure 2 describes the LWA TBN Output Format.

The TBN Output will utilize Ethernet (shown in gray), IP [3] (shown in blue), UDP [4] (shown in purple), and Mark 5C [1] (shown in yellow) headers. The Data Payload size is fixed (1076 bytes) and fits within a standard Ethernet packet. A Data Frame will contain 512 samples or 1024 bytes of complex data (I and Q) from a particular stand (of 260) of one polarization (X or Y).

The Mark 5C header includes an ID field, but it is not sufficient to specify the data’s stand, polarization, and other identifying information. This field will be included for Mark 5C compatibility but will always be set to zero. Instead, the Data Frame header will include a TBN_ID field that identifies which stand and polarization are associated with the data. See Appendix A.2 for the numbering scheme used. The MSB of TBN_ID will be 0, to indicate TBN data. The Data Frame will also include a tuning word, a unsigned 32-bit integer, which specifies the central tuning of the TBN data. This tuning word can be converted to a frequency in Hz via:

$f = \frac{w}{2^{32}} f_s$,


where fs is defined as 196 MHz.

The Data Frame will include a Time Tag field that provides total number of samples at fs since 1970 January 1 00:00 UTC. Inside each 32-bit word, the data will be arranged in the following order (from MSB to LSB):

I0 (byte3), Q0 (byte2), I1 (byte1), Q1 (byte0).


### TBW Output Interface

TBW data will be 12 or 4 bits for each of two polarizations, for a total of either 24 or 8 bits per sample, respectively. Figure 3 describes the LWA TBW Output Format.

The TBW Output will utilize Ethernet (shown in gray), IP [3] (shown in blue), UDP [4] (shown in purple), and Mark 5C [1] (shown in yellow) headers.

The Data Payload size is fixed (1252 bytes) and fits within a standard Ethernet packet. A Data Frame will contain real data from a particular stand (of 260) and both polarizations (X and Y). If the data are 12-bit, each Data Frame will contain 400 samples or 1200 bytes. If the data are 4-bit, each Data Frame will contain 1200 samples or 1200 bytes.

The Mark 5C header includes an ID field, but it is not sufficient to specify the data’s stand and other identifying information. This field will be included for Mark 5C compatibility but will always be set to zero. Instead, the Data Frame header will include a TBW_ID field that identifies which stand is associated with the data. See Appendix A.2 for the numbering scheme used. The MSB of TBW_ID will be 1, to indicate TBW data. The next most significant bit will be 0 for 12-bit data and 1 for 4-bit data. The Data Frame will include a Time Tag field that provides the effective sampling time of the first sample of data (X0 and Y0), in total number of samples at fs since 1970 January 1 00:00 UTC.

The data is packed binary, big-endian. Inside each 32-bit word, the data will be arranged in the following order:

X0, Y0, X1, Y1, ...


For example, the first 3 bytes consist of:

X0(11:4), [X0(3:0) Y0(11:8)], Y0(7:0)


for 12-bit samples and:

[X0(3:0) Y0(3:0)], [X1(3:0) Y1(3:0)], [X2(3:0) Y2(3:0)]


for 4-bit samples. The brackets indicate a single byte and the number in parentheses are the bits within each sample such that 0 is the LSB.

## References

[1] “Mark 5C Specification,” authored jointly by Haystack and NRAO, available at http://www.haystack.mit.edu/tech/vlbi/mark5/mark5_memos/057.pdf. February, 2008.

[2] L. D'Addario, LWA Memo 151: LWA Signal Delays and Time Tagging. December 22, 2008.

[3] Postel, J. B., ed. "Internet Protocol," RFC 791. September, 1981.

[4] Postel, J. B. "User Datagram Protocol," RFC 768. August, 1980.

## Appendix A

### DRX_ID Numbering

Table 1: DRX_ID Numbering

DRX_BEAM DRX_TUNING Polarization DRX_ID
1 1 X 9
1 1 Y 137
1 2 X 17
1 2 Y 145
2 1 X 10
2 1 Y 138
2 2 X 18
2 2 Y 146
3 1 X 11
3 1 Y 139
3 2 X 19
3 2 Y 147
4 1 X 12
4 1 Y 140
4 2 X 20
4 2 Y 148

DRX Numbering is as follows: DRX_ID is an unsigned 8-bit integer. Bits 0-2 are used to represent DRX_BEAM, bits 3-5 are used to represent DRX_TUNING, bit 6 is reserved for future use, and bit 7 is used to represent polarization.

### Stand and Polarization Numbering

Stands are numbered s=1…260. Stand s includes channels 2*(s-1)+1 (X polarization) and 2*(s-1)+2 (Y polarization) and therefore channels are numbered c=1…2*520.