ECE 4122/6122 Hmk #4 (100 pts)Section Due Date89313 - ECE 4122 - A Oct 20th, 2019 by 11:59 PM89314 - ECE 6122 - A Oct 20th, 2019 by 11:59 PM89340 - ECE 6122 - Q Oct 23th, 2019 by 11:59 PM89706 - ECE 6122 - QSZ Oct 23th, 2019 by 11:59 PMECE 4122 students need to do Problem 1. ECE 6122 students need to do Problem 2.Notes:You can write, debug and test your code locally on your personal computer. However, the code yousubmit must compile and run correctly on the PACE-ICE server.In this homework you will need to develop two executable programs. One program for the server andone for the client.Submitting the Assignment:See Appendix C.Grading RubricAUTOMATIC GRADING POINT DEDUCTIONS PER PROBLEM:Element Percentage Deduction DetailsDoes Not Compile 40% Code does not compile on PACE-ICE!Does Not Match Output 10%-90% The code compiles but does not producecorrect outputs.Clear Self-DocumentingCoding Styles10%-25% This can include incorrect indentation, usingunclear variable names, unclear/missingcomments, or compiling with warnings. (See Appendix A)LATE POLICYElement PercentageDeductionDetailsLate Deduction Function score -(20/24)*HH = number of hours (ceiling function) passed deadlinenote : Sat/Sun count as one day; therefore H = 0.5*Hweekend2Problem #1 TCP SocketsServer-70 pointsWrite a console program that takes as a command line argument the port number on whichthe TCP Server will listen for connection requests. A separate thread shall be created to handlethe data received from each remote client and the remote clients can continue to send andreceive data on the connections until either the server or the client closes the connection. TheTCP server needs to maintain a list of all connected clients so that it can send out theappropriate messages. The TCP server needs to be able to receive data from clients withoutblocking the main application thread. The program needs to respond to user input whilehandling socket communications at the same time.1) The program should continuously prompt the user for commands to execute like so:Please enter command: 0 - prints to the console the last message received (if any)Last Message: last message receivedPlease enter command: 1 - prints to the console a list of all connected clients (ip address andport number) like the following:Numer of Clients: 2IP Address Portlocalhost 51717localhost 51718Please enter command: q - closes all sockets and terminates the program2) The data being sent back and forth will use the following packet structure:struct tcpMessage{ unsigned char nVersion; unsigned char nType; unsigned short nMsgLen; char chMsg[1000];};The TCP server needs to have the following functionality for received messages:• If nVersion is not equal to 1 then the message is ignored.• If nType == 0 then the message should be sent to all other connected clients exactly asreceived (but not the client that sent the message).3• If nType == 1 then the message is reversed and sent back to only the client that sent themessage.Client-30 pointsIn order to test your server, write a console program that takes as a command line argumentthe IP Address and port number of the server as shown below:./a.out localhost 51717The program should prompt the user for inputs and display any messages received.Here are example user inputs:Please enter command: v # the user enters a “v”, a space, and then aversion number. This version number is nowused in all new messages.Please enter command: t # message string the user enters a “t”, a space, and then a typenumber, followed by the message. Be sure youare able to handle the spaces in the messagestring.Please enter command: q the user enters a “q” causes the socket to beclosed and the program to terminate.Any messages received from the server should be displayed as followed:Received Msg Type: #; Msg: message received4Problem #2 UDP SocketsUDP Server (60 points)Write a console program that takes as a command line argument the port number on whichthe UDP Server will receive messages. The UDP server collects parts of a larger compositemessage from the clients. The UDP server collects these message parts from different clientsand assembles them in order, based on the lSeqNum. The UDP server keeps a running list of allclients that have sent a message to it and will broadcast the composite message to all clientswhen commanded. The UDP server needs to be able to receive data from clients withoutblocking the main application thread. The program needs to respond to user input whilehandling socket communications at the same time.The program should continuously prompt the user for commands to execute like so:Please enter command: 0Please enter command: 1Please enter command: 2Composite Msg: current composite messageThe data being sent back and forth will use the following packet structure:struct udpMessage{ unsigned char nVersion; unsigned char nType; unsigned short nMsgLen; unsigned long lSeqNum; char chMsg[1000];};The UDP server needs to have the following functionality from the command prompt:• If command == 0 the server immediately sends to all clients the current compositemessage and clears out the composite message.• If command == 1 the server immediately clears out the composite message.• If command == 2 the server immediately displays to the console the composite messagebut takes no other actions.The UDP server needs to have the following functionality when receiving messages:• If nVersion is not equal to 1 then the message is ignored.5• If nType == 0 the composite message is immediately cleared and anything in the chMsgbuffer is ignored.• If nType == 1 the composite message is immediately cleared and the message in chMsgis used as the start of a new composite message• If nType == 2 the message in chMsg is added to the composite message based on itslSeqNum• If nType == 3 the server immediately sends to all clients the current composite messageand clears out the composite message.If the composite message becomes larger than 1000 then the composite message (up to 1000)is immediately set out to all clients and any remaining characters are used to start a newcomposite message with a lSeqNum = 0.UDP Client (40 points)In order to test your server, write a console program that takes as a command line argumentthe IP Address and port number of the server as shown below:./a.out localhost 51717The program should prompt the user for inputs and display any messages received.Here are example user inputs:Please enter command: v # the user enters a “v”, a space, and then aversion number. This version number is nowused in all new messages.Please enter command: t # # message string the user enters a “t”, a space, and then a typenumber, and then a sequence number, followedby the message (if any). Be sure you are able tohandle the spaces in the message.Please enter command: q the user enters a “q” causes the socket to beclosed and the program to terminate.Any messages received should be displayed as followed:Received Msg Type: 1, Seq: 33, Msg: message received6Appendix A: Coding StandardsIndentation:When using if/for/while statements, make sure you indent 4 spaces for the content inside those. Alsomake sure that you use spaces to make the code more readable.If you have nested statements, you should use multiple indentions. Each { should be on its own line (likethe for loop) If you have else or else if statements after your if statement, they should be on their ownline.This naming convention has the first letter of the variable be lower case, and the first letter in each newword be capitalized (e.g. firstSecondThird). This applies for functions and member functions as well! Themain exception to this is class names, where the first letter should also be capitalized.Variable and Function Names:Your variable and function names should be clear about what that variable or function is. Do not use oneletter variableECE 4122/6122代做、C/C++程序语言调试、代写s, but use abbreviations when it is appropriate (for example: “imag instead of“imaginary”). The more descriptive your variable and function names are, the more readable your codewill be. This is the idea behind self-documenting code. 7File Headers:Every file should have the following header at the top/*Author: Class: ECE4122 or ECE6122Last Date Modified: Description:What is the purpose of this file?*/Code Comments:1. Every function must have a comment section describing the purpose of the function, the inputand output parameters, the return value (if any).2. Every class must have a comment section to describe the purpose of the class.3. Comments need to be placed inside of functions/loops to assist in the understanding of the flowof the code.8Appendix B: Accessing PACE-ICE InstructionsACCESSING LINUX PACE-ICE CLUSTER (SERVER)To access the PACE-ICE cluster you need certain software on your laptop or desktop system, as describedbelow.Windows Users:Option 0 (Using SecureCRT)- THIS IS THE EASIEST OPTION!The Georgia Tech Office of Information Technology (OIT) maintains a web page of software that can bedownloaded and installed by students and faculty. That web page is:http://software.oit.gatech.eduFrom that page you will need to install SecureCRT.To access this software, you will first have to log in with your Georgia Tech user name and password,then answer a series of questions regarding export controls.Connecting using SecureCRT should be easy.• Open SecureCRT, youll be presented with the Quick Connect screen.• Choose protocol ssh2.• Enter the name of the PACE machine you wish to connect to in the HostName box (i.e.coc-ice.pace.gatech.edu)• Type your username in the Username box.• Click Connect.• A new window will open, and youll be prompted for your password.Option 1 (Using Ubuntu for Windows 10):Option 1 uses the Ubuntu on Windows program. This can only be downloaded if you are runningWindows 10 or above. If using Windows 8 or below, use Options 2 or 3. It also requires the use of simplebash commands.1. Install Ubuntu for Windows 10 by following the guide from the following link:https://msdn.microsoft.com/en-us/commandline/wsl/install-win102. Once Ubuntu for Windows 10 is installed, open it and type the following into the command line:ssh **YourGTUsername**@coc-ice.pace.gatech.edu where **YourGTUsername** isreplaced with your alphanumeric GT login. Ex: bkim3343. When it asks if you’re sure you want to connect, type in:yes 9and type in your password when prompted (Note: When typing in your password, it will not showany characters typing)4. You’re now connected to PACE-ICE. You can edit files using vim by typing in:vi filename.cc OR nano vilename.cppFor a list of vim commands, use the following link:5. You’re able to edit, compile, run, and submit your code from this command line.Option 2 (Using PuTTY):Option 2 uses a program called PuTTY to ssh into the PACE-ICE cluster. It is easier to set up, but doesn’tallow you to access any local files from the command line. It also requires the use of simple bashcommands.1. Download and install PuTTY from the following link: www.putty.org2. Once installed, open PuTTY and for the Host Name, type in:coc-ice.pace.gatech.edu andfor the port, leave it as 22.3. Click Open and a window will pop up asking if you trust the host. Click Yes and it will then askyou for your username and password. (Note: When typing in your password, it will not show anycharacters typing)4. You’re now connected to PACE-ICE. You can edit files using vim by typing in: vim filename.ccOR nano vilename.cppFor a list of vim commands, use the following link:5. You’re able to edit, compile, run, and submit your code from this command line.MacOS Users:.Option 0 (Using the Terminal to SSH into PACE-ICE):10This option uses the built-in terminal in MacOS to ssh into PACE-ICE and use a command line text editorto edit your code.1. Open Terminal from the Launchpad or Spotlight Search.2. Once you’re in the terminal, ssh into PACE-ICE by typing:ssh **YourGTUsername**@ coc-ice.pace.gatech.edu where **YourGTUsername** isreplaced with your alphanumeric GT login. Ex: bkim3343. When it asks if you’re sure you want to connect, type in:yesand type in your password when prompted (Note: When typing in your password, it will not showany characters typing)4. You’re now connected to PACE-ICE. You can edit files using vim by typing in:vi filename.cc OR nano filename.cppFor a list of vim commands, use the following link: 5. You’re able to edit, compile, run, and submit your code from this command line.Linux Users:If you’re using Linux, follow Option 0 for MacOS users. 11Appendix B: Submitting AssignmentStep-By-Step Submitting a Tar.gzPLEASE NOTE: All the following instructions are run on PACE. If you are struggling with any of the steps,please come see the TAs during office hours. Better to start and test early than wait until the lastminute.Below is a step-by-step tutorial on how to create the .tgz file for Homework 4 for ECE 4122/6122. Pleaseknow, if you are in 4122 you do not need to submit anything for Problem 2. Additionally, if you do notuse a header file for a solution, you do not need to submit a header file. Please adjust these instructionsaccordingly. The tarball should contain a folder with your buzzid containing subfolders for each problemyou are assigned with the corresponding .cpp and .h files. Each problem will have a SERVER and CLIENTfolder with corresponding code.Please make sure that each problem is in its own subfolder with the naming conventions:_Hmk4Prob# (where # is either 1 or 2) in addition to the SERVER and CLIENTfolders:Create a subdirectory named buzzid in the current working directory by executing the followingcommand in the shell:$ mkdir buzzed(In this case my buzzid is tlagrow3)12Create a text file named manifest.Please make sure that the manifest file is a plain text file and not a rich text file. Microsoft word willgenerate a rich text file. The easiest method to create a plain text file is to use a command line editorsuch as vi, vim, or nano.(If you want a tutorial, these can be usefule: vi:The editor will open:13You will need to insert test into this file. Press the ‘i’ key on the keyboard to insert text:Populate the manifest file with the following:buzzid/_Hmk4Prob1/SERVER/*.cppbuzzid/_Hmk4Prob1/SERVER/*.hbuzzid/_Hmk4Prob1/CLIENT/*.cppbuzzid/_Hmk4Prob1/CLIENT/*.hbuzzid/_Hmk4Prob2/SERVER/*.cppbuzzid/_Hmk4Prob2/SERVER/*.hbuzzid/_Hmk4Prob2/CLIENT/*.cppbuzzid/_Hmk4Prob2/CLIENT/*.h(PLEASE NOTE: this is subject to change with depending on your class section. The wildcard (*) characterwill grab all the .cpp and .h files you generated for each problem.)14To save the file, hold the Shift key and press ‘ZZ’. This command will save the text and exit in the vimtext editor. To check that the file saved, you can use the command ‘$cat ’ to print out all thelines:Now you need to construct the correct file structure for the submission. This means that you need toput all the homework files into your buzzid folder. Execute the following lines in the shell:$ cp -a _* buzzid 15Many people have had issue with this step. You need to make sure the naming conventions areconsistent to avoid potential problems.It is now time to tarball your submission. If all the other steps have gone smoothly, execute thefollowing command:$ tar -zcvf buzzid-hmk4.tgz $(cat manifest)This command will generate a new tgz file with all of the specified files and folders in the manifest textdocument:You can now check the new tgz file just generated with the following command:$ tar -ztvf buzzid-hmk4.tgzIf your file has the same structure as above, you are all good to submit!转自:http://www.3daixie.com/contents/11/3444.html