URDINESH: TCP
Showing posts with label TCP. Show all posts
Showing posts with label TCP. Show all posts

Sunday, July 19, 2015

Transmission Control Protocol Introduction

Transmission Control Protocol       

TCP is one of the two original components of the suite the other being  Protocol so the entire suite is commonly referred to as TCP/IP. Whereas IP handles lower-level transmissions from computer to computer as a message makes its way across the Internet, TCP operates at a higher level, concerned only with the two end systems, for example a Web browser and a Web server. In particular, TCP provides reliable, ordered delivery of a stream of bytes from a program on one computer to another program on another computer. Besides the Web, other common applications of TCP include   . Among its other management tasks, TCP controls segment size, flow control, the rate at which data is exchanged, and network traffic congestion

HISTORICAL ORIGIN                                                                                

In May, 1974, the IEEE published a paper entitled "A Protocol for Packet Network Interconnection." The paper'Network function.

IP works by exchanging pieces of information called  A packet is a sequence of  and consists of a header followed by a body. The header describes the packet's destination and, optionally, the  to use for forwarding until it arrives at its final destination. The body contains the data which IP is transmitting.
Due to network congestion, traffic load balancing, or other unpredictable network behavior, IP packets can be  TCP detects these problems, requests retransmission of lost packets, rearranges out-of-order packets, and even helps minimize network congestion to reduce the occurrence of the other problems. Once the TCP receiver has finally reassembled a perfect copy of the data originally transmitted, it passes that datagram to the application program. Thus, TCP abstracts the application's communication from the underlying networking details.

                                      FLOW CONTROL

TCP uses an end-to-end protocol to avoid having the sender send data too fast for the TCP receiver to reliably receive and process it. Having a mechanism for flow control is essential in an environment where machines of diverse network speeds communicate. For example, if a PC sends data to a hand-held PDA that is slowly processing received data, the PDA must regulate data flow so as to not be overwhelmed. Forcing Data Delivery
Normally, TCP waits for the buffer to exceed the maximum segment size before sending any data. This creates serious delays when the two sides of the connection are exchanging short messages and need to receive the response before continuing. For example, the login sequence at the beginning of a session begins with the short message "Login," and the session cannot make any progress until these five characters have been transmitted and the response has been received. This process can be seriously delayed by TCP's normal behavior when the message is provided to TCP in several send calls

Reliable, a technique known as positive acknowledgment with retransmission is used to guarantee reliability of packet transfers. This fundamental technique requires the receiver to respond with an acknowledgment message as it receives the data. The sender keeps a record of each packet it sends, and waits for acknowledgment before sending the next packet. The sender also keeps a timer from when the packet was sent, and retransmits a packet if the timer expires. The timer is needed in case a packet gets lost or corrupted.
TCP consists of a set of rules: for the protocol, that are used with the Internet Protocol, and for the IP, to send data "in a form of message units" between co
   described an internetworking protocol for sharing resources using packet-switching among the nodes. A central control component of this model was the Transmission Control Program that incorporated both connection-oriented links and datagram services between hosts. The monolithic Transmission Control Program was later divided into a modular architecture consisting of the Transmission Control Protocol at the connection-oriented layer and the Internet Protocol at the internetworking  layer. The model became known informally as TCP/IP, although formally it was henceforth called the Internet Protocol Suite.

HARDWARE IMPLEMENTATION

One way to overcome the processing power requirements of TCP is to build hardware implementations of it, widely known as TCP  The main problem of TOEs is that they are hard to integrate into computing systems, requiring extensive changes in the operating system of the computer or device. The first company to develop such a device was Alacritech

NETWORK FUNCTION

TCP provides a communication service at an intermediate level between an application program and the . That is, when  desires to send a large chunk of data across the Internet using IP, instead of breaking the data into IP-sized pieces and issuing a series of IP requests, the software can issue a single request to TCP and let TCP handle the IP details.
IP works by exchanging pieces of information called  packet is a sequence of bytes and consists of a header followed by a body. The header describes the packet's destination and, optionally, the routers to use for forwarding until it arrives at its final destination. The body contains the data which IP is transmitting.
Due to network congestion, traffic load balancing, or other unpredictable network behavior, IP packets can be . TCP detects these problems, requests retransmission of lost packets, rearranges out-of-order packets, and even helps minimize network congestion to reduce the occurrence of the other problems. Once the TCP receiver has finally reassembled a perfect copy of the data originally transmitted, it passes that datagram to the application program. Thus, TCP abstracts the application's communication from the underlying networking details.


Tuesday, May 20, 2014

JAVA CODE FOR TCP MESSAGE TRANSFER



PROGRAM: (SERVER)

import java.net.*;
import java.io.*;
public class TcpServer
{
public static void main(String args[]) throws IOException
{
ServerSocket serverSocket=null;
try
{
serverSocket=new ServerSocket(1234);
}
catch(IOException e)
{
System.err.println("Could not Listen on Port:1234.");
System.exit(1);
}
Socket clientSocket=null;
try
{
clientSocket=serverSocket.accept();
}
catch(IOException e)
{
System.err.println("Accept Failed.");
System.exit(1);
}
PrintWriter out=new PrintWriter(clientSocket.getOutputStream(),
true);
BufferedReader in=new  BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
String int1,int2;
int num1=0,num2=0;
int1=in.readLine();
System.out.println("Received Number1:: "+int1);
int2=in.readLine();
System.out.println("Received Number2::  "+int2);
System.out.println(int1+"*"+int2);
try
{
 num1=Integer.parseInt(int1);
 num2=Integer.parseInt(int2);
}
catch(NumberFormatException nfe)
{
System.out.println("Numbers not Intergers");
out.println("Numbers not intergers");
}
System.out.print("="+num1*num2);
out.println(String.valueOf(num1*num2));
out.close();
in.close();
clientSocket.close();
serverSocket.close();
}
}

PROGRAM: (CLIENT)

import java.io.*;
import java.net.*;
public class TcpClient
{
public static void main(String[] args) throws IOException
{
Socket socket=null;
PrintWriter out=null;
BufferedReader in=null;
try
{
socket=new Socket("127.0.0.1",1234);
out=new PrintWriter(socket.getOutputStream(),true);
in=new BufferedReader(new InputStreamReader(socket.getInputStream()));
}
catch(UnknownHostException e)
{
System.err.println("Don't know about Host!!");
System.exit(1);
}
catch(IOException e)
{
System.err.println("Couldn't get I/o for the connection!!");
System.exit(1);           
}
BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
String num1,num2;
System.out.println("Enter Number1:: ");
num1=read.readLine();
out.println(num1);
System.out.println("Enter Number2:: ");
num2=read.readLine();
out.println(num2);
System.out.println("Product of two given Numbers are:: ");
System.out.println(in.readLine());
out.close();
in.close();
read.close();
socket.close();
}
}



OUTPUT:(SERVER)


Received Number1::5
Received Number2::5
5*5
=25

OUTPUT:(CLIENT)


Enter Number1::
5
Enter Number2::
5
Product of two given Numbers are::

25

JAVA CODE FOR TCP CHAT APPLICATION


PROGRAM: (SERVER)
import java.io.*;
import java.net.*;
class ChatS
{
public static void main(String args[])throws IOException
{
ServerSocket s=new ServerSocket(3300);
Socket s1=s.accept();
for(;;)
{
DataInputStream d1=new DataInputStream(s1.getInputStream());
String s2=d1.readUTF();
System.out.println("client:"+s2);
DataInputStream b=new DataInputStream(System.in);
String s3=b.readLine();
DataOutputStream d3=new DataOutputStream(s1.getOutputStream());
System.out.print(“server: “);
d3.writeUTF(s3);
}  
}  
}
PROGRAM: (CLIENT)
import java.io.*;
import java.net.*;
class ChatC
{
public static void main(String args[])throws IOException
{
Socket s1=new Socket("127.0.0.1",3300);
for(;;)
{
DataInputStream dis=new DataInputStream(System.in);
String str=dis.readLine();
DataOutputStream ds=new DataOutputStream(s1.getOutputStream());
System.out.print(“client: “);
ds.writeUTF(str);
DataInputStream d1=new DataInputStream(s1.getInputStream());
String Str1=d1.readLine();
System.out.println("server:"+Str1);    
}   
}  
}






OUTPUT: (CLIENT)

client: Hai
From server:How are you
client: fine


OUTPUT: (SERVER)


From client:Hai
server: How are you

From client: fine

JAVA CODE FOR TCP FILE TRANSFER



PROGRAM: (SERVER)

import java.net.*;
import java.io.*;
import java.util.*;
class FileTcpServer
{
public static void main(String a[])throws IOException
{
BufferedReader din=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Source Filename::  ");
String sf=din.readLine();
String str=" ";
File srcf=new File(sf);
if(!srcf.exists() )
{
System.out.println(sf + "File not Found!!");
return;
}
FileInputStream fin=new FileInputStream(srcf);
int len=fin.available();
byte ch[]=new byte[len];
try
{
ServerSocket ss=new ServerSocket(3000);
while(fin.available() >0 )
{
Socket sock=ss.accept();
PrintWriter bw=new PrintWriter(sock.getOutputStream(),true);
fin.read(ch,0,len);
str=new String(ch,0,len);
System.out.println(str);
bw.println(str);
System.out.println(len);
sock.close();
}
}
catch(Exception e)
{         
}
fin.close();
}
}




