Changeset 7e6b54d
- Timestamp:
- 09/03/15 15:21:45 (6 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 0a368ae
- Parents:
- 87cba74
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_rt.c
r5ab626a r7e6b54d 98 98 /* Header for the packet currently being received */ 99 99 rt_header_t rt_hdr; 100 101 int unacked; 100 102 101 103 /* Dummy traces that can be assigned to the received packets to ensure … … 155 157 } 156 158 157 switch (connect_msg.type) { 159 if (connect_msg.magic != LIBTRACE_RT_MAGIC) { 160 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, 161 "RT version mismatch: magic byte is incorrect"); 162 return -1; 163 } 164 165 if (connect_msg.version != LIBTRACE_RT_VERSION) { 166 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, 167 "RT version mismatch: version is incorrect (expected %d, got %d", 168 LIBTRACE_RT_VERSION, connect_msg.version); 169 return -1; 170 } 171 172 173 174 switch (ntohl(connect_msg.type)) { 158 175 case TRACE_RT_DENY_CONN: 159 176 /* Connection was denied */ … … 164 181 reason = 0; 165 182 } 166 reason = deny_hdr.reason;183 reason = ntohl(deny_hdr.reason); 167 184 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, 168 185 "Connection attempt is denied: %s", … … 179 196 return -1; 180 197 } 181 RT_INFO->reliable = hello_opts.reliable;182 198 199 200 RT_INFO->reliable = hello_opts.reliable; 201 RT_INFO->unacked = 0; 183 202 return 0; 184 203 default: … … 207 226 RT_INFO->hostname = NULL; 208 227 RT_INFO->port = 0; 228 RT_INFO->unacked = 0; 209 229 } 210 230 … … 245 265 rt_header_t start_msg; 246 266 247 start_msg.type = TRACE_RT_START;267 start_msg.type = htonl(TRACE_RT_START); 248 268 start_msg.length = 0; 249 269 … … 265 285 rt_header_t close_msg; 266 286 267 close_msg.type = TRACE_RT_CLOSE;287 close_msg.type = htonl(TRACE_RT_CLOSE); 268 288 close_msg.length = 0; 269 289 … … 502 522 ack_hdr = (rt_ack_t *) (ack_buffer + sizeof(rt_header_t)); 503 523 504 hdr->type = TRACE_RT_ACK;505 hdr->length = sizeof(rt_ack_t);506 507 ack_hdr->sequence = seqno;508 509 to_write = hdr->length+ sizeof(rt_header_t);524 hdr->type = htonl(TRACE_RT_ACK); 525 hdr->length = htons(sizeof(rt_ack_t)); 526 527 ack_hdr->sequence = htonl(seqno); 528 529 to_write = sizeof(rt_ack_t) + sizeof(rt_header_t); 510 530 buf_ptr = ack_buffer; 511 531 … … 575 595 /* Send an ACK if required */ 576 596 if (RT_INFO->reliable > 0 && packet->type >= TRACE_RT_DATA_SIMPLE) { 577 if (rt_send_ack(libtrace, RT_INFO->rt_hdr.sequence) == -1) 597 RT_INFO->unacked ++; 598 if (RT_INFO->unacked >= RT_ACK_FREQUENCY) { 599 if (rt_send_ack(libtrace, RT_INFO->rt_hdr.sequence) 600 == -1) 578 601 return -1; 602 RT_INFO->unacked = 0; 603 } 579 604 } 580 605 … … 622 647 /* Need to store these in case the next rt_read overwrites 623 648 * the buffer they came from! */ 624 RT_INFO->rt_hdr.type = pkt_hdr->type;625 RT_INFO->rt_hdr.length = pkt_hdr->length;626 RT_INFO->rt_hdr.sequence = pkt_hdr->sequence;649 RT_INFO->rt_hdr.type = ntohl(pkt_hdr->type); 650 RT_INFO->rt_hdr.length = ntohs(pkt_hdr->length); 651 RT_INFO->rt_hdr.sequence = ntohl(pkt_hdr->sequence); 627 652 } 628 653 packet->type = RT_INFO->rt_hdr.type; -
lib/rt_protocol.h
rc5ac872 r7e6b54d 50 50 /** Maximum size for the RT header */ 51 51 #define RT_MAX_HDR_SIZE 256 52 /** Maximum sequence number for the RT protocol */ 53 #define MAX_SEQUENCE 2147483647 52 53 #define RT_ACK_FREQUENCY (10) 54 #define LIBTRACE_RT_VERSION (0x04) 55 #define LIBTRACE_RT_MAGIC (0x5a) 54 56 55 57 /* Procedure for adding new RT control types … … 84 86 uint64_t length; /**< The total length of the fifo */ 85 87 uint64_t used; /**< The amount of fifo space in use */ 86 } fifo_info_t;88 } PACKED fifo_info_t; 87 89 88 90 /** RT packet header */ 89 91 typedef struct rt_header { 90 92 /** The type of RT packet */ 91 libtrace_rt_types_t type; 92 /** The length of the packet (not including the RT header */ 93 uint32_t type; 94 95 uint8_t magic; 96 97 uint8_t version; 98 99 /** The length of the packet (not including the RT header */ 93 100 uint16_t length; 94 101 /** The sequence number of the packet */ 95 102 uint32_t sequence; 96 } rt_header_t;103 } PACKED rt_header_t; 97 104 98 105 /* TODO: Reorganise this struct once more hello info is added */ … … 103 110 * i.e. expecting acknowledgements */ 104 111 uint8_t reliable; 105 } rt_hello_t;112 } PACKED rt_hello_t ; 106 113 107 114 #if 0 … … 115 122 /** The sequence number of the last received RT packet */ 116 123 uint32_t sequence; 117 } rt_ack_t;124 } PACKED rt_ack_t; 118 125 119 126 /** RT Status sub-header */ … … 121 128 /** Statistics describing the current status of the sender fifo */ 122 129 fifo_info_t fifo_status; 123 } rt_status_t;130 } PACKED rt_status_t; 124 131 125 132 #if 0 … … 154 161 typedef struct rt_deny_conn { 155 162 /** The reason that the connection was denied */ 156 enum rt_conn_denied_t reason;157 } rt_deny_conn_t;163 uint32_t reason; 164 } PACKED rt_deny_conn_t; 158 165 159 166 #if 0 … … 187 194 /** Length of the value string that follows the header */ 188 195 uint32_t value_len; 189 } rt_metadata_t;196 } PACKED rt_metadata_t; 190 197 191 198 /** Specifications of duck structures - duck2_4 and duck2_5 match Endace's
Note: See TracChangeset
for help on using the changeset viewer.