Tuesday, October 27, 2015

Chapter-2 Q&A Answers

Notes :
OSI Model : application, presentation, session, transport, network, data link, physical
TCP/IP Stack : application, transport, network, link, physical
Ports Summary :
http :80 
https :443
ftp :20,21
telnet :23
ssh :22
smtp :25
pop3 : 110
snmp :161

Question & Answer:
SECTION 2.1
R1. List five nonproprietary Internet applications and the application-layer protocols that they use.
>> 

Application
Application-Layer Protocol
Underlying Transport Protocol
Web
HTTP (RFC 2616)
TCP
File Transfer
FTP (RFC 959)
TCP
Remote Terminal Access
Telnet (RFC 854)
TCP
Remote File Server
NFS (McKusK 1996)
UDP or TCP
E-Mail
SMTP (RFC 821)
TCP
R2. What is the difference between network architecture and application architecture?
Assignment2>>
Network architecture refers to the organization of the communication process into layers (e.g., the five-layer Internet architecture).
Application architecture, on the other hand, is designed by an application developer and dictates the broad structure of the application (e.g., client-server or P2P)

R3. For a communication session between a pair of processes, which process is
the client and which is the server?
>> 
The process which initiates the communication is the client.
The process that waits to be contacted is the server.

R4. For a P2P file-sharing application, do you agree with the statement, “There is no notion of client and server sides of a communication session”? Why or why not?
Assignment2>>
No. In a P2P file-sharing application, a peer can be client as well as a server at the same time It can be considered to be in different state.
The peer that is receiving a file is typically in the client state.
The peer that is sending the file is typically the server state.

R5. What information is used by a process running on one host to identify a process running on another host ?
>> 
The IP address and the port number of the socket of the destination host and in the destination process.

R6. Suppose you wanted to do a transaction from a remote client to a server as fast as possible. Would you use UDP or TCP? Why?

Assignment2>>
UDP shall be used.
With UDP, the transaction can be completed in one round trip time (RTT) - the client sends the transaction request into a UDP socket, and the server sends the reply back to the client's UDP socket. With TCP, a minimum of two RTTs are needed - one to set-up the TCP connection, and another for the client to send the request, and for the server to send back the reply.

R7. Referring to Figure 2.4, we see that none of the applications listed in Figure 2.4 requires both no data loss and timing. Can you conceive of an application that requires no data loss and that is also highly time-sensitive?
>> Stock Exchange Trading application. Another example is remote word processing, for example, with Google docs. However, because Google docs runs over the Internet (using TCP), timing guarantees are not provided.

R8. List the four broad classes of services that a transport protocol can provide.
For each of the service classes, indicate if either UDP or TCP (or both) provides such a service.
>> 
1. Reliable data transfer - TCP provides a reliable byte-stream between client and server but UDP does not.
2. A guarantee that a certain value for throughput will be maintained - Neither.
3. A guarantee that data will be delivered within a specified amount of time - Neither.
4. Confidentiality (via encryption) - Neither.

R9. Recall that TCP can be enhanced with SSL to provide process-to-process security services, including encryption. 1) Does SSL operate at the transport layer or the application layer? 2)If the application developer wants TCP to be enhanced with SSL, what does the developer have to do?

Assignment2>>
1) SSL operates at the application layer. In the context of TCP/IP model, But it shall be at the transport layer of the OSI model.

2) The SSL socket takes unencrypted data from the application layer, encrypts it and then passes it to the TCP socket. If the application developer wants TCP to be enhanced with SSL, she has to include the SSL code in the application.

SECTIONS 2.2–2.5
R10. What is meant by a handshaking protocol?
>> 
A protocol uses handshaking if the two communicating entities first exchange control packets before sending data to each other. SMTP uses handshaking at the application layer whereas HTTP does not.

R11. Why do HTTP, FTP, SMTP, and POP3 run on top of TCP rather than on UDP?
Assignment3>>

The applications associated with those protocols require that all application data be received in the correct order and without gaps. TCP provides this service whereas UDP does not.


