Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

-Replicate and Enhance this echo client/Server program from socket import * serv

ID: 3701024 • Letter: #

Question

-Replicate and Enhance this echo client/Server program

from socket import *

serverName = ’servername’

serverPort = 12000

clientSocket = socket(AF_INET, SOCK_STREAM)

clientSocket.connect((serverName,serverPort))

sentence = raw_input(‘Input lowercase sentence:’)

clientSocket.send(sentence)

modifiedSentence = clientSocket.recv(1024)

print ‘From Server:’, modifiedSentence

clientSocket.close()

Choose either TCP or UDP version of the echo server/client, modify it to accomplish the following function: Server side program should accept a parameter as the port number that it will listen on for incoming request, if no parameter is provided, then 9999 is used by default. User(e.g. me) runs the client program to connect to server. Client program should accept two parameters that allow user to specify the server address and port number. The client program reads a sentence typed in by user via keyboard, and user can select a command, then it sends both the command and the sentence to the server. Upon receipt of the sentence and command, server converts all the letters in the sentence into uppercase letters or lower letters or other format based on the received command, and sends the result back to the client. Client program displays the replied sentence on the screen. Your server should support at least three commands: all uppercase, all lowercase, and another commands that you designed(something like initial caps, reverse each word, reverse the entire sentence, etc.). Make sure test your program before submission, you'll receive 0 if your programs contains syntax errors! Include a README document for instructions on how to run your program.

-provide a document describing your protocol, i.e., underlying transport layer service, port numbers, the order and format of message sent and received by client/server, action associated with each message, etc. The document should provide enough information for others to implement client and server program to interact with yours.

How TCP or UDP would affect your application? Why you pick TCP over UDP?(Or vice versa) Is your protocol stateful or stateless? How does the other type of design would affect your application? (Hint: this has nothing to do with whether you use TCP or UDP). Is your server program able to communicate with multiple clients at the same time?

Explanation / Answer

To send information to an application utilizing TCP, you initially need to set up an association. Until the point that the association is built up, bundles just get to the OS layer, not the application. Building up an association requires that you get parcels back to the starting end. In the event that you needed to produce an IP address not without anyone else arrange and build up a TCP association, you'd should have the capacity to capture the bundles the opposite side conveyed. (you should be "in the middle of" the endpoint, and where the parcels to the produced IP address would typically go, or do some other cunning steering traps.)

UDP has no association, so you can fashion a bundle with a subjective IP address and it ought to get to the application. Despite everything you won't get parcels back unless you're in the right "place" obviously. Regardless of whether this issues or not relies upon the security you put in the application. If you somehow happened to believe certain IP tends to more than others inside the application, this might be an issue.

So in that sense, TCP is more "secure" than UDP. Contingent upon the application, this could possibly be pertinent to security. All by itself it's not a justifiable reason motivation to supplant UDP with TCP since there's different tradeoffs required between the two conventions.

Is TCP more secure than UDP?

Truly, yet we must be clear about what we are discussing when we are discussing "security" and not sum up this announcement to upper layer conventions.

Presently, security is regularly related to the CIA group of three:

Classification.

Honesty.

Accessibility.

The adaptation 4 of the IP convention, which is as yet the most generally utilized now, is an exceptionally old monster which was produced amid the 70's and 80's.

Around then, secrecy was not so much a subject and what was truly focused on was to accomplish uprightness and accessibility (the Arpanet organize, the progenitor of the Internet which brought forth the IP convention, was intended to guarantee a congruity of administration even in case of an atomic war, not to secure in-travel information).

In this optic, two transport conventions were created over the IP layer: TCP and UDP.

TCP was the one intended to guarantee both the respectability and accessibility properties. It incorporates what was at that circumstances propelled procedures, for example, a three-way handshake, parameters arrangement, different association state taking care of, straightforward parcel reordering, affirmation windows and retry components. This conveys great sureties to the sender that the information it sent has been gotten in an entire an uncorrupted frame (ie. no missing, changed or unordered parts).

Remind however that what this convention was focusing on was a specialized fiasco, not a vindictive altering of the information in travel. Such issue was totally out-of-scope around then.

UDP unexpectedly was intended to be a quick convention. It has nothing unless there are other options said include, and hence none of their overhead as well. Specifically, when the sender sends a few information utilizing UDP, the information got might be deficient, unordered or not gotten by any means: the UDP convention without anyone else's input does not give any system to forestall or distinguish this neither on the sender or collector sides.

Along these lines, when concentrating on the information trustworthiness and accessibility properties of security, TCP is in fact more secure than UDP.

Is an application convention depending on TCP more secure than one depending on UDP?

Surely not.

This lone implies that individuals building up an application convention depending on UDP will have more work since they may need to actualize in their application convention workarounds for the highlights missing in the UDP convention. They should consider that information sent may not be essentially gotten, that information got may not be organized appropriately, and so on. These are altogether notable issues.

