Anda di halaman 1dari 50

Ex.

NO:1A

ECHO SERVER AND CLIENT USING SOCKET PROGRAMING

AIM To write a java program for implementing echoclient and echoserver. ALGORITHM 1. 2. 3. 4. 5. 6. Start the program. Get the inputs with the help of read lines, and convert the string into array data type. Check the character array for any escape sequence. If this input displayed with escape sequence character. Otherwise it shows the result as it is. Stop the program.

PROGRAM ECHOSERVER import java.io.*; import java.net.*; class EchoServer { public EchoServer(int portnum) { try { server=new ServerSocket(portnum); } catch(Exception err) { System.out.println(err);
1

} } public void serve() { try { while(true) { Socket client=server.accept(); BufferedReader r=new BufferedReader(new InputStreamReader(client.getInputStream())); PrintWriter w=new PrintWriter(client.getOutputStream(),true); w.println("Welcome to the Java EchoServer. Type'bye' to close."); String line; do { line=r.readLine(); if(line !=null) System.err.println("server got "+line+" from client"); w.println("Got:"+line); } while( !line.trim().equals("bye")); client.close(); } } catch(Exception err)
2

{ System.err.println(err); } } public static void main(String[] args) { EchoServer s=new EchoServer(9999); s.serve(); } private ServerSocket server; } ECHOCLIENT
import java.io.*; import java.net.*; class EchoClient { public static void main(String[] args) { try { Socket s=new Socket("127.0.0.1",9999); BufferedReader r=new BufferedReader(new InputStreamReader(s.getInputStream())); PrintWriter w=new PrintWriter(s.getOutputStream(),true); BufferedReader con=new BufferedReader(new InputStreamReader(System.in)); String line; do 3

{ line=r.readLine(); if(line !=null) System.out.println(line); line=con.readLine(); w.println(line); } while( !line.trim().equals("bye")); } catch(Exception err) { System.err.println(err); } } }

OUTPUT
Echoclient Welcome to Java echo server, Type bye to close Hai Got: Hai Echoserver Server got Hai from client. Echoclient Bye

RESULT
Thus the above program for echoclient & echoserver using socket program has been executed successfully. 5

Ex.NO:1B

IMPLEMENTATION OF REMOTE SERVER

AIM
To write a Java program for implementing remote server.

ALGORITHM
1. Start the program.

2. Get the inputs with the help of read lines, and convert the string into array data type. 3. Check the character array for any escape sequence.
4. 5. 6. 7. If this input is displayed. Otherwise it shows output. Display the output. Stop the program.

PROGRAM CLIENT
import java.io.*; import java.net.*; public class client { public static void main(String args[])throws Exception { Socket s=new Socket("localhost",555); DataOutputStream out=new DataOutputStream(s.getOutputStream()); DataInputStream sysin=new DataInputStream(System.in); String str; System.out.println("enter the command to be executed"); str=sysin.readLine(); out.writeBytes(str+"\n"); System.out.println(str+" has been executed to the server");

s.close(); } }

SERVER
import java.io.*; import java.net.*; public class RemoteServer { public static void main(String args[])throws Exception { ServerSocket ss=new ServerSocket(555); Socket s=ss.accept(); DataInputStream sysin=new DataInputStream(s.getInputStream()); String str; str=sysin.readLine(); Runtime r=Runtime.getRuntime(); Process p=null; p=r.exec(str); System.out.println(str+"has been executed"); } }

OUTPUT JAVA CLIENT


Enter the command to be executed. Ms paint Ms paint has been executed to the server.

JAVA REMOTESERVER
Ms paint has been executed.

RESULT
Thus the above program for remote server has been executed successfully.

Ex.NO:1C

IMPLEMENTATION OF CONCURRENT SERVER

AIM
To write a java program for implementing the concurrent server.

ALGORITHM SERVER
1. 2. 3. 4. 5. Start the program. Initialize the port number. Client sends request to the server. If the connection is established. Stop the program.

CLIENT
1. 2. 3. 4. 5. 6. 7. Start the program. Initialize the port number. The server will process the client request. The server will process the client request. Initialize the valid address and get the system name. Print the message is received. Stop the program.

PROGRAM SERVER import java.io.*; import java.net.*; class concurrentserver { public static void main(String args[]) throws Exception { int count=0; Thread t=Thread.currentThread();

ServerSocket ss=new ServerSocket(555); while(true) { try { Socket S=ss.accept(); count ++; conserver c=new conserver(S,count); } catch(Exception e){} } } } class conserver implements Runnable { Thread t; Socket S; int c; conserver(Socket S1,int count) { t=new Thread(this,"Demo"); t.start(); S=S1; c=count; }
10

public void run() { try { DataInputStream inp=new DataInputStream(S.getInputStream()); DataOutputStream out=new DataOutputStream(S.getOutputStream()); String sentence="Enter the string"; String newsentence; out.writeBytes(sentence+"\n"); newsentence=inp.readLine(); System.out.println("From client"+c+":"+newsentence); out.writeBytes(newsentence+"\n"); } catch(Exception e){} } } CLIENT
import java.net.*; import java.io.*; import java.lang.String; class concurrentclient { public static void main(String args[]) throws Exception { String sentence,newsentence,newsentence1;

11

DataInputStream in=new DataInputStream(System.in); Socket cs=new Socket("LOCALHOST",555); DataInputStream inp=new DataInputStream(cs.getInputStream()); DataOutputStream out=new DataOutputStream(cs.getOutputStream()); sentence=inp.readLine(); System.out.println(sentence); newsentence=in.readLine(); out.writeBytes(newsentence+'\n'); newsentence1=inp.readLine(); System.out.println("From Server:"+newsentence1); cs.close(); } }

12

OUTPUT
JAVA CLIENT1 Enter the string Hai JAVA CLIENT2 Enter the string :Hello From Server :Hello JAVA SERVER From Client1:Hai From Client2:Hello

RESULT
Thus the program for concurrent server has been executed successfully. 13

Ex.NO:2

GOSSIP CLIENT AND GOSSIP SEVER

AIM To write a java program for implementing TCP client server. ALGORITHM
1. 2. 3. 4. 5. 6. Start the program. Initialize the port number. Client sends request to server. If the connection is established display the output. Else return out. Stop the program.

PROGRAM gossipclient.java import java.io.*; import java.net.*; public class GossipClient { public static void main(String[] args) throws Exception { Socket sock = new Socket("127.0.0.1", 465); // reading from keyboard (keyRead object) BufferedReader keyRead = new BufferedReader(new InputStreamReader(System.in)); // sending to client (pwrite object) OutputStream ostream = sock.getOutputStream(); PrintWriter pwrite = new PrintWriter(ostream, true);

// receiving from server ( receiveRead object)


14

InputStream istream = sock.getInputStream(); BufferedReader receiveRead = new BufferedReader(new InputStreamReader(istream));

System.out.println("Start the chitchat, type and press Enter key");

String receiveMessage, sendMessage; while(true) { sendMessage = keyRead.readLine(); pwrite.println(sendMessage); System.out.flush(); // keyboard reading

// sending to server

// flush the data

if((receiveMessage = receiveRead.readLine()) != null) //receive from server { System.out.println(receiveMessage); // displaying at DOS prompt } } } } GOSSIP SERVER GossipServer.java
import java.io.*; import java.net.*; public class GossipServer {

15

public static void main(String[] args) throws Exception { ServerSocket sersock = new ServerSocket(465); System.out.println("Server ready for chatting"); Socket sock = sersock.accept( ); // reading from keyboard (keyRead object) BufferedReader keyRead = new BufferedReader(new InputStreamReader(System.in)); // sending to client (pwrite object) OutputStream ostream = sock.getOutputStream(); PrintWriter pwrite = new PrintWriter(ostream, true);

// receiving from server ( receiveRead object) InputStream istream = sock.getInputStream(); BufferedReader receiveRead = new BufferedReader(new InputStreamReader(istream));

String receiveMessage, sendMessage; while(true) { if((receiveMessage = receiveRead.readLine( )) != null) { System.out.println(receiveMessage); } sendMessage = keyRead.readLine(); pwrite.println(sendMessage); System.out.flush(); } }}

16

OUTPUT JAVA GOSSIP SERVER


Server ready for Chatting Hai

JAVA GOSSIP CLIENT


Start the client chat type2 and press any key Hai

RESULT
Thus the implementation of gossip client and server has been executed successfully.

17

Ex.NO:3

FILE TRANSFER PROTOCOL

AIM
To write a java program to implement the file transfer protocol.

ALGORITHM CLIENT
1. 2. 3. 4. Start the program. Create the client packet. After transferring the packet statementis displayed. Stop the program.

SERVER
1. 2. 3. 4. 5. 6. Start the program. Create the server socket. Call the I/O stream. Print the file has been sent. Send the intimation to the client. Stop the program.

PROGRAM CLIENT import java.io.*; import java.net.*; public class ftpclient { public static void main(String args[])throws Exception { Socket s=null; DataInputStream si=null; s=new Socket("LocalHost",5555);

18

si=new DataInputStream(s.getInputStream()); DataInputStream inp=new DataInputStream(System.in); DataOutputStream so=new DataOutputStream(s.getOutputStream()); String str; System.out.println("\n Enter file name(path)"); str=inp.readLine(); so.writeBytes(str); so.writeBytes("\n"); FileOutputStream fo=new FileOutputStream("sss.txt"); int str1; while((str1=si.read())!=-1) fo.write((char)str1); System.out.println("\n file received successfully"); si.close(); } }

SERVER
import java.io.*; import java.net.*; public class ftpserver { public static void main(String args[])throws Exception { Socket s=null;

19

ServerSocket ss=null; DataOutputStream sso=null; DataInputStream ssi=null; ss=new ServerSocket(5555); s=ss.accept(); sso=new DataOutputStream(s.getOutputStream()); ssi=new DataInputStream(s.getInputStream()); String s1; s1=ssi.readLine(); FileInputStream fo=new FileInputStream(s1); int str; while((str=fo.read())!=-1) sso.writeBytes(""+(char)+str); System.out.println("file has been sent successfully"); sso.close(); s.close(); } }

20

OUTPUT FTP CLIENT


Enter file name(Path) m.txt File received successfully.

FTP SERVER
File has been sent successfully.

RESULT
Thus the implementation of FTP client and server has been executed successfully.

21

Ex.NO:4

SIMPLE MAIL TRANSFER PROTOCOL

AIM
To write a java program to implement the concept of simple mail transfer protocol.

ALGORITHM SERVER
1. 2. 3. 4. Start the program. Create the server packet Call the I/O stream. print the mail has been sent & send intimation.

CLIENT
1. 2. 3. 4. Start the program. Create the client packet. After transferring packet statement is displayed. Stop the program.

PROGRAM SMTP CLIENT import java.io.*; import java.net.*; class smtpclient1 { public static void main(String a[]) throws Exception { Socket s=new Socket("127.0.0.1",9999); DataInputStream dis=new DataInputStream(s.getInputStream()); DataInputStream in=new DataInputStream(System.in); PrintStream ps=new PrintStream(s.getOutputStream()); ps.println("Ready");
22

System.out.println(dis.readLine()); String strFrom=in.readLine(); ps.println(strFrom); System.out.println(dis.readLine()); String strTo=in.readLine(); ps.println(strTo); System.out.println(dis.readLine()); String strSub=in.readLine(); ps.println(strSub); System.out.println(dis.readLine()); while(true) { String msg=in.readLine(); ps.println(msg); if(msg.equals("quit")) { System.out.println("msg is delerived to server and client quits"); break; } } } }

SMTP SERVER
import java.io.*; 23

import java.net.*; class smtpserver1 { public static void main(String args[])throws Exception { ServerSocket ss=new ServerSocket(9999); Socket s=ss.accept(); ServiceClient(s); } public static void ServiceClient(Socket s)throws Exception { DataInputStream dis=null; PrintStream ps=null; dis=new DataInputStream(s.getInputStream()); ps=new PrintStream(s.getOutputStream()); FileWriter f=new FileWriter("testmail.eml"); String tel=dis.readLine(); if(tel.equals("Ready")) System.out.println("Ready signal received from client"); ps.println("enter the from address"); String from=dis.readLine(); f.write("From:"+from+"\n"); ps.println("enter the to address"); String to=dis.readLine(); f.write("to:"+to+"\n"); ps.println("enter the subject");

24

String sub=dis.readLine(); f.write("subject"+sub+"\n"); ps.println("enter the message"); String msg=dis.readLine(); f.write("\n Message:"+msg+"\n"); f.close(); } }

25

OUTPUT Chat Box


No Subject File Reply Edit Reply all View Forward Tools Print Message Delete Help

From : Gobi Date : Tuesday, July 31, 2012 4.06PM To : Chennai Subject: (No subject) Message : Hello

RESULT
Thus the implementation of SMTP client and server has been implemented successfully. 26

Ex.NO:5

APPLICATION USING UDP SOCKET DNS

AIM
To write a java program for application using UDP socket DNS.

ALGORITHM
1. Start the program 2. Enter the system name (dn) after the connection with the server is established. 3. Call the subroutine resolver and pass the system name to the resolver. 4. Open the host files in the DNS server. 5. Check the system name with the name stored in the host file until the end of the file. 6. If the name matches, then fetch the corresponding IP address and display the IP address. Go to step8. 7. If the match is not found, then display the message as system is not logged on.

8. Stop the process. PROGRAM DNS CLIENT import java.io.*; import java.net.*; import java.util.*; class dclient { public static void main(String args[]) { try

27

{ DatagramSocket client=new DatagramSocket(); InetAddress addr=InetAddress.getByName("127.0.0.1"); byte[]sendbyte=new byte[1024]; byte[]receivebyte=new byte[1024]; BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter DOMAIN NAME OR IP address"); String str=in.readLine(); sendbyte=str.getBytes(); DatagramPacket sender=new DatagramPacket(sendbyte,sendbyte.length,addr,1309); client.send(sender); DatagramPacket receiver= new DatagramPacket(receivebyte,receivebyte.length); client.receive(receiver); String s=new String(receiver.getData()); System.out.println("IP adddress or DOMAIN NAME :"+s.trim()); client.close(); }

catch(Exception e) { System.out.println(e); } }

28

} DNS SERVER import java.io.*; import java.net.*; import java.util.*; class dserver { public static void main(String args[]) { try { DatagramSocket server=new DatagramSocket(1309); while(true) { byte[]sendbyte=new byte[1024]; byte[]receivebyte=new byte[1024]; DatagramPacket receiver=new DatagramPacket(receivebyte,receivebyte.length); server.receive(receiver); String str=new String(receiver.getData()); String s=str.trim(); //system.out.println(s); InetAddress addr=receiver.getAddress(); int port=receiver.getPort();

29

String ip[]={"165.165.80.80","165.165.79.1"}; String name[]={"www.aptitude source.com","www.Sharifguys.com"}; for(int i=0;i<ip.length;i++) { if(s.equals(ip[i])) { sendbyte=name[i].getBytes(); DatagramPacket sender=new DatagramPacket(sendbyte,sendbyte.length,addr, port); server.send(sender); break; } else if(s.equals(name[i])) { sendbyte=ip[i].getBytes(); DatagramPacket sender=new DatagramPacket(sendbyte,sendbyte.length,addr, port); server.send(sender); break; } } break; } } catch(Exception e)

30

{ System.out.println(e); } } }

31

OUTPUT
Java Server 165.165.80.80 165.165.79.1 Java Client Enter domain name or IP address 165.165.80.80 Ip address or domain name: www.aptitude source.com 165.165.79.1 Ip address or domain name: www.Sharifguys.com

RESULT
Thus the program for application using UDP socket DNS has been executed successfully.

32

Ex.NO:6.

IMPLEMENTATION OF USER DATAGRAM

AIM
To write a java program for application using user datagram.

ALGORITHM SERVER
1. 2. 3. 4. 5. Start the program. Create the server packet. Call I/O stream. Run the server. Stop the program.

CLIENT
1. 2. 3. 4. 5. Start the program. Create the client packet. After the transferring packet statement is displayed. Display the output. Stop the program.

PROGRAM SERVER import java.io.*; import java.net.*; class Userver { public static void main(String args[])throws Exception { DatagramSocket ds=new DatagramSocket(700); byte data[]=new byte[20]; String str; while(true)
33

{ DatagramPacket dp=new DatagramPacket(new byte[225],225); ds.receive(dp); data=dp.getData(); int n=(int)data[0]; if(n==0) break; else n=n*n; System.out.println(Integer.toString(n)); } } }

CLIENT import java.io.*;


import java.net.*; import java.lang.*; class Uclient { public static void main(String args[])throws Exception {

34

DatagramSocket ds=new DatagramSocket(); DataInputStream in=new DataInputStream(System.in); byte a[]=new byte[20]; String str; while(true) { str=in.readLine(); int n=Integer.parseInt(str); a[0]=(byte)n; DatagramPacket dp=new DatagramPacket(a,a.length,InetAddress.getByName("localhost"),700); ds.send(dp); if(str.equals("0")) break; } } }

35

OUTPUT JAVA SERVER


4 16 36

JAVA CLIENT
2 4 6

RESULT
Thus the program for application using datagram has been executed successfully.

36

Ex.NO:7

IMPLEMENTATION OF LEAKY BUCKET ALGORITHM

AIM
To write a C program for implementing leaky bucket algorithm.

ALGORITHM
1. 2. 3. 4. 5. Start the program. Include the necessary header files. Declare the variables. call the I/O stream. Stop the program.

PROGRAM
#include<stdio.h> #define min(x,y)((x)<(y)?(x):(y)) #define Max 25 int main() { int cap, oprt,nsec,cont, i=0,inp[Max],ch; printf("Leaky Bucket Algoritm\n"); printf("Enter bucket size\n"); scanf("%d",&cap); printf("\n Enter the ouput Rate \n"); scanf("%d",&oprt); do { printf("Enter no of packets entering at %d Second \n", i+1); scanf("%d",&inp[i]); i++; printf("\nEnter 1 to insert packet or 0 to quit\n "); 37

scanf("%d",&ch); }while(ch); nsec=i;

printf("\n (second):(pktsrecd):(pkts in bucket):(pkts sent):(pkts left in bucket)\n");;

cont=0; for(i=0;i<nsec;i++) { cont+=inp[i]; if(cont>cap) { printf("\n Excessive incoming pkts for the bucket:\n"); printf("\n the excessive pkts rejected from bucket at%d sec is %d",i+1,(cont-cap));

cont=cap; printf("\n"); } printf("(%d):",i+1); printf("\t\t(%d):",inp[i]); printf("\t\t(%d):",cont); printf("\t\t(%d):",min(cont,oprt)); cont=cont-min(cont,oprt); printf("\t\t(%d)\n",cont); } for(;cont!=0;i+1)

38

{ printf("\t\t(%d):",i+1); printf("\t\t(0):"); printf("\t\t(%d):",cont); printf("\t\t(%d):",min(cont,oprt)); cont=cont-min(cont,oprt); printf("\t\t(%d)\n",cont); } return(0); }

39

OUTPUT: Leaky Bucket Algorithm Enter Bucket Size 20 Enter the Output Rate 10 Enter the no of packets Entering at 1 second: 15 Enter 1 to insert packet or 0 to quit: 0 Enter the no of packets Entering at 2 second: 10 Enter 1 to insert packet or 0 to quit: 0 SECOND 1 2 PktsRecd 15 10 PktsInBucket PktsSent 15 15 10 10 PktsLeftInBucket 5 5

RESULT
Thus the above program for leaky bucket algorithm has executed successfully. 40

Ex.NO:8

STUDY OF VARIOUS IP ADDRESS CLASSES

AIM: To study various IP address classes. EXPLANATION: IPV4 ADDRESSING An IP address is a unique logical identifier for a node or host connection on an IP network. An IP address is a 32 bit binary number, and represented as 4 decimal values of 8 bits each. The decimal values range from 0 to 255. This is known as "dotted decimal" notation. Example: 192.189.210.078 It is sometimes useful to view the values in their binary form. 192.189.210.078 11000000.10111101.11010010.1001110 Every IP address consists of network identifier and node identifier. The IP network is divided based on Class of network. The class of network is determined by the leading bits of the IP address as shown below. ADDRESS CLASSES There are 5 different address classes. You can determine which class any IP address is in by examining the first 4 bits of the IP address.

Class A addresses begin with 0xxx, or 1 to 126 decimal. Class B addresses begin with 10xx, or 128 to 191 decimal. Class C addresses begin with 110x, or 192 to 223 decimal. Class D addresses begin with 1110, or 224 to 239 decimal. Class E addresses begin with 1111, or 240 to 254 decimal.

Addresses beginning with 01111111, or 127 decimal, are reserved for loopback and for internal testing on a local machine. Class D addresses are reserved for multicasting. Class E addresses are reserved for future use. They should not be used for host addresses.

41

Now we can see how the Class determines, by default, which part of the IP address belongs to the network (N) and which part belongs to the Host/node (H).

Class A: NNNNNNNN.HHHHHHHH.HHHHHHHH.HHHHHHHH Class B: NNNNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHHH Class C: NNNNNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH

In the example, 192.189.210.078 is a Class C address so by default the Network part of the address (also known as the Network Address) is defined by the first three octets (192.189.210.XXX) and the node part is defined by the last one octets (XXX.XXX.XXX.078). In order to specify the network address for a given IP address, the node section is set to all "0"s. In our example, 192.189.210.0 specifies the network address for 192.189.210.078. When the node section is set to all "1"s, it specifies a broadcast that is sent to all hosts on the network. 192.189.210.255 specifies the broadcast address. PRIVATE SUBNETS There are three IP network addresses reserved for private networks. The addresses are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. They can be used by anyone setting up internal IP networks, such as an intranet. Internet routers never forward the private addresses over the public Internet.

42

Options - There is provision for additional fields in the IPv4 header to provide other services but these are rarely used.

IPV6 HEADER:

Source address (128 bits) The 128-bit source address field contains the IPv6 address of the originating node of the packet. It is the address of the originator of the IPv6 packet. Destination address (128 bits) The 128-bit contains the destination address of the recipient node of the IPv6 packet. It is the address of the intended recipient of the IPv6 packet. Version/IP version (4-bits) The 4-bit version field contains the number 6. It indicates the version of the IPv6 protocol. This field is the same size as the IPv4 version field that contains the number 4. However, this field has a limited use because IPv4 and IPv6 packets are not distinguished based on the value in the version field but by the protocol type present in the layer 2 envelope.
43

Packet priority/Traffic class (8 bits) The 8-bit Priority field in the IPv6 header can assume different values to enable the source node to differentiate between the packets generated by it by associating different delivery priorities to them. This field is subsequently used by the originating node and the routers to identify the data packets that belong to the same traffic class and distinguish between packets with different priorities. Flow Label/QoS management (20 bits) The 20-bit flow label field in the IPv6 header can be used by a source to label a set of packets belonging to the same flow. A flow is uniquely identified by the combination of the source address and of a non-zero Flow label. Multiple active flows may exist from a source to a destination as well as traffic that are not associated with any flow (Flow label = 0). The IPv6 routers must handle the packets belonging to the same flow in a similar fashion. The information on handling of IPv6 data packets belonging to a given flow may be specified within the data packets themselves or it may be conveyed by a control protocol such as the RSVP (Resource reSerVation Protocol). When routers receive the first packet of a new flow, they can process the information carried by the IPv6 header, Routing header, and Hop-by-Hop extension headers, and store the result (e.g. determining the retransmission of specific IPv6 data packets) in a cache memory and use the result to route all other packets belonging to the same flow (having the same source address and the same Flow Label), by using the data stored in the cache memory. Payload length in bytes(16 bits) The 16-bit payload length field contains the length of the data field in octets/bits following the IPv6 packet header. The 16-bit Payload length field puts an upper limit on the maximum packet payload to 64 kilobytes. In case a higher packet payload is required, a Jumbo payload extension header is provided in the IPv6 protocol. A Jumbo payload (Jumbogram) is indicated by the value zero in the Payload Length field. Jumbograms are frequently used in supercomputer communication using the IPv6 protocol to transmit heavy data payload. Next Header (8 bits) The 8-bit Next Header field identifies the type of header immediately following the IPv6 header and located at the beginning of the data field (payload) of the IPv6 packet. This field usually specifies the transport layer protocol used by a packet's payload. The two most common kinds of Next Headers are TCP (6) and UDP (17), but many other headers are also possible. The format adopted for this field is the one proposed for IPv4 by RFC 1700. In case of IPv6 protocol, the Next Header field is similar to the IPv4 Protocol field.

44

Time To Live (TTL)/Hop Limit (8 bits) The 8-bit Hop Limit field is decremented by one, by each node (typically a router) that forwards a packet. If the Hop Limit field is decremented to zero, the packet is discarded. The main function of this field is to identify and to discard packets that are stuck in an indefinite loop due to any routing information errors. The 8-bit field also puts an upper limit on the maximum number of links between two IPv6 nodes. In this way, an IPv6 data packet is allowed a maximum of 255 hops before it is eventually discarded. An IPv6 data packet can pas through a maximum of 254 routers before being discarded. In case of IPv6 protocol, the fields for handling fragmentation do not form a part of the basic header. They are put into a separate extension header. Moreover, fragmentation is exclusively handled by the sending host. Routers are not employed in the Fragmentation process. Next Header (8 bits) The 8-bit Next Header field identifies the type of header immediately following the IPv6 header and located at the beginning of the data field (payload) of the IPv6 packet. This field usually specifies the transport layer protocol used by a packet's payload. The two most common kinds of Next Headers are TCP (6) and UDP (17), but many other headers are also possible. The format adopted for this field is the one proposed for IPv4 by RFC 1700. In case of IPv6 protocol, the Next Header field is similar to the IPv4 Protocol field ADDRESS FORMAT IPv6 addresses have two logical parts: a 64-bit network prefix, and a 64-bit host address part. (The host address is often automatically generated from the interface MAC address. [34]) An IPv6 address is represented by 8 groups of 16-bit hexadecimal values separated by colons (:) shown as follows: A typical example of an IPv6 address is 2001:0db8:85a3:0000:0000:8a2e:0370:7334 The hexadecimal digits are case-insensitive. The 128-bit IPv6 address can be abbreviated with the following rules:

Rule one: Leading zeroes within a 16-bit value may be omitted. For example, the address fe80:0000:0000:0000:0202:b3ff:fe1e:8329 may be written as fe80:0:0:0:202:b3ff:fe1e:8329 Rule two: A single occurrence of consecutive groups of zeroes within an address may be replaced by a double colon. For example, fe80:0:0:0:202:b3ff:fe1e:8329 becomes fe80::202:b3ff:fe1e:8329

45

A single IPv6 address can be represented in several different ways, such as 2001:db8::1:0:0:1 and 2001:0DB8:0:0:1::1. DUAL IP STACK IMPLEMENTATION The dual-stack protocol implementation in an operating system is a fundamental IPv4-toIPv6 transition technology. It implements IPv4 and IPv6 protocol stacks either independently or in a hybrid form. The hybrid form is commonly implemented in modern operating systems supporting IPv6. Dual-stack hosts are described in RFC 4213. Modern hybrid dual-stack implementations of IPv4 and IPv6 allow programmers to write networking code that works transparently on IPv4 or IPv6. The software may use hybrid sockets designed to accept both IPv4 and IPv6 packets. When used in IPv4 communications, hybrid stacks use an IPv6 application programming interface and represent IPv4 addresses in a special address format, the IPv4-mapped IPv6 address. IPV4-MAPPED IPV6 ADDRESSES Hybrid dual-stack IPv6/IPv4 implementations support a special class of addresses, the IPv4-mapped IPv6 addresses. This address type has its first 80 bits set to zero and the next 16 set to one, while its last 32 bits are filled with the IPv4 address. These addresses are commonly represented in the standard IPv6 format, but having the last 32 bits written in the customary dotdecimal notation of IPv4; for example, ::ffff:192.0.2.128 represents the IPv4 address 192.0.2.128. It substitutes the old and deprecated IPv4-compatible IPv6 address formed by ::192.0.2.128. Because of the significant internal differences between IPv4 and IPv6, some of the lower level functionality available to programmers in the IPv6 stack do not work identically with IPv4 mapped addresses. Some common IPv6 stacks do not support the IPv4-mapped address feature, either because the IPv6 and IPv4 stacks are separate implementations (e.g., Microsoft Windows 2000, XP, and Server 2003), or because of security concerns (OpenBSD) . On these operating systems, it is necessary to open a separate socket for each IP protocol that is to be supported. On some systems, e.g., the Linux kernel, NetBSD, and FreeBSD, this feature is controlled by the socket option IPV6_V6ONLY as specified in RFC 3493. TUNNELING In order to reach the IPv6 Internet, an isolated host or network must use the existing IPv4 infrastructure to carry IPv6 packets. This is done using a technique known as tunneling which consists of encapsulating IPv6 packets within IPv4, in effect using IPv4 as a link layer for IPv6.

46

The direct encapsulation of IPv6 datagrams within IPv4 packets is indicated by IP protocol number 41. IPv6 can also be encapsulated within UDP packets e.g. in order to cross a router or NAT device that blocks protocol 41 traffic. Other encapsulation schemes, such as used in AYIYA or GRE, are also popular. Conversely, on IPv6-only internet links, when access to IPv4 network facilities are needed, tunneling of IPv4 over IPv6 protocol occurs, using the IPv6 as a link layer for IPv4.

RESULT: Thus the various IP Address Classes and versions were studied.

47

Ex.NO:9

NETWORK CONFIGURATION TOPOLOGY USING HUBS AND SWITCHES

AIM To study & implement network configuration topology using hubs and switches. EQUIPMENTS i. ii. iii. iv. LTS-01 trainer kit 3 computers with WAN=2Kl x p and ethernet post available on them. RI-45 for RI 45 LAN connecting clauses. L-SIM LAN protocol analses and simulator software.

PROCEDURE 1. Connect three or more computer LAN ports using RI-45 to RI-45 LAN connection clauses provided with the systems to LTS start topology ports. 2. Switches on the LTS-01 and computer one should be server and the other should be client. 3. On the server computer select type of topology as STAR select protocol as CDMA-CD click on the create network button. 4. On the server computer select type of network as LAN. 5. Remote computer details will appear on the computer connected in network. Server will be able to see client. 6. Select the server computer details to whom data file is to be transferred from one of the client computer, from one of the client computer from the head between previously stored/selected file information which is to be transmitted. 7. File size will appear in the software windo socket the packet size infer packed delay and click ok. 8. Total packet formed for that fill will be indicated on computer. Some details of file will appear on remote computer to which to be terminated. 9. Click on the file transfer button to transfer file. 10. During the transfer process try to send file to the server from another client computer file transfer from second transmitter will also get completed. 11. When packet from second collides with the first sender. It will be kept on hold till first file transfer get completed. 12. When packets from first sender collides with the first sender it will be indicated as collision packet on server and client. 13. Once the first sender file reached on to the server it displays the transferred and server will show packets starts from the second sender.

48

14. Second sender file trnasfer will also gets completed, and thus collision of two packets transmitted, simultaneously from teo sender it detected and cleared . 15. Close file transfer window and click on protocol analysis button transmitter computer to view details of the log created. 16. Multiple transfer between various server client communication should be performed to deserve throughput is packet size graphics on transmitter computer. 17. Under network analyser window click on plot graph. 18. Calculate throughput and click on plot graph button. 19. Detailed graph of throughput VLS packet SIM will appear on the graph window. 20. This plot can be printed by clicking on print button.

49

RESULT Thus the network configuration topology using hubs and switches was studied.

50

Anda mungkin juga menyukai