R12. Consider an e-commerce site that wants to keep a purchase record for each of its customers. Describe how this can be done with cookies.
>> 
When the user first visits the site, the server creates a unique identification number, creates an entry in its back-end database, and returns this identification number as a cookie number. This cookie number is stored on the user's host and is managed by the browser. During each subsequent visit (and purchase), the browser sends the cookie number back to the site. Thus the site knows when this user (more precisely, this browser) is visiting the site.

R13. Describe how Web caching can reduce the delay in receiving a requested object. Will Web caching reduce the delay for all objects requested by a user or for only some of the objects? Why?
Assignment3>>
Web caching can bring the desired content "closer" to the user, possibly to the same LAN to which the user's host is connected. Web caching can reduce the delay for all objects, even objects that are not cached, since caching reduces the traffic on links.

R14. Telnet into a Web server and send a multiline request message. Include in the request message the If-modified-since: header line to force a response message with the 304 Not Modified status code.
>> An example is given below:
--------------------------------------
>> telnet www.esqsoft.com 80
telnet www.npu.edu 80
// Above is input , hit enter twice to send.

Trying 72.167.131.131...
Connected to esqsoft.com.
Escape character is '^]'.
// Above is response when connected.

GET /index.html HTTP/1.1
Host: www.npu.edu
If-modified-since: Fri, 18 May 2007 09:23:24 GMT

// Above is input, hit enter twice to send.

HTTP/1.1 304 Not Modified
Date: Mon, 21 May 2007 15:20:05 GMT
Server: Apache/1.3.9 (Unix)
ETag: "1631-3a3-3c6d478b'
// Above is response.
-------------------------------------------
Ralics-MacBook-Pro:~ raliclo$ telnet www.esqsoft.com 80
Trying 72.167.131.131...
Connected to esqsoft.com.
Escape character is '^]'.
GET /index.html HTTP/1.1
Host: www.esqsoft.com
If-modified-since: Fri, 18 May 2007 09:23:24 GMT

HTTP/1.1 200 OK
Date: Sat, 24 Oct 2015 01:36:14 GMT
Server: Apache
Accept-Ranges: bytes
Content-Length: 3298
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>
<title>E.S.Q. Software :: Educational, Standards, Quality through Software</title>
<meta name="description" content="Who is E.S.Q. Software? Find how-to examples related to web development, web design, web hosting, and programming topics.">
<meta name="keywords" content="esq,esqsoft,e.s.q. software">
<link rel="stylesheet" href="2003/style.css" type="text/css">

<script language="JavaScript" src="2003/library.js"></script>
<script type="text/javascript" src="http://www.esqsoft.com/tools/mai-lto.js"></script>

</head><body>
<script>if(window.templateHeader)templateHeader()</script>
<!-- start: content -->
<table width="100%" cellpadding="8" cellspacing="0">
  <tr>
    <td class="content">

    <h1>E.S.Q. Software</h1>

    <h2>Who or what is E.S.Q. Software?</h2>

    Once upon a time I thought acronyms were helpful; E.S.Q. is one of those acronyms.
    It stands for "Education", "Standards", and "Quality". These were (and remain) ideals that appeal to me personally and the name
    reminds me to strive for those in any software project I take on.

    <h2>Why this website?</h2>

    Over the years I've built tools to make tasks easier, or illustrate how to tackle programming and web development challenges.
    As a web developer I also found myself looking for a place to accumulate reliable tools and process for building and managing web projects
    for customers. This site was created as a place to aggregate and centralize that content--mainly so I could find them again when the need would arise.
    I mention this because I have a vested interest in trying to keep it current and useful...and I honestly hope you'll find it useful too.
    I appreciate your visit and hope you'll drop me a line if you have any questions or run into anything that isn't clear (or correct).
    Thank you!

    <h2>Would you like to reach our audience?</h2>

    Now that we've told you about our focus, perhaps you have a product or service designed to help our audience.
    We run ads to try to cover some of our hosting expenses and to prepare to help with upcoming college expenses for the kids.
    If you would like to explore this further, please contact me to work through one of the ad networks we partner with.

    <p>Here are some examples of our web developer content:
    <ul>
    <li><a href="javascript_examples/date-to-epoch.htm">date to epoch conversion tool</a>
    <li><a href="javascript/free-online-time-sheet.htm">javascript time card calculator example</a>
    <li><a href="examples/troubleshooting-http-using-telnet.htm">notes for troubleshooting HTTP using telnet</a>
    <li><a href="javascript/javascript-example-how-to-validate-radio-buttons.htm">radio button form validation example</a>
    <li><a href="site-map.htm">more...</a>
    </ul>

    </td>
  </tr>