OpenVPN for example, while it bolsters TCP for the most part for similarity with prohibitive firewalls, keeps running of course and runs best finished UDP. Changing it to TCP is conceivable yet won't expand its security in any capacity as the distinction between the two transport layer convention UDP and TCP is completely taken care of by OpenVPN itself. Changing it to TCP will just add the TCP overhead to the OpenVPN convention, in this way lessening its execution.

Is TCP superior to UDP?

No, this is altogether an application convention plan decision.

UDP is a more crude convention. At the point when utilized accurately and precisely it might accomplish preferable exhibitions over TCP at the cost of a more troublesome advancement and support of the application convention.

At the point when the application isn't time touchy, TCP forces itself as the characteristic decision as there is no compelling reason to reexamine the wheel.

At the point when the application is time delicate, an exchange must happen on which to pick realizing that each will accompany its downside: a potential execution punishment with TCP against a surely more intricate application with UDP.

Most conventions are not time touchy and in this manner TCP is most broadly utilized convention. To be sure, when you stack a page or get an email, there is no distinction in the event that you get it 10 milliseconds at some point or another.

Two established cases of conventions utilizing UDP, notwithstanding the OpenVPN already refered to, are media spilling and DNS.

With media spilling, you don't generally mind on the off chance that one video outline or a couple of milliseconds of video or sound is missing, as long as the video or sound is playing easily and synchronously. In such case, you would prefer not to initiate tedious delays in light of the fact that TCP recognized a missing parcel and asked the sender to resend the substance of the last affirmation window.

With DNS, asks for and answers are normally short and you need the name determination procedure to be as quick as could be expected under the circumstances (take note of that more drawn out and less time-touchy answers, for example, DNS zone exchanges typically still happen on TCP). It is speedier to resend the name determination demand to the DNS server on the not very many circumstances the demand or its answer gets lost than preparing an undeniable three-route handshake for each demand.

Shouldn't something be said about secrecy and vindictive sniffing/altering (and IPv6)?

All we thought about up to this point was, in the soul of this old IPv4, the harmony between transmission speed and information uprightness + accessibility. Presently, on the off chance that we need to include classification best of this, we can do this however it should be done at the application layer as, as expressed previously, IPv4 isn't worried by privacy issues.

A cutting edge, undeniable execution of security can be actualized at the application layer and depend on either TCP or UDP (or both) conventions with no effect on the application convention security itself (see the case of OpenVPN above).

Be that as it may, as expressed at the outset, IPv4 truly originates from an another processing age. It got a successor by the name if IPv6, which locally bolsters IPSec at the IP layer, accordingly giving more present day security benefits underneath transport conventions, for example, UDP and TCP.

This permits to assign in-travel information encryption from the application to the system layer, and permits both UDP and TCP to give the very same security certifications. Be that as it may, in many situations UDP execution pick up will be offset IPSec overhead, so I don't know there would be any favorable position in utilizing UDP rather TCP as long as IPv6 IPSec is being utilized.

Here is the code for the given client and server problem.

Source code

Client.java


import java.io.*;

import java.net.*;

class Client {

   public static void main(String argv[]) throws Exception{

       String orgSentece; //original sentence

       String modSentence; //modified sentence

       BufferedReader from_User = new BufferedReader(

       new InputStreamReader(System.in));

       Socket clientSocket = new Socket("localhost", 4444);

       DataOutputStream to_Server = new DataOutputStream(clientSocket.getOutputStream());

       BufferedReader from_Server = new BufferedReader(

       new InputStreamReader(clientSocket.getInputStream()));

       System.out.print("Client> ");

       orgSentence = from_User.readLine();

       to_Server.writeBytes(orgSentence + ' ');

       modSentence = from_Server.readLine();

       System.out.println("Server>" + modSentence);

       clientSocket.close();

   }
}

Server.java

import java.io.*;

import java.net.*;

class Server {

   public static void main(String argv[]) throws Exception {

       String clientOrgSentence;//client original sentence

       String upperCaseModSentence;//upper case modified sentence

       ServerSocket welcomeConnection = new ServerSocket(4444);

       while (true) {

           System.out.println("Waiting for clients to connect....");

           Socket connection = welcomeConnection.accept();

           System.out.println("Client Connected.");

           BufferedReader from_Client = new BufferedReader(

               new InputStreamReader(connection.getInputStream()));

                   DataOutputStream to_Client = new DataOutputStream(

           connection.getOutputStream());

           clientOrgSentence = from_Client.readLine();

           System.out.println("Client sent: " + clientOrgSentence);

           upperCaseModSentence = clientOrgSentence.toUpperCase() + ' ';

           to_Client.writeBytes(upperCaseModSentence);

       }

   }

}