How to identify a tcp socket

Assignment Help JAVA Programming
Reference no: EM131224507

Part 1. Text reading

Chapter 3, Chapter 4

Part 2. Textbook questions Chapter 3.

Describe why an application developer might choose to run over TCP rather than UDP.

Suppose host A is sending host B a large file over a TCP connection. If the acknowledge number for a segment of this connection is y, then the acknowledge number for the subsequent segment will necessarily be y+ 1. Is this true or false? Why?

Suppose 5 TCP connections are present over some bottleneck link of rate X bps. All connections have a huge file to send (in the same direction over the bottleneck link). The transmissions of the files start at the same time. What is the transmission rate that TCP would like to give to each of the connections?

How to identify a UDP socket? How to identify a TCP socket? Are these data fields same? Why?

UDP and TCP use 1's complement for their checksums. Suppose you have the following three 8-bit words: 11010101, 01111000, 10001010. What is the 1's complement of the sum of these words? Show all work. Why UDP takes the 1's complement of the sum, that is, why not just use the sum?

Suppose Client A initiates a SMTP session with server S. Provide possible source and destination port numbers for:

a. The segment sent from S to A.
b. The segment sent from A to S.

Compare two pipelining protocols shown in the textbook - go-back-N and selective repeat.

In our textbook, protocol rdt 3.0 shows a data transfer protocols that uses only acknowledges. As an alternative, consider a reliable data transfer protocol that uses negative acknowledgements. Suppose the sender sends data only infrequently. Will a NAK-only protocol be preferable to protocol that uses ACKs? Why? Suppose the sender has a lot of data to send and the end-to-end connection experiences few losses. In the second case, would a NAK-only protocol be preferable to a protocol that uses ACKs? Why?

Let us assume that the roundtrip delay between sender and receiver is constant and known to the sender. Would a timer still be necessary in protocol rdt 3.0, assuming that packets can be lost? Please explain.

Briefly discuss the basic mechanisms adopted by TCP congestion control.

Chapter 4

Describe two major network-layer functions in a datagram network.

Describe how packet loss can occur at input and outputs of a router. Is it possible to eliminate packet loss at these ports? If so, how? If not, please explain.

Suppose an application generates chunks of 960 bytes of data every 20 msec, and each chunk gets encapsulated in a TCP segment and then an IP datagram. What percentage of each datagram will be overhead, and what percentage will be application data?

Consider a datagram network using 8-bit host addresses. Suppose a router uses longest prefix matching and has the following forwarding table:

Prefix  Match  Interface 
00 0
001 1
otherwise 2

For each of the 3 interfaces, give the associated range of destination host addresses and the number of addresses in the range.

Consider the following network. With the indicated link costs, use Dijkstra's shortest-path algorithm to compute the shortest path from x to all network nodes. Show how the algorithm works by computing a table similar to the textbook example. In cases when several candidate nodes have the same minimal costs, choose a node according to non-decreasing alphabetical order.

2308_Figure4.jpg

Consider the count-to-infinity problem in the distance vector routing. Will the problem occur if we decrease the cost of a link? Why?

IPv6 adopts a fixed-length 40 byte IP header. What is the major advantage of this approach compared to that in IPv4?

Suppose an ISP owns the block of addresses of the form 200.200.128.0/19. Suppose it wants to create four subnets from this block, with each block having the same number of IP addresses. What are the prefixes (of form a.b.c.d/x) for the four subnets?

Why are different inter-AS and intra-AS protocols used in the Internet?

Part 3. Practical assignment

For this assignment, you can choose to use either Java or Python. Please submit the following items in a ZIP file.
1) Source code;
2) Instructions on how to install and run your program;
3) A brief design document explaining your solution.