</table>

<!-- end: content -->
<script>if(window.templateFooter)templateFooter('')</script>
<script>var no_ad = true;</script>

<!-- start Vibrant Media IntelliTXT script section -->
<script type="text/javascript" src="http://esqsoft.us.intellitxt.com/intellitxt/front.asp?ipid=83953"></script>
<!-- end Vibrant Media IntelliTXT script section -->
</body>
</html>

R15. Why is it said that FTP sends control information “out-of-band”?
Assignment3>>
FTP uses two parallel TCP connections, one connection for sending control information (such as a request to transfer a file) and another connection for actually transferring the file. Because the control information is not sent over the same connection that the file is sent over, FTP sends control information out of band.


R16. Suppose Alice, with a Web-based e-mail account (such as Hotmail or gmail), sends a message to Bob, who accesses his mail from his mail server using POP3. Discuss how the message gets from Alice’s host to Bob’s host. Be sure to list the series of application-layer protocols that are used to move the message between the two hosts.
>> 
Message is sent from Alice’s host to her mail server over HTTP. Alice’s mail server then sends the message to Bob’s mail server over SMTP. Bob then transfers the message from his mail server to his host over POP3.

R17. Print out the header of an e-mail message you have recently received. How many Received: header lines are there? Analyze each of the header lines in the message.
Assignment3>>

Received: from 65.54.246.203 (EHLO bay0-omc3-s3.bay0.hotmail.com) (65.54.246.203) ymta419.mail.mud.yahoo.com with SMTP; Sat, 19 May 2007 16:53:51 -0700 

Received:  from hotmail.com ([65.55.135.106]) by bay0-omc3-s3.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Sat, 19 May 2007 16:52:42 -0700 

Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sat, 19 May 2007 16:52:41 -0700 Message-ID: <BAY130-F26D9E35BF59E0D18A819AFB9310@phx.gbl> 

Received: from 65.55.135.123 by by130fd.bay130.hotmail.msn.com with HTTP; Sat, 19 May 2007 23:52:36 GMT From: "prithula dhungel" <prithuladhungel@hotmail.com> 

To: prithula@yahoo.com
Bcc:
Subject: Test mail
Date: Sat, 19 May 2007 23:52:36 +0000 Mime-Version: 1.0
Content-Type: Text/html; format=flowed
Return-Path: prithuladhungel@hotmail.com
Figure: A sample mail message header 

Received: This header field indicates the sequence in which the SMTP servers send and receive the mail message including the respective timestamps.

In this example there are 4 "Received:" header lines.
This means the mail message passed through 5 different SMTP servers before being delivered to the receiver's mail box.

The last (forth) "Received:" header indicates the mail message flow from the SMTP server of the sender to the second SMTP server in the chain of servers.  The sender's SMTP server is at address 65.55.135.123 and the second SMTP server in the chain is by130fd.bay130.hotmail.msn.com.

The third "Received:" header indicates the mail message flow from the second SMTP server in the chain to the third server, and so on.