PROGRAM: (CLIENT)

import java.net.*;
import java.io.*;
import java.util.*;
class FileTcpClient
{
public static void main(String a[])throws IOException
{
String str=" ";
BufferedReader din=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Destination Filename::  ");
String df=din.readLine();
File dstf=new File(df);
if(!dstf.exists() )
{
System.out.println(df + "File already Exists!!");
return;
}
FileOutputStream fout=new FileOutputStream(dstf);
try
{
Socket sock=new Socket(InetAddress.getByName("  "),3000);
DataInputStream br=new DataInputStream(sock.getInputStream());
int len=2341;
while(true )
{
byte buff[]=new byte[len];
br.read(buff,0,len);
str=new String(buff,0,len);
fout.write(buff);
System.out.println(str);
sock.close();
}                     
}
catch(Exception e)
{
}
fout.close();
}
}








OUTPUT: (SERVER)


Enter Source Filename::
Test1.java

OUTPUT: (CLIENT)

Enter Destination Filename::

Test2.java

Thursday, May 8, 2014

INTRODUCTION TO WEB TECHNOLOGY



1. What is the difference between node and host?
A node is any addressable device connected to a network whereas the host is a more
specific descriptor that refers to a networked general-purpose computer rather than a single purpose device (such as a printer).
2. What is the purpose of routers?
Router operates like electronic postal workers that evaluate and forward packets
between networks.
3. Define protocol.
A protocol is a formal set of rules that must be followed in order to communicate.
4. Why are the protocols layered?
Layering protocols simplifies the task of communicating over the network and it
allows for reuse of layers that are not specific to a particular application.
5. Define encapsulation.
Placing the data inside a package of headers is known as encapsulation.
6. Define port.
A port is a logical channel to an application running on a host. ie., The applications
running on the host machines are uniquely identified by port numbers.
7. What do you mean by well-known ports?
Port numbers can range from 1 to 65535, however ports 1 to 1023 are reserved.
These reserved ports are referred to as we1l-known ports because the Internet Assigned
Numbers Authority publicly documents the applications that use them.
8. What is meant by Name Resolution?
Name Resolution is the process of mapping a hostname to its corresponding IP
Address.One way to translate a hostname to an IP address is to look it up in a simple text file.The second way is the domain name service, which is a distributed database containing all registered hostnames on the Internet and their IP addresses.
9. Define protocol tunneling.
Protocol tunneling is the process of encapsulating one protocol within another
protocol that operates on the same layer.
10. Define URI, URL, URN.
1. URI (Uniform Resource Identifier): It identifies an object on the Internet.
2. URL (Uniform Resource Locator): It is a specification for identifying an object
such as a file, newsgroup, CGI program or e-mail address by indicating the exact location on the internet.
3. URN (Uniform Resource Name): It is a method for referencing an object without
declaring the full path to the object.
11. What are the components of HTTP URL?
The components are host, an optional port, path, filename, section and query string.
12. Define URL encoding.
URL encoding involves replacing all unsafe and nonprintable characters with a
percent sign (%) followed by two hexadecimal digits corresponding to the character‟s ASCII value.
13. What are the issues of next generation IP?
The issues to be considered in IP next generation are
I. Addresses Space Growth
2. Support large Global networks
3. A clear way of transition from the existing IP to new IP next generation
14. What is the difference between TCP and UDP?
TCP:
Connection oriented transport protocol
Sends data as a stream of bytes
Guarantee of delivery
UDP:
Connection less protocol
Datagram service
No guarantee of delivery.
15. What does ICMP provide?
ICMP provides
1. Error messaging
2. Demand reply functions
16. Define IGMP.
It is Internet Group Management protocol. It provides
1. Broadcasting
2. Multicasting
17. List the goals of SGML.
I. To manage the flow of millions of pages.
2. For structuring information exchange
3. For modeling inter-document linkages
4. For managing information flows between departments and weapons systems
18. What is the role of server?
1. Manages application tasks
2. Handles storage
3. Handles security
4. Provides scalability
5. Handles accounting and distribution
19. What are the necessities of using HTML forms?
1. Gathering user information
2. Conducting Surveys
3. Interactive services
20. What are the sequences of steps for each HTTP request from a client to the server?
1. Making the connection
2. Making a request
3. The response
4. Closing the connection
21. Define MIME.
MIME (Multipurpose Internet Mail Extensions) is an open standard for sending
multipart, multimedia data through Internet email.
22. List the predefined MIME content types.
1. Text
2. Multipart
3. Message
4. Image
5. Audio
6. Video
7. Model
8. Application
23. Define HTML.
It is a simple page description language, which enables document creation for the
web.
24. What is meant by loop back address?
A zone that enables the server to direct traffic to itself. The host number is almost
always 127.0.0.1.

Followers