feat(routing): Support session based routing

The session id field in a message buffer is now used
directly for routing.

Change-Id: I3634c97588b11172db964b2d06c96c317d8b8ae3
Signed-off-by: E. Scott Daniels <daniels@research.att.com>

Routing table entry changes to pick up subid

Change-Id: If08dc21aae4acaab350ba75a8854ad2f24007b03
Signed-off-by: E. Scott Daniels <daniels@research.att.com>

Fix unit test for rmr_call

It was not properly setting message type and now that RMr
ensures that invalid message type is set by default on a newly
created message this was causing unit test to fail.

Change-Id: I50f08d1038ea7fca2a070cdd949657bfbc25f3fd
Signed-off-by: E. Scott Daniels <daniels@research.att.com>

Add application level tests

Added round robin and multi group application level
test scripts.

Change-Id: Ic6aebaf3bc1edb763decc7fd0aebb09df116f20c
Signed-off-by: E. Scott Daniels <daniels@research.att.com>

NNG based sub-id support added

Change-Id: I0d36b55bb90a315ba94c9476df88e2c7eac6c383
Signed-off-by: E. Scott Daniels <daniels@research.att.com>

Correct bug in app test script

Change-Id: I5b4a9f32aa1bc2907f320b8ad4628e0948062904
Signed-off-by: E. Scott Daniels <daniels@research.att.com>

Nano sub-id changes and unit test updates

Change-Id: Ia69f2fb33de3bbee2f33f9a4c5def779c872e52c
Signed-off-by: E. Scott Daniels <daniels@research.att.com>

Change nil-sub_id key to high order key

If there is no sub-id, then the key is based only on the
message type, but to allow for a sub-id == 0 the key
when there is no subscription id must be set to
0xffffffff00000000 + msg type.

New version for deb is 1.0.19

Change-Id: I55f89d368466a0137fdea99410c76ba72e1923ab
Signed-off-by: E. Scott Daniels <daniels@research.att.com>
diff --git a/test/app_test/receiver.c b/test/app_test/receiver.c
index dd639ce..ed2450b 100644
--- a/test/app_test/receiver.c
+++ b/test/app_test/receiver.c
@@ -99,12 +99,15 @@
 	long good = 0;						// good palyload buffers
 	long bad = 0;						// payload buffers which were not correct
 	long bad_tr = 0;					// trace buffers that were not correct
+	long bad_sid = 0;					// bad subscription ids
 	long timeout = 0;
 	char*	data;
-	char	wbuf[1024];					// we'll pull trace data into here
 	int		nmsgs = 10;					// number of messages to stop after (argv[1] overrides)
 	int		rt_count = 0;				// retry count
 	long ack_count = 0;					// number of acks sent
+	int		count_bins[11];				// histogram bins based on msg type (0-10)
+	char	wbuf[1024];					// we'll pull trace data into here, and use as general working buffer
+	char	sbuf[128];					// short buffer
 
 	data = getenv( "RMR_RTG_SVC" );
 	if( data == NULL ) {
@@ -118,6 +121,8 @@
 		listen_port = argv[2];
 	}
 
+	memset( count_bins, 0, sizeof( count_bins ) );
+
 	fprintf( stderr, "<RCVR> listening on port: %s for a max of %d messages\n", listen_port, nmsgs );
 
 	mrc = rmr_init( listen_port, RMR_MAX_RCV_BYTES, RMRFL_NONE );	// start your engines!
@@ -165,11 +170,21 @@
 				}
 				count++;									// messages received for stats output
 
-				if( msg->mtype == 5 ) {						// send an ack; sender will count but not process, so data in message is moot
-					msg = rmr_rts_msg( mrc, msg );								// we don't try to resend if this returns retry
+				if( msg->mtype < 3 ) {							// count number of properly set subscription id
+					if( msg->sub_id != msg->mtype * 10 ) {
+						bad_sid++;
+					}
+				}
+
+				if( msg->mtype >= 0 && msg->mtype <= 10 ) {
+					count_bins[msg->mtype]++;
+				}
+
+				if( msg->mtype == 5 ) {											// send an ack; sender will count but not process, so data in message is moot
+					msg = rmr_rts_msg( mrc, msg );
 					rt_count = 1000;
 					while( rt_count > 0 && msg != NULL && msg->state == RMR_ERR_RETRY ) {		// to work right in nano we need this :(
-						if( ack_count < 1 ) {									// need to connect, so hard wait
+						if( ack_count < 1 ) {									// 1st ack, so we need to connect, and we'll wait for that
 							sleep( 1 );
 						}
 						rt_count--;
@@ -189,7 +204,16 @@
 		}
 	}
 
-	fprintf( stderr, "<RCVR> [%s] %ld messages;  good=%ld  acked=%ld bad=%ld  bad-trace=%ld\n", !!(errors + bad + bad_tr) ? "FAIL" : "PASS", count, good, ack_count, bad, bad_tr );
+	wbuf[0] = 0;
+	for( i = 0; i < 11; i++ ) {
+		snprintf( sbuf, sizeof( sbuf ), "%6d ", count_bins[i] );
+		strcat( wbuf, sbuf );
+	}
+
+	fprintf( stderr, "<RCVR> mtype histogram: %s\n", wbuf );
+	fprintf( stderr, "<RCVR> [%s] %ld messages;  good=%ld  acked=%ld bad=%ld  bad-trace=%ld bad-sub_id=%ld\n", 
+		!!(errors + bad + bad_tr) ? "FAIL" : "PASS", count, good, ack_count, bad, bad_tr, bad_sid );
+
 	sleep( 2 );									// let any outbound acks flow before closing
 
 	rmr_close( mrc );