Skip to content
Snippets Groups Projects
Commit cda89b64 authored by Jan David Mol's avatar Jan David Mol
Browse files

bug 1362: improved packet analysis

parent 73248dc9
No related branches found
No related tags found
No related merge requests found
...@@ -65,9 +65,11 @@ unsigned char packet[MAX_PACKETSIZE]; ...@@ -65,9 +65,11 @@ unsigned char packet[MAX_PACKETSIZE];
#define IP (*(struct IP_header *)packet) #define IP (*(struct IP_header *)packet)
#define UDP (*(struct UDP_header *)((char*)packet + IP.headerlength * 4)) #define UDP (*(struct UDP_header *)((char*)packet + IP.headerlength * 4))
#define EPA (*(struct EPA_header *)((char*)&UDP + UDP_HEADERSIZE)) #define EPA (*(struct EPA_header *)((char*)&UDP + UDP_HEADERSIZE))
#define DATA ((signed char *)((char*)&EPA + EPA_HEADERSIZE)) #define DATA8 ((uint8_t *)((char*)&EPA + EPA_HEADERSIZE))
#define DATA16 ((uint16_t *)((char*)&EPA + EPA_HEADERSIZE))
#define DATA32 ((uint32_t *)((char*)&EPA + EPA_HEADERSIZE))
#define PAYLOAD_SIZE (UDP.length - EPA_HEADERSIZE) #define PAYLOAD_SIZE (UDP.length - EPA_HEADERSIZE - UDP_HEADERSIZE)
#define EXPECTED_PPS(clock) (1.0*clock*1e6/1024/EPA.times) #define EXPECTED_PPS(clock) (1.0*clock*1e6/1024/EPA.times)
/* a filter for the packets we're looking for */ /* a filter for the packets we're looking for */
...@@ -223,21 +225,57 @@ int main( int argc, char **argv ) { ...@@ -223,21 +225,57 @@ int main( int argc, char **argv ) {
} else { } else {
int zeros = 0; int zeros = 0;
int i; int i;
int elementbits = 0;
unsigned elements;
do { do {
recv( fd, &packet, sizeof packet, 0 ); recv( fd, &packet, sizeof packet, 0 );
} while( !PACKETFILTER( port ) ); } while( !PACKETFILTER( port ) );
elements = EPA.beamlets * EPA.times * 2 /* polarizations */;
if( elements == 0 ) elements = 1; /* avoid dividing by 0 */
/* little endian -> big endian */ /* little endian -> big endian */
swap16( (char*)&EPA.station ); swap16( (char*)&EPA.station );
swap32( (char*)&EPA.RSPtimestamp ); swap32( (char*)&EPA.RSPtimestamp );
for( i = 0; i < PAYLOAD_SIZE; i++ ) { if( PAYLOAD_SIZE == elements * 4 ) { /* i16complex */
if( !DATA[i] ) { elementbits = 16;
zeros++;
for( i = 0; i < elements; i ++ ) {
if( !(DATA32[i] & 0xffff) ) {
zeros++;
}
if( !(DATA32[i] >> 16) ) {
zeros++;
}
}
} else if( PAYLOAD_SIZE == elements * 2 ) { /* i8complex */
elementbits = 8;
for( i = 0; i < elements; i ++ ) {
if( !(DATA16[i] & 0xff) ) {
zeros++;
}
if( !(DATA16[i] >> 8) ) {
zeros++;
}
}
} else if( PAYLOAD_SIZE == elements ) { /* i4complex */
elementbits = 4;
for( i = 0; i < elements; i ++ ) {
if( !(DATA8[i] & 0x0f) ) {
zeros++;
}
if( !(DATA8[i] >> 4) ) {
zeros++;
}
} }
} }
elements *= 2 ; /* compensate for real/imag */
union { union {
uint32_t integer; uint32_t integer;
unsigned char parts[4]; unsigned char parts[4];
...@@ -272,6 +310,13 @@ int main( int argc, char **argv ) { ...@@ -272,6 +310,13 @@ int main( int argc, char **argv ) {
printf("NOK Time samples: %d (should be 16?)\n",EPA.times); printf("NOK Time samples: %d (should be 16?)\n",EPA.times);
} }
if( elementbits == 0 ) {
printf("NOK Sample type: UNKNOWN (payload = %d, expected samples = #beamlets * #times * 2 * 2 = %d)\n",PAYLOAD_SIZE,elements);
} else {
printf(" OK Sample type: i%dcomplex\n",elementbits);
}
if( EPA.RSPtimestamp == -1 ) { if( EPA.RSPtimestamp == -1 ) {
printf("NOK Timestamp UTC: UNDEFINED (0xffffffff)\n"); printf("NOK Timestamp UTC: UNDEFINED (0xffffffff)\n");
} else { } else {
...@@ -283,12 +328,12 @@ int main( int argc, char **argv ) { ...@@ -283,12 +328,12 @@ int main( int argc, char **argv ) {
} }
} }
if( zeros == PAYLOAD_SIZE ) { if( zeros == elements ) {
printf("NOK Zeros in payload: %.f %%\n",100.0*zeros/PAYLOAD_SIZE); printf("NOK Zeros in payload: %.f %%\n",100.0*zeros/elements);
} else if( zeros > 0.5 * PAYLOAD_SIZE ) { } else if( zeros > 0.25 * PAYLOAD_SIZE ) {
printf("NOK Zeros in payload: %.f %% (did you set up %d beamlets?)\n",100.0*zeros/PAYLOAD_SIZE,EPA.beamlets); printf("NOK Zeros in payload: %.f %% (did you set up %d beamlets?)\n",100.0*zeros/elements,EPA.beamlets);
} else { } else {
printf(" OK Zeros in payload: %.f %%\n",100.0*zeros/PAYLOAD_SIZE); printf(" OK Zeros in payload: %.f %%\n",100.0*zeros/elements);
} }
if( rate < 0.99 * EXPECTED_PPS(160) if( rate < 0.99 * EXPECTED_PPS(160)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment