diff --git a/core/federated/RTI/rti_remote.c b/core/federated/RTI/rti_remote.c index b60736bda..f3d540115 100644 --- a/core/federated/RTI/rti_remote.c +++ b/core/federated/RTI/rti_remote.c @@ -377,7 +377,7 @@ void handle_port_absent_message(federate_info_t *sending_federate, unsigned char } void handle_timed_message(federate_info_t *sending_federate, unsigned char *buffer) { - size_t header_size = 1 + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(int32_t) + size_t header_size = 1 + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(int64_t) + sizeof(uint32_t); // Read the header, minus the first byte which has already been read. read_from_socket_fail_on_error( diff --git a/core/federated/federate.c b/core/federated/federate.c index 57ff1c750..46c5b89ed 100644 --- a/core/federated/federate.c +++ b/core/federated/federate.c @@ -528,7 +528,7 @@ static int handle_tagged_message(int* socket, int fed_id) { _lf_get_environments(&env); // Read the header which contains the timestamp. - size_t bytes_to_read = sizeof(uint16_t) + sizeof(uint16_t) + sizeof(int32_t) + size_t bytes_to_read = sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(instant_t) + sizeof(microstep_t); unsigned char buffer[bytes_to_read]; if (read_from_socket_close_on_error(socket, bytes_to_read, buffer)) { @@ -2653,7 +2653,7 @@ int lf_send_tagged_message(environment_t* env, buffer_head += sizeof(uint16_t); // The next four bytes are the message length. - encode_int32((int32_t)length, &(header_buffer[buffer_head])); + encode_uint32((uint32_t)length, &(header_buffer[buffer_head])); buffer_head += sizeof(int32_t); // Apply the additional delay to the current tag and use that as the intended diff --git a/core/federated/network/net_util.c b/core/federated/network/net_util.c index 813e5cd07..6bc3fd0d7 100644 --- a/core/federated/network/net_util.c +++ b/core/federated/network/net_util.c @@ -403,7 +403,7 @@ void extract_header( // printf("DEBUG: Message for port %d of federate %d.\n", *port_id, *federate_id); // The next four bytes are the message length. - int32_t local_length_signed = extract_int32(&(buffer[sizeof(uint16_t) + sizeof(uint16_t)])); + uint32_t local_length_signed = extract_uint32(&(buffer[sizeof(uint16_t) + sizeof(uint16_t)])); if (local_length_signed < 0) { lf_print_error_and_exit( "Received an invalid message length (%d) from federate %d.", diff --git a/include/core/federated/network/net_common.h b/include/core/federated/network/net_common.h index 9ea720fd7..8f2bc3f5a 100644 --- a/include/core/federated/network/net_common.h +++ b/include/core/federated/network/net_common.h @@ -386,7 +386,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Byte identifying a timestamped message to forward to another federate. * The next two bytes will be the ID of the destination reactor port. * The next two bytes are the destination federate ID. - * The four bytes after that will be the length of the message. + * The four bytes after that will be the length of the message (as an unsigned 32-bit int). * The next eight bytes will be the timestamp of the message. * The next four bytes will be the microstep of the message. * The remaining bytes are the message.