RFC: CS.485/585 CS 485/585 Fall 2015 UNM Layer 7 Transport Protocol: UNML7TP PREFACE ........................................................ iii 1. INTRODUCTION ................................................ 1 1.1. REQUIREMENTS TERMINOLOGY ............................... 2 1.2. MOTIVATION ............................................. 3 1.3. INTERFACES ............................................. 4 1.4. PROTOCOL OVERVIEW ...................................... 5 2. FUNCTIONAL SPECIFICATION .................................... 5 2.1. MESSAGE FORMATS ........................................ 6 2.1.2. CLIENT HELLO ......................................... 6 2.1.3. SERVER HELLO ......................................... 6 2.1.4. CHUNK ................................................ 6 2.1.5. ERROR ................................................ 6 3. GLOSSARY .................................................... 7 PREFACE This document describes the application layer transport control protocol as specified in class 14 Oct. 2015. All code examples, format strings, and coding related examples in this RFC will be in C. 1. INTRODUCTION 1.1. REQUIREMENTS TERMINOLOGY The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [REQ]. 1.2. MOTIVATION This lab is intended to get you familiar with reading RFCs, defining, interperating, and implementing communications protocols for a computer network. 1.3. PROTOCOL OVERVIEW This RFC describes the UNM layer 7 transport protocol hereafter refered to as UNML7TP as defined in class on 14 Oct. 2015 for CS485/545. This protocol is built on top of the transmission control protocol hereafter refered to as TCP. TCP is an interprocess communication (IPC) mechanism that allows two applications running on different (or the same) machine to transfer data between eachother reliably and in full-duplex. Because of this fact, UNML7TP is lightweight in the sense that very little state information about the connection and data transfer will be maintained by UNML7TP. There are two components to this protocol, client messages and server messages. The server MUST listen on port 1049. It must wait indefinitely for a client to connect to it. The server MUST be able to handle mutliple conncurrent connection. Once a client has connected, the client MUST then send the CLIENT HELLO as defined in section 2.1.1. After the server receives this message from the client, it MUST reply with the SERVER HELLO as defined in section 2.1.2. The server MUST then send 1 CHUNK of data as defined in section 2.1.3. The server MUST continue to send 1 CHUNK until N chunks have been sent to the client. N is the number of chunks that the client asked for in the original CLIENT HELLO message. If the server OR the client sends an invalid CLIENT HELLO or SERVER HELLO or CHUNK, the reciever of the invalid message MUST send the ERROR message as defined in section 2.1.5 and terminate th connection. 2. FUNCTIONAL SPECIFICATION 2.1. MESSAGE FORMATS 2.1.1. CLIENT HELLO The CLIENT HELLO is a message from the client to the server. It tells the server the the client wants an arbitrary number of chunks. in the range [1, UINT_MAX). Where UINT_MAX = 4294967295. UINT_MAX specifies the largest possible value for a 32 bit unsigned integer. The exact message format MUST conform to the following format string: "HELLO I'M THE CLIENT GIVE ME %u CHUNKS\n" The meaning of '%u' MUST be interperated as the format specifier for 4 byte (32 bit) unsigned integers. The '\n' character MUST be interperated as the newline character. All other characters MUST be either uppercase ALPHBETIC, or the space character. If client sends a CLIENT HELLO to the server that does not conform to this format, the server MUST responed with an ERROR message and terminate the connection. 2.1.2. SERVER HELLO "HELLO I'M THE SERVER HERE ARE %u CHUNKS\n" The meaning of '%u' MUST be interperated as the format specifier for 4 byte (32 bit) unsigned integers. The '\n' character MUST be interperated as the newline character. All other characters MUST be either uppercase ALPHBETIC, or the space character. The server MUST specify that it is sending N CHUNKs of data, where N is the number of CHUNKs the client requested in the original CLIENT HELLO message. The server MUST then send N chunks of data to the client. If the server sends a SERVER HELLO to the client that does not conform to this format, the client MUST responed with an ERROR message and terminate the connection. 2.1.3. CHUNK A chunck is defined to be 74 bytes of characters. The server SHOULD return a string of *uniformlly distributed* random printable 8 bit ascii characters. The behavior is undefined for data sent in other formats. The only hard requirement is that the server MUST terminate the CHUNK with a '\n' character. Therefore, the total length of the message is 74 bytes random data + 1 byte newline character. CHUNK ::= <74 bytes > , '\n' If the servers sends a data buffer that does not have a '\n' character terminating the buffer, the client MUST send an ERROR message and terminate the connection. 2.1.4. ERROR The error message has the form: "ERROR\n" It is used for transport control and tells one of the two communicating parties that an error occurred and that the connectin MUST be terminated. Upon sending an ERROR message, the sender MUST then terminate the connection. Upon receiving an ERROR message, the receiver MUST then terminate the connection. 3. GLOSSARY 3.1. Making a stream socket in C: int socket = socket(AF_INET, SOCK_STREAM, 0); 3.2. Server port to listen on: 1049 3.3. CLIENT HELLO: "HELLO I'M THE CLIENT GIVE ME %u CHUNKS\n" 3.4. SERVER HELLO: "HELLO I'M THE SERVER HERE ARE %u CHUNKS\n" 3.5. CHUNK: <74 bytes of random data> + '\n' == 75 bytes total.