Finally, the first "Received:" header indicates the flow of the mail messages from the forth SMTP server to the last SMTP server (i.e. the receiver's mail server) in the chain. 

Message-id:
Message-id is a unique string assigned by the mail system when the message is first created.
From:
This indicates the email address of the sender of the mail. In the given example, the sender is "prithuladhungel@hotmail.com"
To:
This field indicates the email address of the receiver of the mail. In the example, the receiver is "prithula@yahoo.com"
Subject:
This gives the subject of the mail (if any specified by the sender). In the example, the subject specified by the sender is "Test mail"
Date:
The date and time when the mail was sent by the sender. In the example, the sender sent the mail on 19th May 2007, at time 23:52:36 GMT.
Mime-version:
MIME version used for the mail. In the example, it is 1.0.
Content-type:
The type of content in the body of the mail message. In the example, it is "text/html".
Return-Path:
This specifies the email address to which the mail will be sent if the receiver of this mail wants to reply to the sender.

R18. From a user’s perspective, what is the difference between the download and delete mode and the download-and-keep mode in POP3?
Assignment3>>
With download and delete, after a user retrieves its messages from a POP server, the messages are deleted. This poses a problem for the nomadic user, who may want to access the messages from many different machines (office PC, home PC, etc.).

In the download and keep configuration, messages are not deleted after the user retrieves the messages. This can also be inconvenient, as each time the user retrieves the stored messages from a new machine, all of non-deleted messages will be transferred to the new machine (including very old messages).

R19. Is it possible for an organization’s Web server and mail server to have exactly the same alias for a hostname (for example, foo.com)? What would be the type for the RR that contains the hostname of the mail server?
>> 
Yes an organization's mail server and Web server can have the same alias for a host name. The MX record is used to map the mail server's host name to its IP address.


R20. Look over your received emails, and examine the header of a message sent from a user with an .edu email address. Is it possible to determine from the header the IP address of the host from which the message was sent? Do the same for a message sent from a gmail account.
>> 
You should be able to see the sender's IP address for a user with an .edu email address. But you will not be able to see the sender's IP address if the user uses a gmail account.


SECTION 2.6
R21. In BitTorrent, suppose Alice provides chunks to Bob throughout a 30-second interval. Will Bob necessarily return the favor and provide chunks to Alice in this same interval? Why or why not?
>> 
It is not necessary that Bob will also provide chunks to Alice. Alice has to be in the top 4 neighbors of Bob for Bob to send out chunks to her; this might not occur even if Alice provides chunks to Bob throughout a 30-second interval.

R22. Consider a new peer Alice that joins BitTorrent without possessing any chunks. Without any chunks, she cannot become a top-four uploader for any of the other peers, since she has nothing to upload. How then will Alice get her first chunk?
>> 
Recall that in BitTorrent, a peer picks a random peer and optimistically unchokes the peer for a short period of time. Therefore, Alice will eventually be optimistically unchoked by one of her neighbors, during which time she will receive chunks from that neighbor.

R23. What is an overlay network? Does it include routers? What are the edges in the overlay network?
>> 
The overlay network in a P2P file sharing system consists of the nodes participating in the file sharing system and the logical links between the nodes. There is a logical link (an "edge" in graph theory terms) from node A to node B if there is a semi-permanent TCP connection between A and B. An overlay network does not include routers.

R24. Consider a DHT with a mesh overlay topology (that is, every peer tracks all peers in the system). What are the advantages and disadvantages of such a design? What are the advantages and disadvantages of a circular DHT (with no shortcuts)?
>> 
Mesh DHT: The advantage is in order to a route a message to the peer (with ID) that is closest to the key, only one hop is required; the disadvantage is that each peer must track all other peers in the DHT. Circular DHT: the advantage is that each peer needs to track only a few other peers; the disadvantage is that O(N) hops are needed to route a message to the peer that is closest to the key.

R25. List at least four different applications that are naturally suitable for P2P architectures. (Hint: File distribution and instant messaging are two.)
>> 
a) File Distribution
b) Instant Messaging
c) Video Streaming
d) Distributed Computing

SECTION 2.7
R26. In Section 2.7, the UDP server described needed only one socket, whereas the
TCP server needed two sockets. Why? If the TCP server were to support n simultaneous connections, each from a different client host, how many sockets would the TCP server need?
>> 
With the UDP server, there is no welcoming socket, and all data from different clients enters the server through this one socket. With the TCP server, there is a welcoming socket, and each time a client initiates a connection to the server, a new socket is created. Thus, to support n simultaneous connections, the server would need n+1 sockets.

R27. For the client-server application over TCP described in Section 2.7, why must the server program be executed before the client program? For the client-server application over UDP, why may the client program be executed before the server program?
>> 
For the TCP application, as soon as the client is executed, it attempts to initiate a TCP connection with the server. If the TCP server is not running, then the client will fail to make a connection. For the UDP application, the client does not initiate connections (or attempt to communicate with the UDP server) immediately upon execution