Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TCP and UDP Application Programming For this assignment you will design and write your own application program using network sockets. You will implement two different

TCP and UDP Application Programming

For this assignment you will design and write your own application program using network sockets. You will implement two different versions of the application. One version will be based on TCP. The other will use UDP. You will write both the client and server portions of this application.

The application you are designing is a loan calculator that computes both monthly and total payments for a given loan amount, annual interest rate and loan period. The client interface will allow users to perform simple loan calculation. The client command should be called Cal.

For each valid invocation, the resulting monthly payment and total payment values should be printed for the user.

You must allow either the hostname or IP address of the server to be specified on the command line of the client. For instance, if the user wants to know the monthly and total payments for $150,000, 30 years, 4.69%, the command:

Cal myserver.mynet.com $150,000 30 4.69%

Would do the loan calculation and might produce the output:

$150,000 loan monthly payment is $777.06 total payment is $9324.72

This query would have been sent to the server myserver.mynet.com. Note that if you want to query a server application running on the same computer as the client you can always use the loopback address, 127.0.0.1.

The only output of the program should be the numeric output or an error message if it fails.

When you build this application you are to assume that the client program is not capable of doing the math itself. Instead, the client must request the result from the server.

Make sure that you do sufficient error handling such that a user can't crash your server. For instance, what will you do if a user provides invalid input? What about a negative value?

Your server application should listen for requests from Cal clients, process the requested operation(s) and return the result. After responding to a request the server should then listen for more requests. The server application should be designed so that it will never exit as a result of a client user action.

The formula for computing the monthly payment can be found in any mathematics book that covers geometric sequences. It is

Where L is the loan amount, R is the monthly interest rate which is yearly interest rate/12, and N is the number of payments (Please note 30 years will have 30*12 payments).

Notes:

You are implementing two complete, separate versions. A client and server using TCP and another client and server using UDP. Your final submission should include 4 separate executables. For simplicity in grading, let's call them TCPClient, TCPServer, UDPClient and UDPServer.

Your TCP and UDP versions will share much of the same code for user interaction, computation of greatest common divisor. However, your UDP implementation will have to deal with lost request messages. Make sure you consider what happens when a message is lost. You will need to handle this in some way such as using a timer to retransmit your request. A good way to test your client in this situation is to run it without the server. Does your client handle this gracefully?

You should select a port for your service. I recommend something between say 13000 and 14000. Make sure you kill your server when you are done working. See the netstat command for checking on busy network ports.

You will need to develop your own "protocol" for the communication between the client and the server. While you should use TCP and UDP to transfer messages back and forth, you must determine exactly what messages will be sent, what they mean and when they will be sent (syntax, semantics and timing). Be sure to document your protocol completely in the program readme file.

Your design should be flexible without arbitrary constraints. For instance, your protocol should not limit the number of requests made to the server.

Please comment your programs.

You must test your program and convince me it works! Provide me with a sample output that shows your function working. If you fail to demonstrate a capability of the program I will assume that feature does not work.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions