logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

The goal of this assignment is to extend the chat server and client the most exciting feature will be support for emotes

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Chat Server and Client

Introduction

The goal of this assignment is to extend the chat server and client from Tutorial 11 with new features. The most exciting feature will be support foremotes. This assignment also asks you to demonstrate a number of the learning outcomes from earlier in the course: ability to learn about systemsutilities independently, use of file operations, use of fork, etc. That is, this assignment is the capstone of this course.The only new starter code provided for this assignment is: (1) A new socket.h with updates to the macro definitions. (2) A new chat_server.c that turnsoff SIGPIPE(the rest of the file is identical to the Tutorial 11 starter code). Aside from that, your solution to Tutorial 11 will be your starter code forAssignment 4.

Reliability and Security

The remarks mentioned in Tutorial 11 under the "A Note on Software Quality, Reliability, and Security" heading apply to this assignment as well. Insummary, both the client and server must validate all protocol messages received. If your client encounters an invalid protocol message, it shouldterminate. If your server encounters an invalid protocol message from a client, it should disconnect that client and continue serving the other clients.

Recommendation: Testing Client from Another Computer

We encourage you (but we are not marking this for completion) to implement optionalcommand-line arguments in the client to allow you to specify ahostname or IP address to connect to. If no command-line arguments are provided, your program should fall back to using the default host (localhost, or127.0.0.1) and port (specified in the Makefile). You should be able to implement this with just a few lines of code—see randclient.c to see how it is donethere (word of warning, though: randclient.c exits if no command-line arguments are provided, instead of falling back to a default hostname/port.

New Requirements for your Chat Program

This assignment adds a number of features to your Tutorial 11: the addition of an admin role, restrictions on usernames, the addition of emotes to thechat, and an updated protocol to enable these new features.

An Updated Chat Protocol

To s u p p o r t t h e n e w fe a t u re s , we w i l l n e e d t o u p d a t e o u r c h a t p ro t o c o l with a new message format. All protocol messages sent by your client must followthe format:PROTO_MSG_CODE USER_MESSAGE CRLFPROTO_MSG_CODE is a single character that serves to identify the type of message that the client is sending:Message code 0 (the ASCII character 0) indicates a "kick" command from the chat server administrator. In this case, USER_MESSAGE is the user nameof the client that should be kicked from the server.Message code 1 (the ASCII character 1) indicates that USER_MESSAGE is a text message consisting of a sequence of 0 to MAX_USR_MSGprintable ASCIIcharacters. This is followed by a CRLF sequence. If the client is sending their username upon connecting to the server, the message code is still 1but USER_MESSAGEmust be a user name consisting of 0 to MAX_NAME characters. This functionality should have been completed in the tutorials.Message code 2 (the ASCII character 2) indicates that USER_MESSAGE is an emote, consisting of a sequence of up to MAX_IMG_LENbytes that composea Base64-encoded JPEG file (explained later). As required by the protocol, these bytes are followed by a CRLF sequence.All protocol messages sent by your server be in the format:PROTO_MSG_CODE USER_NAME SPACE USER_MESSAGE CRLFAll of the fields in this format have already been described either above or in the Tutorial 11 instructions. The only change from Tutorial 11 to Assignment 4is the addition of the PROTO_MSG_CODE field. Note that there is no space between PROTO_MSG_CODE and USER_NAME.Due: 10 p.m. on Wednesday, April 1, 2020 (submit to your MarkUs git repository). Since this tutorial will be marked by automated scripts, pleaseensure that you follow the submission instructions exactly, including the required file names and directory structure.

Admin

One user connected to the server will be designated the admin, and that user has the ability to kick (disconnect) any user from the server.The admin is always the user that has been connected for the longest period of time. As a result, the first client to connect to the server is the first admin.If the first client disconnects from the server at some point, the next most "senior" user becomes the admin (i.e., the next user that has been around thelongest). This method is simpler than it sounds. (Hint: You don't need to keep track of time.)To k i c k a u s e r, t h e a d m i n u s e r c a n t y p e t h e fo l l ow i n g c o m m a n d i n t o t h e c l i e n t : .k username. In accordance with the protocol message format, theresulting protocol message that the client sends to the server will be 0usernamern. The server should ignoreany kick commands from non-admin users.(To reiterate: A non-admin issuing a kick should not be considered an invalid message; it should just be ignored.)

Duplicate Names

In the assignment 4 chat application, no two users can share the same user name, and they may not pick the all-caps username SERVERas theirusername. If a new user attempts to log in with an invalid username (e.g., SERVER, an oversized username, or one that is already taken), the server shouldrespond with the ASCII sequence 1SERVER Username invalid or already taken.rn and disconnect the client.

Base64 Encoding of Emotes

Base64 is a subset of ASCII. Your chat client will need to make use of the UNIX base64 utility to encode and decode data to and from Base64. Asexplained in man base64, this utility follows the RFC 4648 variant of Base64, which uses the characters A-Z, a-z, 0-9, -, and _. If necessary, = is used atthe end as a padding character to ensure that the total number of characters in the encoded data is always a multiple of 4.Base64 is very popular across many applications, which is why you can find many online toolsthat can encode/decode Base64. Its appeal is that it allowsyou to take any data and convert it into a form that can be printed as human-readable text, without any unprintable or control characters. E-mailattachments are sent in Base64-encoded form, for example. It is also a popular way of storing other data such as cryptographic keys(that "trick" worksfor any Github account set up with SSH public keys), since it makes it easier to copy them around or print them out for backup purposes.The disadvantage of Base64 is that any encoded data will be about 37% larger than the original unencoded data length. The reason why is fairlystraightforward: Since the Base64 encoding process restricts the value of each character to one of 64 printable characters out of the 256 possiblevalues that an 8-bit character can normally hold, a greater number of characters are required to represent the same data. If that confuses you, thinkabout it this way: Why is it that the number 255 can be printed with 3 characters in decimal representation, but its binary equivalent (11111111) requires 8characters to print, even though both the decimal and binary values represent the exact same number?For our chat protocol, the appeal of using Base64 is that the encoded image will never inadvertently contain any control characters, such as a CRLFsequence (i.e., 0x0D0A in hexadecimal, or rn when represented as control characters) that your server or client would interpret as a protocol messageterminator. In contrast, the original JPEG file may inadvertently contain a CRLF sequence or other control characters such as a 0x00 byte (which might beinterpreted as a string terminator by some string-handling functions in C).

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

803 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

682 Answers

Hire Me
expert
Husnain SaeedComputer science

531 Answers

Hire Me
expert
Atharva PatilComputer science

765 Answers

Hire Me

Get Free Quote!

276 Experts Online