Note: I shall not provide remedial help concerning coding problems that you might have. Students are responsible for the setup of their own coding environment. Each student is also expected to debug their code. In addition most SMTP servers (e.g., NSU's email server at nsusmtp.nova.edu) require authentication before sending messages. You can either hard-code the email account's authentication information into the source code, or create a dummy or a free SMTP server (shown as follows) to test your program.

https://www.softstack.com/freesmtp.html https://www.hmailserver.com/
https://sourceforge.net/directory/os:windows/freshness:recently-updated/?q=smtp%20server (There are a couple of options. It seems that SMTPMail is a viable option if you feel comfortable with common line mode.)

Sending Email with Java

Java provides an API for interacting with the Internet mail system, which is called JavaMail. However, we will not be using this API, because it hides the details of SMTP and socket programming. Instead, you should write a simple Java program that establishes a TCP connection with a mail server through the socket interface, and sends an email message.

You can place all of your code into the main method of a class called EmailAgent. Run your program with the following simple command:

java EmailAgent

This means you will include in your code the details of the particular email message you are trying to send.

Here is a skeleton of the code you'll need to write:

import java.io.*; import java.net.*;

public class EmailAgent
{
public static void main(String[] args) throws Exception
{
// Establish a TCP connection with the mail server.

// Create a BufferedReader to read a line at a time. InputStream is = socket.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr);

// Read greeting from the server. String response = br.readLine(); System.out.println(response);
if (!response.startsWith("220")) {
throw new Exception("220 reply not received from server.");
}

// Get a reference to the socket's output stream. OutputStream os = socket.getOutputStream();

// Send HELO command and get server response. String command = "HELO alice\r\n"; System.out.print(command); os.write(command.getBytes("US-ASCII")); response = br.readLine(); System.out.println(response);
if (!response.startsWith("250")) {
throw new Exception("250 reply not received from server.");
}

// Send MAIL FROM command.


// Send RCPT TO command.


// Send DATA command.


// Send message data.

// End with line with a single period.


// Send QUIT command.

}
}

For this assignment, you are required to use command-line-based Java and should not rely on any features provided by IDE such as NetBeans, Eclipse, etc. In your submission please send me a stand-alone document named "EmailAgent.java". No executables should be submitted. No graphical interface should be used by your program.

Sending Email with Python

You can implement your email client using Python. You should write a simple Python program that follow a step-by-step process to establish a TCP connection with a mail server through sockets, and send an email message. The other requirements are very similar to those by choosing Java. I am attaching a skeleton of the Python code below. Again Python 2 is recommended for this assignment.

from socket import *

# Message to send
msg = '\r\nHello World' endmsg = '\r\n.\r\n'

# Choose a mail server and call it mailserver mailserver = 'smtp.nova.edu'

# Create socket called clientSocket and establish a TCP connection with mailserver
clientSocket = socket(AF_INET, SOCK_STREAM)

# Port number may change according to the mail server clientSocket.connect((mailserver, 587))
recv = clientSocket.recv(1024) print recv
if recv[:3] != '220':
print '220 reply not received from server.'

# Send HELO command and print server response. heloCommand = 'HELO gmail.com\r\n' clientSocket.send(heloCommand)
recv1 = clientSocket.recv(1024) print recv1
if recv1[:3] != '250':
print '250 reply not received from server.'

# Send MAIL FROM command and print server response.

# Send RCPT TO command and print server response.

# Send DATA command and print server response.

# Send message data.

# Message ends with a single period.

# Send QUIT command and get server response.

Reference no: EM131224507

Questions Cloud

Break down the segmentation variables : Break down the segmentation variables used for Baby Boomers, Gen X, GenY/Millennials and Gen Z. Compare the major differences and recommend one new and unique variable for each segment.
Responsibility of working with organization ceo : You have been given the responsibility of working with your organization's CEO to do a competitive market analysis of the potential success of one of their existing products.
How might your personality type influence job performance : Do you agree with the results of your assessment? Based on the results of your assessment, what do you see as your strengths and weaknesses? How might your personality type influence your job performance?
Theory of competition and cooperation in context of conflict : A critical issue in resolving conflict is the process through which people change their beliefs or their perception that they can only achieve their goals at the expense of the other party involved. How one approaches a conflict can determine how you..
How to identify a tcp socket : CISC 650 Computer Networks - Describe why an application developer might choose to run over TCP rather than UDP and What is the transmission rate that TCP would like to give to each of the connections?
Business ethics-alternative dispute resolution : Are the courts the best forum to resolve business disputes? Choose the forum that you believe is the best forum to resolve business disputes. Explain your reasoning for choosing this forum. Discuss the advantages and disadvantages of your selected fo..
Identify the structure that purvis currently has : Review the Purvis fact pattern and identify the structure that Purvis currently has. Identify the organizational structure. Does the structure fit the purpose of the company? Why or Why not?
Define truth-in-sentencing : How has the Truth-in-Sentencing Incentive Grant changed the way states sentence offenders? Include a discussion of which states complied with the act.
What have sexual harassment laws accomplished in workplace : What have sexual harassment laws accomplished in the workplace? Have the advances in sexual harassment law resulted in women being denied meaningful access to senior management mentors, who are most often male? Does every civil rights gain in the wor..

Reviews

len1224507

9/29/2016 2:37:50 AM

Please include your name and the “Certification of Authorship” form in EVERY document (except for the programming assignment) that you submit. Thanks - You can implement your email client using Python. You should write a simple Python program that follow a step-by-step process to establish a TCP connection with a mail server through sockets, and send an email message.

Write a Review

JAVA Programming Questions & Answers

  User to input a decimal number and ouputs the number

Write a program that prompts the user to input a decimal number and ouputs the number rounded to the nearest integer.Remember the rules around proper development style and form, including adding comments. A software developer should always add commen..

  Explain how operating systems and abstraction are related

Compare and contrast System Software and Application Software. Give an example of each. Abstraction is an important quality of an Operating System. Explain how Operating Systems and abstraction are related

  Design and implement a set of classes and interfaces and

design and implement a set of classes and interfaces and use them to evaluate the rtas resource requirements.nbspyour

  Write your program to accommodate spaces and strings longer

Write your program to accommodate spaces and strings longer than 100 characters. You may also assume each line ends with a newline character.

  How large a value can be stored in an integer variable

Most programming languages have a built-in integer data type. Normally this representation has a fixed size, thus placing a limit on how large a value can be stored in an integer variable

  Write a one-class java program

Write a one-class Java program with at least one method (besides main) to determine if the data in your dataset (i.e., in data.txt) follows Benford's law.

  Examine the clocktype class definition

Examine the ClockType class definition. How many attributes does it contain? Assume we have two classes and have instantiated an object from each class. How many copies of each class's attributes and methods exist in the instantiated objects?

  Write a recursive method to reverse a string.

write a recursive method to reverse a string. Explain why you would not normally use recursion to solve this problem?

  Create a new string called passwd

Create a class called Hw1FirstLastName.javain a project called hw1firstlastname. Create a new string called passwd formed by concatenatingevery alternate non-spacecharacter in sentencestarting with the first

  Document the current application describing major classes

Add to the Project Management tool the different planned activities needed to implement the changes to the solution and document the current application describing the major classes used by the application.

  Determine the length of the string

You must give your user three opportunities for wrong input before you terminate the program.

  Automated code coverage and cyclomatic complexity analyses

Automated code coverage and cyclomatic complexity analyses -

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd