5 Pages

PA1

Course: CNT 4007, Spring 2012
School: University of Florida
Rating:
 
 
 
 
 

Word Count: 1828

Document Preview

Computer CNT4007C Network Fundamentals, Spring 2012 Programming Assignment 1 --- Yi Wang: yiwan@cise.ufl.edu Date assigned: Friday, Feb 10, 2012 Date due: Friday, Feb 24, 2012 (3:00 pm EST) NO LATE submission will be accepted for grading! How to submit: Email to yi.wang.uf@gmail.com with your project attached. Questions: Come to office hour or contact TA (Yi Wang: yiwan@cise.ufl.edu). Please dont send your...

Register Now

Unformatted Document Excerpt

Coursehero >> Florida >> University of Florida >> CNT 4007

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Computer CNT4007C Network Fundamentals, Spring 2012 Programming Assignment 1 --- Yi Wang: yiwan@cise.ufl.edu Date assigned: Friday, Feb 10, 2012 Date due: Friday, Feb 24, 2012 (3:00 pm EST) NO LATE submission will be accepted for grading! How to submit: Email to yi.wang.uf@gmail.com with your project attached. Questions: Come to office hour or contact TA (Yi Wang: yiwan@cise.ufl.edu). Please dont send your questions to the submission email address, because I will not check the submissions until deadline. Introduction In this programming assignment, you will develop a simple client/server implementation for socket communication. It is intended for the students to experience socket programming with proper exception handlings. The implementation will have a server program and a client program running on two CISE machines. They communicate with each other using socket communication on a TCP/IP protocol suite. The process is like this: After initialization, the server process listens and responds to the clients requests. A client will try to connect to the server and send out a message containing a command and inputs. The command will be arithmetic calculation commands of adding, subtracting and multiplying and is followed by inputs of one or more numbers (e.g. add 12 7). Upon receiving the command and inputs, the server will respond to the client with the calculating result (e.g. 19). More details will be explained later. Prerequisite Socket A socket is one endpoint of a two-way communication link between two programs running on the network. It is bound to a port number so that the TCP layer can identify the application that data is destined to. The socket API allows application programs to communicate remotely over the Internet. A socket is analogous to a file (an example of transparency) and is used very much like a file. Its send/receive primitives correspond to the write/read operations in a file system. In this project, we will use sockets over TCP/IP (not UDP datagram) in order ensure the reliability of the communication. More about socket communication can be found from the following links (checking out the books in library and doing some internet search are also encouraged): [C] http://beej.us/guide/bgnet/ http://www.linuxhowtos.org/C_C++/socket.htm [Java] http://www.oracle.com/technetwork/java/socket-140484.html http://en.wikipedia.org/wiki/Berkeley_sockets Specification Server Program A server program is an always-running program that accepts the clients requests. This program starts earlier than all clients and waits for the in-coming connection. After accepting an incoming request from a client, it responds a message Hello! to the client. Then whenever it receives an operation command from the client, it prints out the command on screen and then returns with the calculation result (e.g. for the message add 4 5 from client, the server will send a message 9 to the client). Maximum number of inputs following the operator should be four, and the server returns an error code for exceeding or insufficient number of inputs. Note that the returning message to the client should only include a number (calculation result or error code. If the server receives a command bye from a client, it closes the corresponding socket, but can still communicating with other clients. However, if the server receives command terminate from any client, it closes all the sockets and exit. And all clients exit too. Client Program Clients are started on remote machines after a server is running. After connecting to athe server and receiving Hello! message, client program prints it out and let the user input a command line. Then it will send the command to the server (clients do not handle invalid input) and receive a response. After printing out the result or error message (to be specified later), it will let the user input again. The following are the operation commands used in this project: add number1 number2 subtract number1 number2 multiply number1 number2 Please note that there should be 2 to 4 input parameters after each operator. Exception Handling Your server program should be able to handle unexpected inputs. For example, consider a command add d 7. This operation cannot be done; however, your program may still produce a result based on ASCII code of the character d. In this program assignment, the server needs to send an error code instead of the wrong result. Error codes are negative numbers. To avoid confusion, TA will only test your program with non-negative natural numbers, and the result should also be non-negative (e.g. we will not test subtract 3 5). Therefore, negative numbers are reserved for error code. Your server program (NOT your client!) needs to generate an error code for incorrect command (e.g. add 4.2 or 3 2). The following is the code list: -1: incorrect operation command. -2: number of inputs is less than two. -3: number of inputs is more than four. -4: one or more of the inputs contain(s) non-number(s). -5: exit. When there is more than one error in the message, the error code on the top of the error codes list precedes other error codes. (e.g. 5 4 will have two errors: incorrect operation command & number of inputs is less than two. As the error code -1 precedes the other error codes, the server should return -1). The client program should print out the corresponding error message after receiving an error code. Termination Graceful termination is required in this project. If there are runaway processes, points will be deducted. The detailed process is: when user types the command bye and the client send it to the server, server will reply error with code -5. Upon receiving -5, the client process will print out exit on screen and exit. But the server program will keep accepting other connection requests. If user types terminate command and sends to server, server will also reply -5 but both client and server will exit after that. After termination, there should not be any dangling thread, i.e. no zombie thread showing in the operating system. Note on Run-away Processes for the Graceful Termination: Your program should terminate gracefully. While testing your programs, run-away processes might exist. However, these run-away processes should be killed. Please check frequently if there are any remaining processes after termination. CISE department has a policy regarding this issue and your access to the department machines might be restricted if you do not clean these processes properly. Some useful Linux/Unix commands: To check your running processes: ps -u <your-username> To kill a process: kill -9 pid To kill all Java processes: killall java To check processes on remote hosts: ssh <host-name> ps -u <your-username> To clean Java: ssh <host-name> killall java Execution format Server: [C] ./server [port_number] [Java] java server [port_number] Client: [C] ./client [serverURL] [port_number] [Java] java client [serverURL] [port_number] Examples of compilation and execution (do not use the same port number as shown in here) [C] S> gcc -o server server.c -lnsl (-lsocket -lpthread) C> gcc -o client client.c -lnsl (-lsocket) S> ./server 21234 C> ./client sand.cise.ufl.edu 21234 [Java] sand> javac *.java rain> javac *.java sand> java server 21234 rain> java client sand.cise.ufl.edu 21234 Program should follow the sample output format. Example: S> ./server 21234 C> ./client sand.cise.ufl.edu 21234 S> get connection from (IP) C> receive: Hello! (user input: add 5 2) S> get: add 5 2, return: 7 C> receive: 7 (user input: multiply 3) S> get: multiply 3, return -2 C> receive: number of inputs is less than two. (user input: bye) S> get: bye, return -5 C> receive: exit. Your screen should show results like this, except the user input part. Port number You have to be careful when using a port number, i.e., some port numbers are already reserved for special purposes, e.g., 20:FTP, 23:Telnet, 80:HTTP, etc. We suggest you test your program with your last 4-digit of UFID as your port number in order to avoid conflicts with other students. Keep in mind that the port number should be less than 216 (=65,536). Getting the most points 1. The source codes need to be tested on CISE Linux/Unix machines, because we are going to grade on Linux system. Please state your testing machines and results in your report. 2. Please try to complete the socket communication part first. After testing that, your program will be able to correctly send a message to the server and receive a response, and then you can move on to the next step. 3. Try to finish the simplest operations first (e.g. add 3 4). Exception handling can follow next. 4. Have backups whenever your program can do more. That way, you can avoid the situation where your program used to work but not anymore (e.g. after trying to implement exception handling). If your program cannot be compiled, your will receive zero point. Therefore, it is very important for you to keep the working versions for submission. If your program does not handle exceptions properly, points will be deducted but this is much better than receiving no point. Reminder 1. For your programming conveniences, your server program does not need to be implemented by Thread functionalities (multi-threading) in this assignment. In other words, your server program doesnt need to handle concurrent requests by several clients, i.e., we will test your server program by sequential client requests one at a time. However, you should know that a server program is originally supposed to handle simultaneous requests, which might be asked in later assignments. 2. All the coding must be done individually. Using blocks of code from other people or any other resources is strictly prohibited and is regarded as a violating of UF honor code! Please refer to the UF honor code if you are unfamiliar with it (http://itl.chem.ufl.edu/honor.html). Report Submitted report file should be named report.pdf or .txt and include the following: Your personal information: Full name, UF ID, and Email How to compile and run your code under which environment. - You will receive zero points if the submitted program cannot be compiled. Description of your code structure. Show some of the execution results. - Discuss the results you got with your program. - Discuss any abnormal results. Explain about the bugs, missing items and limitations of the program if there is any. - Honesty is valued here. Any additional comments. Submission Guidelines: 1. The name of a source code for the server program should be named server.c (server.java for java language), and the client program client.c or client.java. 2. Only submit your C/Java source code files and report, do not include .obj/.class or executable files in your submission. 3. Include makefile if you have one. (Not required) 4. Include the report in .pdf or .txt format. Name it report.pdf/txt. 5. Zip all your files into a packet: Firstname_Lastname_ID.zip 6. Email the zip packet as attachment to: yi.wang.uf@gmail.com before deadline. Grading Criteria: Correct Implementation / Outputs 60% Graceful Termination / Exception handling 20% Report 15% Readability / Comments / Code structure 5% Total: 100%
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

University of Florida - CNT - 4007
CNT4007C Computer Network Fundamentals, Spring 2012Programming Assignment 2- Yi Wang: yiwan@cise.ufl.eduDate assigned: Friday, March 16, 2012Date due:Monday, March 26, 2012 (3:00 pm EST)NO LATE submission will be accepted for grading!How to submit:
University of Florida - CNT - 4007
CNT4007C Computer Network Fundamentals, Spring 2012Programming Assignment 3- Yi Wang: yiwan@cise.ufl.eduDate assigned: Wed. April 11, 2012Date due:Wed. April 25, 2012 (3:00 pm EST)NO LATE submission will be accepted for grading!How to submit: Email
University of Florida - CNT - 4007
CNT 4007 Computer Networks- Chapter 4 : Network LayerJonathanC.L.Liu,Ph.D.DepartmentofComputer,InformationScienceandEngineering(CISE),UniversityofFloridaIP datagram formatIPprotocolversionnumberheaderlength(bytes)typeofdatamaxnumberremainingh
University of Florida - CNT - 4007
CNT 4007 Computer Network Fundamentals, Spring 2012Sample Questions for Midterm Examgiven byJonathan C.L. Liu This sample set provides you an opportunity to practice the midterm exam. There will be no key solutions for these sample questions. There
University of Florida - MAC - 2313
CHAPTER 11Vectors and the Space GeometryOur space may be viewed as a collection of points. Every geometrical gure, such as a sphere, plane, or line, is a special subset of points inspace. The main purpose of an algebraic description of various objects
University of Florida - MAC - 2313
Concepts in Calculus IIIBeta VersionUNIVERSITY PRESS OF FLORIDAFlorida A&amp;M University, TallahasseeFlorida Atlantic University, Boca RatonFlorida Gulf Coast University, Ft. MyersFlorida International University, MiamiFlorida State University, Tallah
University of Florida - MAC - 2313
MAC 2313 HW Problems Part 2Section 91A. p. 173 (1)-(9)B. Assume that z = f (x, y ) is implicitly dened by the function:arctan(xyz ) + x2 + y 2 = xz + yzUse the Implicit Function Theorem to ndzxandz.yC. Supposew = x2 + y 2 , x = 2st, y = s2 t2
University of Florida - MAC - 2313
MAC 2313 HW Problems Part 2 AnswersSection 91A. p.173 (1) dz = dt11+x2 +2y 26xt2 +2yt(2) z = ex (y cos(xy ) sin(xy ) t + xex cos(xy ) s2s+t2 ;sz= ex (y cos(xy ) sin(xy ) s + xex cos(xy ) s2t+t2tzzz(4) u = 23, v = 32, and w = 39(5) Note:
University of Florida - MAC - 2313
MAC 2313 HW Problems Part 3Section 102A. p. 268 (1), (4), (6), (7) oddSection 103A. p. 280 (1) i, iv, v, viii, (2), (4) iSection 105A. p. 299 (1)Section 104A. p. 291 (1) (ii, iii), (2), (3) (i, iii, iv), (4), (5), (6) odd, (7), (8), (9)1
University of Florida - MAC - 2313
MAC 2313 HW Problems Answers Part 3Section 102A. (1) (i) 11, (ii) e2r , (iii) (u2 + v 2 )(4) (i) D = cfw_(x, y ) | 0 x 1, 0 y 1 x2 , (ii) D = cfw_(x, y ) | 0 x y, 0 y 1,(iii) D = cfw_(x, y ) | 1 x 1, 1 y 1(6) (i) 192, (ii) / 3, (iv) 7 (e1 e1/2 )3(7
University of Florida - MAC - 2313
MAC 2313 Section 3122SyllabusSpring 2012Instructor: Jo Ann LeeOffice: LIT 417Phone: (352) 392-0281 ext 307Email: joann5@ufl.eduWebsite: www.math.ufl.edu/~joann5Class time: Class meets MWRF 6th period (12:50-1:40 pm) in LIT 223Office Hours: (tenta
University of Florida - EMA - 4760
Biomechanics of the Normaland Arthritic Knee ImplantDesignDesignProfessorGaryJ.Miller,Ph.D.UniversityofFloridaandExactech,Inc.Gainesville,Fl.USAGoal of the Presentation: Briefly describe the normal kneesbiomechanical functions as related tomotio
University of Florida - COP - 5725
Database Management Systems (COP 5725)Spring 2012Instructor:Dr. Markus SchneiderTA:Nam NguyenExam 1 SolutionsName:UFID:Email Address:Pledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthorized a
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)InstructorDr. Markus SchneiderTANam NguyenExam 2SolutionsName:UFID:Email Address:Pledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthorized a
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor: Dr. Markus SchneiderTA: Nam NguyenHomework 2 SolutionsNameUFIDEmail AddressPledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthorize
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor: Dr. Markus SchneiderTA: Nam NguyenHomework 3NameUF IdEmail AddressPledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthorized aid in
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor: Dr. Markus SchneiderTA: Nam NguyenHomework 3 SolutionsNameUF IdEmail AddressPledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthoriz
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor: Dr. Markus SchneiderTA: Nam NguyenHomework 4NameUF IdEmail AddressPledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthorized aid in
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor: Dr. Markus SchneiderTA: Nam NguyenHomework 4 SolutionsNameUF IdEmail AddressPledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthoriz
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor:Dr. Markus SchneiderTA:Nam NguyenHomework 5Name:UFID:Email Address:Pledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthorized aid i
University of Florida - COP - 5725
What you should have learned after this lecture . what aggregation functions are grouping in SQLdistinction between upper and lower caseString patterns in SQL are expressed with the aid of the like operator.example: Find all students with names Meier
University of Florida - COP - 5725
What you should have learned after this lecture . sorting in SQL what nested queries are how different kinds of joins can be explicitly expressedexamples (relation lectures extended by the attribute hpw (hours per week) Determine the number of hours
University of Florida - COP - 5725
What you should have learned after this lecture . how to determine whether a given FD is contained in the closure of a set of FDs what a canonical cover of a set of functional dependencies is how a canonical cover is computedContainment of a FD in a c
University of Florida - COP - 5725
What you should have learned after this lecture . what normalization means and how it is done what the benefits and the drawbacks of the normalization process are what the normal forms aredependency preservation goal: All FDs that hold for schema R a
University of Florida - COP - 5725
What you should have learned after this lecture .what the normal forms are The following anomalies can occur:+ insertion anomaly: What do we do with students who do not attend a lecture?+ update anomaly: If a student reaches the next semester, we must
University of Florida - COP - 5725
What you should have learned after this lecture .what the normal forms arefundamentals of database application programmingstep 1: computation of a canonical cover (precomputed) FD 1:cfw_pers-id cfw_name, rank, room, city, street, state FD 2:cfw_roo
University of Florida - COP - 5725
What you should have learned after this lecture .fundamentals of database application programmingPL/SQLexample:/ Creation of a new object of class StatementStatement stmt = con.createStatement();/ Translation of the query and creation of a new objec
University of Florida - COP - 5725
What you should have learned after this lecture . PL/SQL what data integrity means how integrity constraints are expressed in SQL PL/SQL also supports the definition of recordstype person_type is record (name varchar(50), salary int);variable declar
University of Florida - COP - 5725
What you should have learned after this lecture . How integrity constraints are expressed in QBE Why (purely) relational database systems are not sufficient any more What object-relational database systems (ORDBS) are What the benefits of ORDBS are9.
University of Florida - COP - 5725
What you should have learned after this lecture . further concepts of object-relational database systems (ORDBS) what query processing isinsert into company values(XYZ, array[Mall Avenue, Sales Street, Sellers Drive]);Alternatively:insert into compa
University of Florida - COP - 5725
What you should have learned after this lecture .how algebraic optimization is done10.2 Phases of translation/optimizationgoal: syntactical and semantical analysis of the querygiven: query in a relational query language, e.g. SQLstep 1: translation o
University of Florida - COP - 5725
What you should have learned after this lecture .how algebraic optimization is donerule 8: permutation of a selection with a join or a cross product, if it only usesattributes of one of the two operand relations. cfw_ , : F(R1 R2) = F(R1) R2(attr(F)
University of Florida - COP - 5725
10.4 Physical Optimization(We here deal only with some few aspects. This theme is especially a topic of a courseImplementation of Database Systems.)Introduction The physical algebra operators realize/implement the logical operators. A logicaloperator
University of Florida - COP - 3530
cop3530sp12Parameter passingcall by value- appropriate for small objects that should not be altered by the functioncall by constant reference- appropriate for large objects that should not bealtered by the functioncall by reference -appropriate for a
University of Florida - COP - 3530
COP 3530Data Structures &amp; AlgorithmsDiscussion Session 3OutlineInput-output streams in C+Floating point precisionFile manipulationPointers in CVector class in C+Strings in C and C+About meEyup Serdar Ayazayaz@cise.ufl.eduTA Office: E309This
University of Florida - COP - 3530
Copyright 2003 Pearson Education, Inc.Slide 1Chapter 11Strings and VectorsCreated by David Mann, North Idaho CollegeCopyright 2003 Pearson Education, Inc.Slide 2OverviewAn Array Type for Strings (11.1)The Standard string class (11.2)Vectors(11.3
University of Florida - EEL - 4712
University of Florida - EEL - 4712
University of Florida - EEL - 4712
EEL 4712Midterm 2 Spring 2011VERSION 1Name:UFID:Sign your name here if you would like for your test to be returned in class:_IMPORTANT: Please be neat and write (or draw) carefully. If we cannot read it with areasonable effort, it is assumed wron
University of Florida - EEL - 4712
EEL4712Name: Midterm1Spring2012VERSION1UFID: IMPORTANT: Please be neat and write (or draw) carefully. If we cannot read it with areasonable effort, it is assumed wrong. As always, the best answer gets the most points.COVERSHEET:Problem#: Points
University of Florida - EEL - 4712
EEL4712Name: Midterm2Spring2012VERSION1UFID: Signyournamehereifyouwouldlikeforyourtesttobereturnedinclass:_IMPORTANT: Please be neat and write (or draw) carefully. If we cannot read it with areasonable effort, it is assumed wrong. As always, the
University of Florida - EEL - 4712
University of Florida - EEL - 3396
Book sections to be covered in EEL 3396 Spring 2012 during (tentatively):Week 1: Ch 1 superficially, 2.3W2: 2.5 ,3.1.allW3: 3.2. all except 3.2.5W4: 3.3 allW5: 3.4 all, 3.5W6: 4.1, 4.2, 4.3W7: 4.4, except 4.4.5W8: 5.1 superficially, 5.2, 5.3W9: 5
University of Florida - EEL - 3396
Home work assignments in preparation for the weekly Wednesday 10 minute quizzes.Note that you can only work the quiz problem successfully if you have studied theseassignments. Quizzes will be closed book, no notes. Physical constants will be given.The
University of Florida - EEL - 3396
Home work assignments in preparation for the weekly Wednesday 10 minute quizzes.Note that you can only work the quiz problem successfully if you have studied theseassignments. Quizzes will be closed book, no notes. Physical constants will be given.Brin
University of Florida - EEL - 3396
Home work assignments in preparation for the weekly Wednesday 10 minute quizzes.Note that you can only work the quiz problem successfully if you have studied theseassignments. Quizzes will be closed book, no notes. Physical constants will be given.Brin
University of Florida - EEL - 3396
Course Number and TitleEEE 3396- Solid State Electron Devices1. Catalog Description (3 hrs) Introduction to the principles of semiconductorelectron device operation.2. Pre-requisites and Co-requisites EEL 3111 - Circuits I3. Course Objectives: To pre
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
Purdue - AAE - 340
Purdue - AAE - 340
C1Moment / Angular MomentumOperate on Law of Motion to obtain relationship between moment andrate of change of angular momentuma pivotal equation inrotational dynamicsDerivationiid r opvdtpiid iv pAdtLaw of Motion:F m iApOperate onthe
Purdue - AAE - 340
D1Integrals of the MotionI. Work and EnergyOperate on Law of MotioniFv m ApiipiipdvmdtiiFvpd1 imvdt 2vpivppivpkinetic energy TiiFdTvTdtpAnother form of Law ofMotionyields one scalardifferential equationIntegr
Purdue - AAE - 340
M1Rigid Bodies Angular MomentumlLaws of Motion:F M i Acmar Momentumid iH qM M qcm i AqdtqDefinitionsnM q j Fjqj 1nidqjH mjdtj 1qiqjDifficulty with applying this to systems of particles: to calculate Hrequires and d dt for every