Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 91

EX: NO: 1

IP ADDRESS OF LOCAL HOST

AIM: To write a java program to find the IP address of the system. ALGORITHM: STEP1: Start STEP : Declare a variable ip as a static InetAddress STEP!: Using a function get ocal!ost "# to find the address of the s$stem. STEP": Using the function get!ost%ame"# find the s$stem no and print it. STEP#: Using the function get&$%ame"# find the name of an$ other s$stem. STEP$: Displa$ the name STEP%: Stop

PROGRAM: import java.io.'( import java.net.'( class Address ) public InetAddress ip( public static void main"String arg*+#throws Un,nown!ost-.ception ) InetAddress ip/InetAddress.get ocal!ost"#( S$stem.out.println"01n Ip address is 203ip#( String si/ip.get!ost%ame"#( S$stem.out.println/"01n S$stem number is203si#( InetAddress ip4/InetAddress.get&$%ame"0s$s 450#( S$stem.out.println"01n %ame of the other s$stem is203ip#( 6 6

O&TP&T: -217cn1javac Address.java -217cn1java Address Ip address is2 s$s8894:8.4;<.4.88 S$stem number is2 s$s88 %ame of the other s$stem is2s$s4594:8.4;<.4.85

RES&LT: Thus the java program to find the IP address has been coded and e.ecuted successfull$.

EX: NO:

&DP' ONE (A) COMM&NICATION

AIM: To write a java program to implement o*e +ay ,omm-*.,at.o* -s.*/ &DP0

ALGORITHM: SENDER:' STEP1: Import the net pac,age and other pac,ages. STEP : String of argument is passed to the args *+. STEP!: =reate a Datagram soc,et and bind it to the special port specified. STEP": >et the buffer si?e and I@ Address of local host and communication with the client. STEP#: Send the Datagram pac,et to the destination address of given port. STEP$: Store the input in the buffer at the specific location.

RECEI1ER:' STEP1: Import the net pac,age and other pac,ages. STEP : String of argument is passed to the args *+. STEP!: =reate a Datagram soc,et and bind it to the special port specified. STEP": =reate pac,et for receving arra$ of b$tes with ma.imum b$tes. STEP#: Specif$ the common port for connecting datagram soc,et.

PROGRAM: SENDER:' import java.io.'( import java.net.'( class Sender ) DatagramSoc,et ds( Datagram@ac,et dp( b$te buff*+/new b$te*458A+( String strBstr4( boolean i/true( public void send"# throws IC-.ception ) while"i# ) ds/new DatagramSoc,et"#( DataInputStream in/new DataInputStream"S$stem.in#( S$stem.out.println"0-nter the message0#( str/in.read ine"#( buff/str.get&$tes"#( dp/new Datagram@ac,et"buffBbuff.lengthBInetAddress.get ocal!ost"#B<555#( ds.send"dp#( S$stem.out.println"0Do $ou want to continueDEes or %o0#( str4/in.read ine"#( if"str4.eFuals"0Ees0## ) i/true( 6 else ) i/false( 6 6 6 public static void main"String a*+#throws -.ception ) Sender se/new Sender"#( se.send"#( 6 6

RECEI1ER:' import java.io.'( import java.net.'( class Geceiver ) DatagramSoc,et ds( Datagram@ac,et dp( b$te buff*+/new b$te*458H+( String str( public void receiver"# throws IC-.ception ) ds/new DatagramSoc,et"<555#( while"true# ) dp/new Datagram@ac,et"buffBbuff.length#( ds.receive"dp#( str/new String"dp.getData"#B5B5Bdp.get ength"##( S$stem.out.println"str#( S$stem.out.println"0I@ Address203dp.getAddress"##( 6 6 public static void main"String args*+#throws -.ception ) Geceiver re/new Geceiver"#( re.receiver"#( 6 6

O&TP&T: SENDER:' -21cn7javac Sender.java -21cn7java Sender -nter the message2 hi Do $ou want to continueD Ees or %o %o

RECEI1ER: -21cn7javac Geceiver.java -21cn7java Geceiver Iessage received2 hi Ip Address2 94:8.4;<.4.8;

RES&LT: Thus the program implementing &DP'o*e +ay ,omm-*.,at.o* has been successfull$ coded and e.ecuted.

EX0NO: !

TCP' ONE (A) COMM&NICATIONS

AIM: To write a java program to implement o*e +ay ,omm-*.,at.o* -s.*/ TCP0

ALGORITHM: SER1ER:' STEP 1: Start the program. STEP : Import net pac,age and other pac,ages. STEP !: Declare object for ServerSoc,etB Soc,et and @rintStream to transfer data. STEP ": Using @rintStream transfer the data in CutputStream via a port. STEP #: Gun a loop to send data from server until an J-%D or -KITL string is transferred. STEP $: If J-%D or -KITL is encounteredB close the soc,ets and e.it the loop.

CLIENT:' STEP 1: Start the program. STEP : Import net pac,age and other pac,ages. STEP !: Declare object for Soc,et and DataInputStream to receive server data. STEP ": Gun a loop to receive data from server and store it in a string using DataInputStream. STEP #: @rint the string to displa$ the server data and e.it when an J-%D or -KITL message is encountered .

PROGRAM: SER1ER:' import java.io.'( import java.net.'( class Server ) public static void main"String a*+#throws IC-.ception ) Serversoc,et ss/ new ServerSoc,et"<555#( Soc,et s/ss.accept"#( DataInputStream in/ new DataInputStream"S$stem.in#( @rintStream dos/ new @rintStream"s.getCutputStream"##( while"true# ) S$stem.out.println"J-nter the message to send2L#( String str/ in.read ine"#( dos.println"str#( if"str.eFuals"J-%DL## ) ss.close"#( brea,( 6 666 CLIENT:' import java.io.'( import java.net.'( class =lient ) public static void mian"String args*+#throws IC-.ception ) Soc,et s/ new Soc,et"J ocal!ostLB<555#( DataInputStream in/ new DataInputStream"s.getInputStream"##( while"true# ) String str/ in.read ine"#( S$stem.out.println"JIessage Geceived2L3str#( if"str.eFuals"J-%DL# ) s.close"#2 brea,( 6 666

O&TP&T: SER1ER:' -21cn7Server.java -21cn7java Server -nter the message to send2 =omputer networ, -%D

CLIENT:' -21cn7javac =lient.java -21cn7java =lient Iessage Geceived2 =omputer networ, -%D

RES&LT: Thus the java program implementing TCP' o*e +ay ,omm-*.,at.o* has been successfull$ coded and e.ecuted EX: NO: "a IMPLEMENTATION OF ECHO COMMAND

AIM: To write a java program to demonstrate the -=!C command.

ALGORITHM: SER1ER:' STEP1: Start STEP : Import net pac,age and other pac,ages. STEP!: Declare objects for DataInputStreamB soc,et and @rintMriter to receive server and send it bac,. STEP": Store message in a string and print message using print method. STEP#: Send the same received message to server using @rintMriter and Soc,et. STEP$: Mhen received message is -%D then e.it program e.ecution.

CLIENT:' STEP1: Start STEP : Import net pac,age and other necessar$ pac,ages. STEP!: Declare objects from ServerSoc,et and Soc,et. STEP": Declare Cbjects for @rintStream to write message from server to client. STEP#: >et user input and store it in a string. STEP$: Using print method receive client echo message and print it. STEP%: Terminate program when message is sent.

PROGRAM:

ECHO SER1ER:' import java.io.'( import java.net.'( class -choServer ) public static void main"String a*+# ) tr$ ) Soc,et s/null( ServerSoc,et ss/new ServerSoc,et"<555#( s/ss.accept"#( S$stem.out.println"s#( &ufferedGeader br/new &ufferedGeader"new InputStreamGeader"s.getInputStream"###( @rintMriter print/new @rintMriter"s.getCutputStream"##( int i/4( while"i75# ) String str/br.read ine"#( if"str.eFuals"0.0## brea,( S$stem.out.println"0Iesssage received b$ client03str#( print.println"str#( print.flush"#( 6 6 catch"IC-.ception e# ) S$stem.out.print"e#( 6 6 6 ECHO CLIENT:' import java.io.'( import java.net.'( class -cho=lient ) public static void main"String a*+# ) tr$ ) Soc,et s/new Soc,et"0 ocal!ost0B<555#(

DataInputStream in/new DataInputStream"S$stem.in#( &ufferedGeader br4/new &ufferedGeader "new InputStreamGeader"S$stem.in##( &ufferedGeader br8/new &ufferedGeader "new InputStreamGeader"s.getInputStream"###( @rintMriter print/new @rintMriter"s.getCutputStream"##( S$stem.out.println"JIessage to be echoed20#( String str/br4.read ine"#( print.println"str#( print.flush"#( S$stem.out.println"br8.read ine"##( 6 catch"Un,nown!ost-.ception e# ) 6 catch"IC-.ception e# ) S$stem.out.println"0error203e#( 6 6 6

O&TP&T:

ECHO SER1ER:' -21cn7javac -choServer.java -21cn7java -choServer Soc,et*addr/94:8.4;<.4.88B port/45A4B ocalport/<555+ Iessage received b$ client2 hi java.net.Soc,et-.ception2 connection reset

ECHO CLIENT:' -21cn7javac -cho=lient.java -21cn7java -cho=lient Iessage to be echoed2 hi hi

RES&LT: Thus the java program implementing the ECHO ,omma*d has been successfull$ coded and e.ecuted EX: NO: "2 PING COMMAND

AIM: To write a java program to implement the PING ,omma*d. ALGORITHM: STEP 1: Start the program. STEP : Import net and pac,ages. STEP !: Initiali?e the ping server with both soc,ets as null value. STEP ": Start the ServerSoc,et at the clientand give the I@ address of the server. STEP #: The client program is then started b$ starting soc,et. STEP $: At the receiver endB the server is pinged.

PROGRAM:

SER1ER:' import java .io.'( import java.net.'( public class @server ) public static void main"String a*+# ) String line4Bline8( int i( ServerSoc,et ss( DataInputStream di( @rintStream ps( Soc,et soc( ss/null( soc/null( tr$ ) ss/new ServerSoc,et"::::#( 6 catch"-.ception e# ) S$stem.out.print"e#( 6 S$stem.out.println"0@ing server0#( tr$ ) soc/ss.accept"#( di/new DataInputStream"soc.getInputStream"##( ps/new @rintStream"soc.getCutputStream"##( for"i/5(iNA(i33# ) line4/di.read ine"#( S$stem.out.println"0@inged b$ client0#( ps.println"line430repl$ from host2b$tes/H8 timeNms TT /48O0#( 6 di.close"#( ps.close"#( 6 catch"-.ception e# ) S$stem.out.print"e#( 6 66 CLIENT:'

import java.io.'( import java.net.'( public class @client ) public static void main"String a*+# ) @rintMriter out/null( int iBjB,( &ufferedGeader networ,In/null( tr$ ) S$stem.out.print"0-nter I@ Address20#( DataInputStream in/new DataInputStream"S$stem.in#( String ip/in.read ine"#( Soc,et theSoc,et/new Soc,et"ipB::::#( networ,In/new &ufferedGeader"new InputStreamGeader"S$stem.in##( out/new @rintMriter"theSoc,et.getCutputStream"##( S$stem.out.print"0pinging 03ip30 with H8 b$tes of data0#( for"i/5(iNA(i33# ) out.println"ip#( out.flush"#( String inp/networ,In.read ine"#( if"inpP/null# ) for"j/5(jN45555(j33# ) for",/5(,NO5555(,33#)6 6 S$stem.out.println"0Gepl$ from03inp#( 6 else ) for"i/5(iNA(i33# ) for"j/5(jN45555(j33# ) for",/5(,NO5555(,33#)6 S$stem.out.println"01n GeFuested time out0#( 6 6 6 6 6 catch"IC-.ception e#

) for"i/5(iNA(i33# ) for"j/5(jN45555(j33# ) for",/5(,NO5555(,33#)6 6 S$stem.out.println"01n GeFuested time out0#( 6 6 tr$ ) if"networ,InP/null# networ,In.close"#( if"outP/null# out.close"#( 6catch"-.ception e# ) S$stem.out.println"01n GeFuested time out0#( 6 6 6

O&TP&T:

SER1ER:' -21cn7javac @ingServer.java -21cn7java @ingServer @ing server @inged b$ client

CLIENT:' -21cn7javac @ing=lient.java -21cn7java @ing=lient -nter I@ Address2 4;:.8OA.A4.A8

@inging 4;:.8OA.A4.A8 with H8 b$tes of data Gepl$ from 4;:.8OA.A4.A4 Gepl$ from2 b$tes/H8 timeN 4 ms TT /48<

RES&LT: Thus the java program implementing the PING ,omma*d has been successfull$ coded and e.ecuted EX NO: ", IMPLEMENTATION OF TAL3 COMMAND

AIM: To send and receive message from client and server using ,o**e,t.o* or.e*ted ser4.,e. ALGORITHM: SER1ER: STEP1: =reate server and client soc,ets . STEP : Use input streams to get the message from user. STEP!: Use output stream to send message to the client . STEP": Mait for client to displa$ this message and write a new one to be displa$ed b$ the server. STEP#: Displa$ message given at client using input streams read from soc,et. STEP$: If in the message given b$ server or clientB the word JendL is encounteredB e.it both the programs.

CLIENT: STEP1: =reate a client soc,et that connects to the reFuired host and port. STEP : Using input streams read message given b$ server and print it . STEP!: Using input streamsB get message from user to be given to the server. STEP": Use output streams to write message to the server.

PROGRAM:

TAL3SER1ER:' import java.io.'( import java.net.'( public class tal,server ) public static void main"String args*+#throws -.ception ) ServerSoc,et ecsvr/null( String line4Bline8( DataInputStream dis/null( @rintStream pts/null( Soc,et clsc,t/null( &ufferedGeader in4/null( ecsvr/new ServerSoc,et"::::#( S$stem.out.println"0TA Q S-GR-G0#( S$stem.out.println"0SSSSSSSSSSSSSSSSSSSSSS0#( clsc,t/ecsvr.accept"#( dis/new DataInputStream"clsc,t.getInputStream"##( pts/new @rintStream"clsc,t.getCutputStream"##( S$stem.out.println"0%ode successfull$ connected..0#( while"true# ) line4/dis.read ine"#( S$stem.out.println"0Iessage Geceived0#( S$stem.out.println"0The Iessage /03line4#( in4/new &ufferedGeader"new InputStreamGeader"S$stem.in##( line8/in4.read ine"#( if"line8.eFuals"0end0## ) brea,( 6 pts.println"line8#( pts.flush"#( S$stem.out.println"0Iessage sent successfull$0#( 6 dis.close"#( pts.close"#( 6 6

TAL3 CLIENT:'

import java.io.'( import java.net.'( public class tal,client ) public static void main"String args*+# ) @rintMriter out/null( String line4( &ufferedGeader networ,ln/null( tr$ ) Soc,et theSoc,et/new Soc,et"0 ocal!ost0B::::#( networ,ln/new &ufferedGeader"new InputStreamGeader"theSoc,et.getInputStream"###( &ufferedGeader userln/new &ufferedGeader"new InputStreamGeader"S$stem.in##( out/new @rintMriter"theSoc,et.getCutputStream"##( S$stem.out.println"0TA Q = I-%T0#( S$stem.out.println"0SSSSSSSSSSSSSSSSSSSS0#( while"true# ) S$stem.out.println"0send message to server2 0#( String the ine/userln.read ine"#( if"the ine.eFuals"0end0## brea,( out.println"the ine#( out.flush"#( S$stem.out.println"0message sent successfull$0#( S$stem.out.println"0 0#( S$stem.out.println"0message received from tal,server2 03networ,ln.read ine"##( 6 6 catch"IC-.ception e# ) S$stem.err.println"e#( 6 tr$ ) if"networ,lnP/null# networ,ln.close"#( if"outP/null# out.close"#( 6 catch"-.ception e# ) S$stem.err.println"e#( 6 6 6

O&TP&T

TAL3SER1ER =21Documents and Settings1S--%U.G7cd1 =217cd =21@rogram Tiles1Uava1jd,4.;.51bin =21@rogram Tiles1Uava1jd,4.;.51bin7javac tal,server.java =21@rogram Tiles1Uava1jd,4.;.51bin7java tal,server TA Q S-GR-G SSSSSSSSSSSSSSSSSSSSSS %ode successfull$ connected.. Iessage Geceived The Iessage /!AI !I.. Iessage sent successfull$ Iessage Geceived The Iessage /!CM AG- ECU I AI TI%Iessage sent successfull$ Iessage Geceived The Iessage /Q &Eend =21@rogram Tiles1Uava1jd,4.;.51bin7

TAL3CLIENT

=21Documents and Settings1S--%U.G7cd1 =217cd =21@rogram Tiles1Uava1jd,4.;.51bin =21@rogram Tiles1Uava1jd,4.;.51bin7javac tal,client.java =21@rogram Tiles1Uava1jd,4.;.51bin7java tal,client TA Q = I-%T send message to server2 !AI message sent successfull$ message received from tal,server2 !I.. send message to server2 !CM AG- ECU message sent successfull$ message received from tal,server: I AI TI%send message to server2 Q &Emessage sent successfull$ send message to server2 end =21@rogram Tiles1Uava1jd,4.;.51bin7

RES&LT: Thus the java program is e.ecuted and output is verified successfull$.

EX: NO: #

TCP' T(O (A) COMM&NICATION

AIM: To write a java program to implement t+o +ay ,omm-*.,at.o* -s.*/ TCP0

ALGORITHM: SER1ER:' STEP1: Import the net pac,age and other pac,ages. STEP : String of argument is passed to the args *+. STEP!: =reate a new server soc,et and bind it to the port. STEP": Accept the client connection at the reFuested port. STEP#: Cverride the methods of output stream. STEP$: &$ using data input stream a message is received from clientSserver and that message are echoed to client again b$ print stream. STEP%: Mrite message at the soc,et. STEP5: If the read line is J-%DL then close the client connection.

CLIENT:' STEP1: Import the net pac,age and other java pac,ages. STEP : String of argument is passed to the args *+. STEP!: =reate a new soc,et reFuesting for communication with server. STEP": =reate objects for buffered reader V inputs stream.

STEP#: &$ using data input stream a message is received from clientSserver and that

are echoed STEP$: Cverride the methods of input stream. STEP%: Gead the message from the soc,et. STEP5: If the read line is J-%DL then close the client connection.

PROGRAM:

SER1ER:' import java.io.'( import java.net.'( import java.lang.'( class Server ) public static void main"String a*+#throws IC-.ception ) S$stem.out.println"J=onnection -stablishedL#( Serversoc,et ss/ new ServerSoc,et"<555#( Soc,et s/ss.accept"#( @rintStream dos/ new @rintStream"s.getCutputStream"##( DataInputStream in / new DataInputStream"S$stem.in#( DataInputStream inn / new DataInputStream"s.getInputStream"##( while"true# ) S$stem.out.println"J-nter the message to send2L#( String str/ in.read ine"#( dos.println"str#( if"str.eFuals"J-%DL## ) S$stem.out.println"Jconnection closedL#( ss.close"#( brea,( 6 String str4 / inn.read ine"#( S$stem.out.println"JIessage Geceived2L3str4#( if"str4.eFuals"J-%DL## ) S$stem.out.println"Jconnection closedL#( ss.close"#( brea,( 6 6 6 6

CLIENT:'

import java.io.'( import java.net.'( import java.lang.'( class =lient ) public static void mian"String args*+#throws IC-.ception ) S$stem.out.println"J=onnected to serverL#( Soc,et s/ new Soc,et"J ocal!ostLB<555#( DataInputStream in / new DataInputStream"s.getInputStream"##( DataInputStream inn / new DataInputStream"S$stem.in"##( @rintStream dos / new @rintStream"s.getCutputStream"##( while"true# ) String str/ in.read ine"#( S$stem.out.println"JIessage Geceived2L3str#( if"str.eFuals"J-%DL# ) S$stem.out.println"Jconnection closedL#( s.close"#2 brea,( 6 S$stem.out.println"J-nter the message to send2L#( String str4 / inn.read ine"#( dos.println"str4#( if"str4.eFuals"J-%DL## ) S$stem.out.println"Jconnection closedL#( s.close"#( brea,( 66 66

O&TP&T:

SER1ER:' -21cn7javac Server.java -21cn7java Server =onnection -stablished -nter the message2 hi Iessage Geceived2 hi -nter the message2 -%D connection closed CLIENT:' -21cn7javac =lient.java -21cn7java =lient =onnected to server Iessage Geceived2 hi -nter the message to send2 hi Iessage Geceived2 -%D connection closed

RES&LT: Thus the program implementing TCP' t+o +ay ,omm-*.,at.o* has been successfull$ coded and e.ecuted.

EXNO:$

REMOTE COMMAND EXEC&TION

AIM:' To write a java program to perform JRemote Comma*d E6e,-t.o*L. ALGORITHM:S SER1ER:' STEP12 Import the java pac,age and create class GemServer. STEP 2 String of argument is passed to the args *+. STEP!2 =reate a server soc,et object and assign it a port :<. STEP"2 Accept the reFuest from client using accept"#. STEP#2 CutputStream is send to the client using @rintMrite and &ufferedGeader class STEP$2 Ac,nowledge the client that it is read$ ro recieve the data. STEP%2 -nd of main and end of class

CLIENT:' STEP12 Import the java pac,age and create class Gem=lient. STEP 2 String of argument is passed to the args *+. STEP!2 =reate a server soc,et object and assign it a port :< and host name using W get ocal!ost"#. STEP"2 Using the &ufferedGeaderBread the DataStream from the server . STEP#2 Using runtime methodBreturn the current runtime object. STEP$2 -.ecute the program with e.ec"# method function. STEP%2 -nd of main and end of class. PROGRAM:

SER1ER SIDE:' import java.io.'( import java.net.'( public class GemServer ) public static final int port/45( public static void main"String args*+#throws IC-.ception ) ServerSoc,et s/new ServerSoc,et"port#( S$stem.out.println"0Started203s#( Soc,et ser/s.accept"#( S$stem.out.println"0=onnection Accepted203ser#( &ufferedGeader in/new &ufferedGeader"new W InputStreamGeader"ser.getInputStream"###( @rintMriter out/new @rintMriter"new &ufferedMriter"new W CutputStreamMriter"ser.getCutputStream"###Btrue#( S$stem.out.println"0=ommand -.ecuted Successfull$PPP0#( String str/in.read ine"#( out.println"str#( @rocess p/Guntime.getGuntime"#.e.ec"str#( 6 6 CLIENT SIDE:' import java.net.'( import java.io.'( public class Gem=lient ) public static void main"String args*+#throws IC-.ception ) InetAddress adr/InetAddress.get&$%ame"048X.5.5.40#( S$stem.out.println"0Address/03adr#( Soc,et ser/new Soc,et"adrB45#( S$stem.out.println"0Server03ser#( &ufferedGeader in/new &ufferedGeader"new W InputStreamGeader"S$stem.in##( @rintMriter out/new @rintMriter"new &ufferedMriter"new W CutputStreamMriter"ser.getCutputStream"###Btrue#( S$stem.out.print"0-nter A =ommand 20#( String str/in.read ine"#( out.println"str#( S$stem.out.println"0=ommand -.ecuted Successfull$PPP0#( 66 O&TP&T:'

SER1ER O&TP&T:' =21jd,4.H1bin7javac GemServer.java =21jd,4.H1bin7java GemServer Started2ServerSoc,et*addr/5.5.5.595.5.5.5Bport/5Blocalport/45+ =onnection Accepted2Soc,et*addr/localhost948X.5.5.4Bport/44:HBlocalport/45+ =ommand -.ecuted Successfull$PPP =21jd,4.H1bin7

CLIENT O&TP&T:' =21jd,4.H1bin7javac Gem=lient.java =21jd,4.H1bin7java Gem=lient adr/localhost948X.5.5.4 serSoc,et*addr/localhost948X.5.5.4Bport/45Blocalport/44:H+ -nter a command2notepad.e.e =ommand -.ecuted Successfull$PPP =21jd,4.H1bin7

RES&LT: Thus the java program to implement remote ,omma*d e6e,-t.o* was coded and e.ecuted EX: NO: % C)CLIC RED&NDANC) CHEC3

AIM: To write a java program to implement c$clic redundanc$ chec,. ALGORITHM: STEP1: Start the program. STEP : Import .net and other necessar$ pac,ages. STEP!: >et an user input in the form of bit data is string. STEP": >et an generator data from the user . STEP#: Gead the length of the string and convert the data into another format b$ deducing A< from it. STEP$: %ow add the generator data to the original data and send the string as transmitter string. STEP%: In the receiving endB enter the generator code. STEP5: Using the generator codeB to the length of the received stringB add A< to the . number format of the string b$ character STEP7: If the generator string is wrongB displa$ Jmessage received with error.L STEP18: If the generator string is correctB perform step < and displa$ Jmessage received with no error.L STEP11: -nd the program.

PROGRAM: import java.io.'(

import java.lang.'( public class crc ) public static void main"String args*+#throws IC-.ception ) int f*+/new int*8O+( int gen*+/new int*45+( int rem*+/new int*45+( int flenBglenBrlenBiBj( int pBsumBiframeBigenBirem( String data( &ufferedGeader in/new &ufferedGeader"new InputStreamGeader"S$stem.in##( S$stem.out.print"01n-%T-G %-M TGAI- 20#( data/in.read ine"#( flen/data.length"#S4( for"i/5(iNdata.length"#(i33# f*i+/""int#"data.charAt"i###SA<( S$stem.out.print"01n-%T-G T!- >-%-GATCG 20#( data/in.read ine"#( glen/data.length"#S4( for"i/4(iN/glen(i33# f*flen3i+/5( flen/flen3glen( for"i/5(iNdata.length"#(i33# gen*i+/""int#"data.charAt"i###SA<( p/5( sum/5( for"i/flen(i7/5(iSS# ) sum/sum3"f*i+'"int#Iath.pow"8Bp##( p/p34( 6 iframe/sum( p/5( sum/5( for"i/glen(i7/5(iSS# ) sum/sum3"gen*i+'"int#Iath.pow"8Bp##( p/p34( 6 igen/sum(

irem/iframeYigen( irem/igenSirem( iframe3/irem( i/5( while"iframe75# ) f*i+/iframeY8( iframe/iframe98( i33( 6 if"iframe//4# f*i+/iframe( S$stem.out.print"01n1nTGA%SIITT-D STGI%> 20#( for"i/flen(i7/5(iSS# S$stem.out.print"f*i+#( S$stem.out.print"01n1n-%T-G T!- G-=-IR-D STGI%> 20#( data/in.read ine"#( flen/data.length"#S4( for"i/5(iNdata.length"#(i33# f*i+/""int#"data.charAt"i###SA<( p/5( sum/5( for"i/flen(i7/5(iSS# ) sum/sum3"f*i+'"int#Iath.pow"8Bp##( p/p34( 6 iframe/sum( irem/iframeYigen( if"irem//5# S$stem.out.println"01n1tI-SSA>- G-=-IR-D MIT! %C -GGCG0#( else S$stem.out.println"01n1tI-SSA>- G-=-IR-D MIT! -GGCG0#( 6 6 O&TP&T: -%T-G T!- %-M TG-AI45455 -%T-G T!- >-%-GATCG

45454 TGA%SIITT-D STGI%> 45455454 -%T-G T!- G-=-IR-D STGI%> 45454 I-SSA>- G-=-IR-D MIT! %C -GGCG

RES&LT: Thus the java program implementing the process of ,y,9., red-*da*,y ,he,: has been successfull$ coded and e.ecuted. EX: NO: 5 ONE ;IT SLIDING (INDO( PROTOCOL

AIM:

To write a java program to implement the process of o*e 2.t s9.d.*/ +.*do+ <roto,o90 ALGORITHM: SER1ER:' STEP 1: Start the program. STEP : Import net and other pac,ages. STEP !: Declare objects for input9output and Soc,et to receive the frame and send ac,nowledgement STEP ": Mait for the client to establish connection. STEP #: Geceive the frame one b$ one from the soc,et and return the frame number as ac,nowledgement within the thread sleep time STEP $: Send ac,nowledgement for each receiving frame and continue the process until ac,nowledgement for all frames are sent STEP %: Mhen ac,nowledged the last frameB e.it the program. CLIENT:' STEP 1: Start the program. STEP : Import the net and other pac,ages. STEP !: =reate objects for ServerSoc,etB Soc,et to send the frames. STEP ": Dispa$ the server address when the server is connected. STEP #: >et the number of frames to be sent from the user. STEP $: Send the first frame to serevr using the soc,et. STEP %2 Mhen one frame is sentB wait for the ac,nowledgementfrom the receiver for the previous frame. STEP 5: Ia,e use of Thread.Sleep"# method to pause the sending of frame until ac,nowledgement is received. STEP 7: Mhen the ac,nowledgement is receivedB send the ne.t frame.

STEP 18: =ontinue the process till all the specified number of frames are sent and ac,nowledgement is received STEP 11: Mhen all the frames are sent and ac,nowledgement is received e.it the program.

PROGRAM: SER1ER:' import java.lang.s$stem( import java.net.'(

import java.io.'( class Server4 ) public static void main"String args*+# ) tr$ ) &uferedInputStream in( ServerSoc,et ss / new ServerSoc,et"O555#( S$stem.out.println"JMaiting for connectionL#( Soc,et client / ss.accept"#( S$stem.out.println"JGeceived reFuest for sending framesL#( in / new &ufferedInputStream"client.getInputStream"##( DataCutputStream out/ new DataCutputStream"client.getCutputStream"##( int p/ in.read"#( S$stem.out.println"JSendingL#( for"int i/4( iN/p( 33i# ) S$stem.out.println"JSending frame no2L3i#( out.write"i#( out.flush"#( S$stem.out.println"Jwaiting for ac,nowledgeZL#( Thread.sleep"O555#( int a/ in.read"#( S$stem.out.println"JGeceived ac,nowledge for frame no23i3LasL 3a#( 6 out.flush"#( in.close"#2 out.close"#( client.close"#( ss.close"#( S$stem.out.println"J[uiting..L#( 6catch"IC-.ception e# ) S$stem.out.println"e#(6 catch"Interrupted-.ception e#)6 6 6 CLIENT:' import java.lang.'( Import java.net.'( import java.io.'(

import java.math.'( class =lient4 ) public static void main"String *+args# ) tr$ ) InetAddress addr / InetAddress.get&$%ame"J ocal!ostL#( S$stem.out.println"addr#( Soc,et connection/ new Soc,et"addrBO555#( DataCutputStream out/ new DataCutputStream"connection.getCutputStream"##( &ufferedInputStream in / new &ufferedInputStream"connection.getInputStream"##( &ufferedInputStream inn/ new &ufferedInputStream"connection.getInputStream"##( &ufferedGeader ,i/ new &ufferedGeader"new InputStreamGeader"S$stem.in##( int flag /5( S$stem.out.println"JconnectedZL#( S$stem.out.println"J-nter no. of frames to reFuested to server2L#( int c/ Integer.parseInt",i.read ine"##( out.write"c#( out.flush"#( int iB jj/5( while"jjNc# ) i/ in.read"#( S$stem.out.println"JGeceived frame no2L3i#( S$stem.out.println"JSending ac,nowledgement for frame no2L3i#( out.write"i#( out.flush"#( jj33( 6 out.flush"#( in.close"#2 inn.close"#( out.close"#( connection.close"#( S$stem.out.println"J[uiting..L#( 6 catch"-.ception e# ) S$stem.out.println"e#( 6 6 6 O&TP&T: SER1ER:' -21cn7javac Server4.java

-21cn7 java Server4 Maiting for connection Geceived reFuest for sending frames Sending Sending frame no24 Maiting for ac,nowledgeZ Geceived ac,nowledge for frame no24 as 4 [uitting.. CLIENT:' -21cn7javac =lient4.java -21cn7 java =lient4 ocal!ost =onnectedZ -nter the no. of frames to reFuested to server2 4 Geceived frame no24 Sending ac,nowledgment for frame no24 [uittingZ. RES&LT: Thus the java program implementing the O*e 2.t s9.d.*/ +.*do+ <roto,o9 has been successfull$ coded and e.ecuted.

EX0NO0 7

IMPLEMENTATION OF FTP

AIM:

To write a java program to implement FTP -s.*/ TCP.

ALGORITHM: SER1ER:' STEP1: Start the program. STEP : Import net and other pac,ages. STEP!: Declare object for ServerSoc,et and Soc,et to send a file. STEP": Declare objects for TileCutputStream to write into a file. STEP#: >et the filename from the user an dt$pe the file using TileCutputStream"# conent. CLIENT:' STEP1: Start the program. STEP : Import net and other pac,ages. STEP!: Declare objects for Server and TileInputStream to write the server file into server STEP": Using the InputStream method receive the filename and print the received file name STEP#: =reate a new client file using TileInputStream and write the contents of the server file into it using TileCutputSream . STEP $: Mhile writingB read the source file as characters and write into the other file. STEP %: -nd the program after writing into the client file.

PROGRAM: FILE SER1ER:' import java.net.'( import java.io.'(

class TileServer ) public static void main"String args*+# throws IC-.ception ) &ufferedGeader br new &ufferedGeader"new InputStreamGeader"S$stem.in##( ServerSoc,et ss/ new ServerSoc,et"4545#( Soc,et s/ ss.accept"#( @rintStream ps/ new @rintStream"s.getCutputStream"##( S$stem.out.println"J-nter the file name2L#( String fname/ br.read ine"#( TileCutputStream fos/ new TileCutputStream"fname33.t.tLBtrue#( &ufferedCutputStream bos/ new &ufferedCutputStream"fosB 85A<#( char msg( while ""msg/"char#br.read"##P/\# ) fos.write"msg#( 6 ps.print"fname#( fos.close"#( bos.close"#( ps.close"#( s.close"#( ss.close"#( 6 6 FILE CLIENT:' import java.net.'( import java.io.'( class Tile=lient ) public static void main"String args*+# throws IC-.ception ) tr$ ) Soc,et s / new Soc,et"J ocal!ostLB4545#( &ufferedGeader br/ new &ufferedGeader"new InputStreamGeader"s.getInputStream"###( &ufferedGeader br4/ new &ufferedGeader"new InputStreamGeader"S$stem.in##( String msg/ br.read ine"#( S$stem.out.println"JGeceived file2L3msg#( TileInputStream fis / new TileInputStream"msg3L.t.tL#( &ufferedInputStream bis / new &ufferedInputStream"fis#( S$stem.out.println"J-nter the new file name2L#( String fname/ br4.read ine"#(

TileCutputStream fos / new TileCutputStream"fname3L.t.tL#( &ufferedCutputStream bos/ new &ufferedCutputStream"fosB85A<#( int msg4( while""msg4/bis.read"5#P/S4# fos.write""char#msg4#( s.close"#( 6 catch"e.ception e#)e.printStac,Trace"#(6 6 6

O&TP&T: FILE SER1ER:' -21cn7javac TileServer.java

-21cn7java TileServer -nter the filename2 Tile =omputer networ, \

FILE CLIENT:' -21cn7javac Tile=lient.java -21cn7java Tile=lient Geceived file2 Tile -nter the new file name2 Tile4

RES&LT: Thus the java program implementing TT@ using T=@ has been successfull$ coded and e.ecuted. EXNO: 18a AIM:' To write a java program to perform JT+o (ay Comm-*.,at.o* &s.*/ TCP=IPL. ALGORITHM:S T(O (A) COMM&NICATION &SING TCP=IP

SER1ER:' STEP12 Import the java pac,age and create class TwoServerT=@. STEP 2 String of argument is passed to the args *+. STEP!2 =reate a new server soc,et and bind it to the port. STEP"2 Accept the client connection at the reFuested port. STEP#2 Cverride the methods of output stream . STEP$2 &$ using data input stream a message is received from clientSserver andW that message are echoed to client again b$ print stream. STEP%2 Mrite message at the soc,et. STEP52 If the read line is J-.itL then close the client connection. STEP72 -nd of main. STEP182 -nd of TwoServerT=@ class.

CLIENT:' STEP12 Import the java pac,age and create class Two=lientT=@. STEP 2 String of argument is passed to the args *+. STEP!2 =reate a new soc,et reFuesting for communication with server. STEP"2 =reate objects for buffered reader V inputs stream. STEP#2 &$ using data input stream a message is received from clientSserver andW that message are echoed to client again b$ print stream. STEP$2 Cverride the methods of input stream. STEP%2 Gead the message from the soc,et. STEP52 -nd of main . STEP72 -nd of Two=lientT=@ class.

SER1ER SIDE:' import java.net.'( import java.io.'( class TwoServerT=@ ) public static void main"String args*+#throws IC-.ception ) Tr$ ) ServerSoc,et ss/new ServerSoc,et";5#( Soc,et sc( S$stem.out.println"0Maiting Tor =lient...0#( sc/ss.accept"#( &ufferedGeader in/new &ufferedGeader"new W InputStreamGeader"sc.getInputStream"###( @rintMriter out/new @rintMriter"sc.getCutputStream"#Btrue#( &ufferedGeader stdin/new &ufferedGeader"new W InputStreamGeader"S$stem.in##( String aBb( S$stem.out.println"0=onnected To =lient...03sc#( while"true# ) S$stem.out.print"0-nter The Iessage Tor =lient20#( a/stdin.read ine"#( if"a.eFuals"0-.it0## brea,( out.flush"#( out.println"a#( b/in.read ine"#( S$stem.out.print"0=lient Sa$s203b#( 6 sc.close"#( 6 catch"-.ception e# ) S$stem.out.println"0-rror03e#( 6 66

CLIENT SIDE:' import java.io.'( import java.net.'( class Two=lientT=@ ) public static void main"String args*+#throws IC-.ception ) tr$ ) Soc,et sc( if"args.lengthP/4# sc /new Soc,et"0 ocal!ost0B;5#( else sc/new Soc,et"0SEST-I0B;5#( &ufferedGeader in/new &ufferedGeader"new W InputStreamGeader"sc.getInputStream"###( @rintMriter out/new @rintMriter"sc.getCutputStream"#Btrue#( &ufferedGeader stdin/new &ufferedGeader"new S InputStreamGeader"S$stem.in##( String aBb( S$stem.out.println"0Maiting Tor Server...0#( S$stem.out.println"0=onnected To Server...03sc#( b/in.read ine"#( S$stem.out.println"0Server Sa$s203b#( while"true# ) S$stem.out.println"0-nter The Iessage Tor Server20#( a/stdin.read ine"#( if"a.eFuals"0-.it0## brea,( out.println"a#( b/in.read ine"#( S$stem.out.print"0Server Sa$s203b#( 6 sc.close"#( 6 catch"-.ception e# ) S$stem.out.println"0-rror03e#( 6 6

O&TP&T:' SER1ER O&TP&T:' =21jd,4.H1bin7javac TwoServerT=@.java =21jd,4.H1bin7java TwoServerT=@ Maiting Tor =lient... =onnected To =lient... Soc,et*addr/localhost948X.5.5.4Bport/HO5:Blocalport/;5+ -nter The Iessage Tor =lient2!ai =lient Sa$s2!ai...!ow Are UD -nter The Iessage Tor =lient2Ea Tine... =lient Sa$s2null -nter The Iessage Tor =lient2-.it =21jd,4.H1bin7 CLIENT O&TP&T:' =21jd,4.H1bin7javac Two=lientT=@.java =21jd,4.H1bin7java Two=lientT=@ Maiting Tor Server... =onnected To Server... Soc,et*addr/ ocal!ost948X.5.5.4Bport/;5Blocalport/HO5:+ Server Sa$s2!ai -nter The Iessage Tor Server2!ai...!ow Are UD Server Sa$s2Ea Tine... -nter The Iessage Tor Server2-.it =21jd,4.H1bin7

RES&LT:' Thus the program has been e.ecuted and the output is verified successfull$.

EX: NO: 182

T(O (A) COMM&NICATION' &DP

AIM: To write a java program to implement t+o +ay ,omm-*.,at.o* -s.*/ &DP0

ALGORITHM: SER1ER:' STEP1: Import the net and other pac,ages. STEP : String of argument is passed to the args *+. STEP!: =reate a Datagram soc,et and bind it to the special port specified. STEP": >et the buffer si?e and I@ Address of local host and communication with the client. STEP#: Send the Datagram pac,et to the destination address of given port. STEP$: Store the input in the buffer at the specific location.

CLIENT:' STEP1: Import the net pac,age and other pac,ages. STEP : String of argument is passed to the args *+. STEP!: =reate a Datagram soc,et and bind it to the special port specified. STEP": =reate pac,et for receving arra$ of b$tes with ma.imum b$tes. STEP#: Specif$ the common port for connecting datagram soc,et.

PROGRAM: SENDER:' import java.io.'( import java.net.'( class Sender ) public static void main "String a*+#throws -.ception ) while"true# ) DatagramSoc,et ds / new DatagramSoc,et"#( &ufferedGeader br / new &ufferedGeader"new InputStreamGeader"S$stem.in##( S$stem.out.println"0-nter the message20#( String msg/br.read ine"#( b$te b*+/msg.get&$tes"#( InetAddress add/InetAddress.get ocal!ost"#( Datagram@ac,et dp/new Datagram@ac,et"bBb.lengthBaddB48HA#( ds.send"dp#( if"msg.eFuals"0-KIT0## S$stem.e.it"5#( b$te b4*+/new b$te*8OO+( Datagram@ac,et dp4/new Datagram@ac,et"b4Bb4.length#( ds.receive"dp4#( String msg4/new String"dp4.getData"##( S$stem.out.println"0Geceived message203msg4#( 6 6 6 RECEI1ER:' import java.io.'( import java.net.'( class Geceiver ) public static void main"String a*+#throws IC-.ception ) DatagramSoc,et ds/new DatagramSoc,et"48HA#( b$te b*+/new b$te*8OO+( while"true# ) Datagram@ac,et dp/new Datagram@ac,et"bBb.length#( ds.receive"dp#(

String msg/new String"dp.getData"##( S$stem.out.println"0Iessage Geceived203msg#( InetAddress add/dp.getAddress"#( int port/dp.get@ort"#( S$stem.out.println"0-nter the message to send20#( &ufferedGeader br/new &ufferedGeader"new InputStreamGeader"S$stem.in##( String msg4/br.read ine"#( b$te b4*+/msg4.get&$tes"#( Datagram@ac,et dp4/new Datagram@ac,et"b4Bb4.lengthBaddBport#( ds.send"dp4#( if"msg4.eFuals"0-KIT0## S$stem.e.it"5#( 6 6 6

O&TP&T: SENDER:' -21cn7javac Sender.java -21cn7java Sender -nter the message2 hi Geceived message2 hi -nter the message2 -KIT

RECEI1ER:' -21cn7javac receiver.java -21cn7java Geceiver Iessage Geceived2 hi -nter the message to send2 hi Iessage Geceived2 -KIT

RES&LT: Thus the java program implementing UD@ > t+o +ay ,omm-*.,at.o* has been successfull$ coded and e.ecuted.

EX0NO:11

REMOTE METHOD IN1OCATION

AIM: To write a java program to implement remote method .*4o,at.o* ?rm.@0

ALGORITHM: STEP 1: Start STEP : -stablish the connection between the client and the server to calculate factorial operation STEP !: In imple"# it calls the inter"# which throws e.ception thrown b$ fact"#. STEP ": In the client UG has been specified and declared as String. STEP #: It calls the inter"# to connect with the imple"# and getthe result. STEP $: Stop.

PROGRAM: RMI SER1ER:' import java.rmi.'( import java.net.'( import java.io.'( public class server ) public static void main"String args*+#throws -.ception ) imple c/new imple"#( java.rmi.%aming.rebind"0server0Bc#( S$stem.out.println"0S-GR-G G-ADE...0#( 6 6 RMI CLIENT:' import java.rmi.'( import java.net.'( import java.io.'( public class client ) public static void main"String args*+#throws -.ception ) &ufferedGeader br/new &ufferedGeader"new InputStreamGeader"S$stem.in##( inter s/"inter#java.rmi.%aming.loo,up"0rmi299 ocal!ost9server0#( S$stem.out.println"0-nter a %o 2 0#( int n/Integer.parseInt"br.read ine"##( s.fact"n#( 6 6 RMI IMPLEMENT:' import java.rmi.'( import java.net.'( import java.rmi.server.'( public class imple e.tends java.rmi.server.UnicastGemoteCbject implements inter ) public imple"#throws java.rmi.Gemote-.ception )

6 public void fact"int n#throws java.rmi.Gemote-.ception ) int f/4( for"int i/4(iN/n(i33# f/f'i( S$stem.out.println"0Tactorial of 03n30is 2 03f#( 6 6 RMI INTERFACE:' import java.rmi.'( public interface inter e.tends java.rmi.Gemote ) public void fact"int n#throws java.rmi.Gemote-.ception( 6

O&TP&T: SER1ER:' =217javac inter.java =217jaavc imple.java =217javac server.java =21 7rmic imple =217start rmiregistr$ =217java Server S-GR-G G-ADEZ Tactorial of O is 485

CLIENT:' =217javac client.java =217java client -nter a no2 O

RES&LT: Thus the java program implementing remote method .*4o,at.o* has been successfull$ coded and e.ecuted.

EX: NO: 1

SHORTEST PATH RO&TING ALGORITHM

AIM: To write a java program to implement shortest path routing algorithm.

ALGORITHM: STEP1: Import the java pac,age and create class spath. STEP : String of argument is passed to the args *+. STEP!: Gead the distance b9w pair of nodes. STEP": If e.itsB then get the source and destination node. STEP#: Trom the source nodeB find the possible path and record. STEP$: Ta,e the smallest path among these path repeat the process till the W destination is reached. STEP%: -nd of main. STEP5: -nd spath class.

PROGRAM: import java.net.'( import java.io.'( class spath ) public static void main"String args*+#throws IC-.ception ) int nBsBdBiBjB$/5Bsd/455( int*+ in/new int*45+( int*+*+ m/new int*O+*O+( int*+ dis/new int*45+( int*+ path/new int*45+( DataInputStream a/new DataInputStream"S$stem.in#( S$stem.out.print"0-%T-G T!- %UI&-G CT R-GT-K 2 0#( n/Integer.parseInt"a.read ine"##( S$stem.out.print"0-%T-G T!- SCUG=- R-GT-K 2 0#( s/Integer.parseInt"a.read ine"##( S$stem.out.print"0-%T-G T!- D-STI%ATIC% R-GT-K 2 0#( d/Integer.parseInt"a.read ine"##( for"i/4(iNn(i33# ) j/4( while"jNn# ) S$stem.out.print"0-%T-G T!- DISTA%=- &-TM--% 03i30 A%D 03"j34#302 0#( m*i+*j34+/Integer.parseInt"a.read ine"##( m*j34+*i+/m*i+*j34+( j33( 6 6 for"i/4(iN/n(i33# ) in*i+/5( dis*i+/m*s+*i+( if"m*s+*i+P/5# path*i+/s( 6 in*s+/4( dis*s+/5( for"i/8(iNn(i33# ) for"j/4(jN/n(j33# ) if"in*j+//5# )

if"dis*j+Nsd# ) sd/dis*j+( $/j( 6 6 6 in*$+/4( for"j/4(jN/n(j33# ) if""in*j+//5#VV"m*$+*j+P/5## ) if""dis*$+3m*$+*j+#Ndis*j+# ) dis*j+/dis*$+3m*$+*j+( path*j+/$( 6 6 6 6 S$stem.out.print"003d30NSSSS0#( i/d( while"path*i+P/s# ) S$stem.out.print"003path*i+30NSSSS0#( i/path*i+( 6 S$stem.out.print"003s#( S$stem.out.print"01nDISTA%=- IS 203dis*d+#( 6 6

O&TP&T: -21cn7javac Short@ath.java -21cn7java Short@ath -nter The %o.Cf Rertices2A -nter The =ost Cf Iatri.2S Mhether -dges -.ist &9M 4 And 8 *4SEesB5S%o+. 4 -nter The Meight Tor -dge 4 To 8 O Mhether -dges -.ist &9M 4 And H *4SEesB5S%o+. 5 Mhether -dges -.ist &9M 4 And A *4SEesB5S%o+. 4 -nter The Meight Tor -dge 4 To A A Mhether -dges -.ist &9M 8 And 4 *4SEesB5S%o+. 4 -nter The Meight Tor -dge 8 To 4 X Mhether -dges -.ist &9M 8 And H *4SEesB5S%o+. 5 Mhether -dges -.ist &9M 8 And A *4SEesB5S%o+. 4 -nter The Meight Tor -dge 8 To A 8 Mhether -dges -.ist &9M H And 4 *4SEesB5S%o+. 5 Mhether -dges -.ist &9M H And 8 *4SEesB5S%o+. 4

-nter The Meight Tor -dge H To 8 H Mhether -dges -.ist &9M H And A *4SEesB5S%o+. 5 Mhether -dges -.ist &9M A And 4 *4SEesB5S%o+. 5 Mhether -dges -.ist &9M A And 8 *4SEesB5S%o+. 5 Mhether -dges -.ist &9M A And H *4SEesB5S%o+. 4 -nter The Meight Tor -dge A To H 4 -nter The Source Rerte.24 The Q Ralue Is2A 5 4 A 4 The Q Ralue Is28 5 4 A 4 The Q Ralue Is2H 5 4 A 4 @ath*4+/5 Distance*4+/5

@ath*8+/4 Distance*8+/O @ath*H+/A Distance*H+/O @ath*A+/4 Distance*A+/A The Shortest @ath Trom 4 To 8 Is... 4S78 The Shortest @ath Trom 4 To H Is... 4S7AS7H The Shortest @ath Trom 4 To A Is... 4S7A

RES&LT: Thus the java program implementing the shortest <ath ro-t.*/ a9/or.thm has been successfull$ coded and e.ecuted .

EX: NO: 1!a

;ROADCASTING

AIM: To write a java program to implement the process of 2road,ast.*/.

ALGORITHM: SER1ER:' STEP1: Start the program. STEP : Import the net and other pac,ages. STEP !: The DatagramSoc,et and the DataInputstream are initiali?ed. STEP ": The buffer is declared for message. STEP #: The message is obtained from the user. STEP $: The message is delivered to the client one b$ one with the help of the Datagram@ac,et. STEP %: The client details is obtained STEP%: @ac,ets are then sent to the reciver b$ the help od Datagram soc,et. STEP5: If message is b$e then the server Fuits. CLIENT:' STEP1: Start the program. STEP : Import net and other pac,age. STEP!: The DatagramSoc,et and Datagram@ac,et are initiali?ed. STEP": The message from sender is ta,en as the pac,etfrom buffer. STEP#: The message is displa$ed along with the I@ address of the server. STEP$: If the message isb$e then the client Fuits.

PROGRAM: SER1ER:' import java.io.'( import java.net.'( public class &roadServer ) public static void main"String args*+# throws -.ception ) DatagramSoc,et ds / new DatagramSoc,et"#( DataInputStream dis / new DataInputStream"S$stem.in#( String msg/ 00( String client / 00( b$te*+ buf / new b$te*458A+( while"true# ) S$stem.out.println"0Server0#( msg/ dis.read ine"#( buf/ msg.get&$tes"#( for"int i/4( iN/45( i33# ) tr$ ) client / "0s$sL3i#( Datagram@ac,et dp/ new Datagram@ac,et "bufBbuf.lengthB InetAddress.get&$%ame"client#BO555#( ds.send"dp#( S$stem.out.println"0Iessage Sent To2 03client#( 6 catch"-.ception e# ) S$stem.out.println"0Unable To =onnect At...03client3e#( 6 if"msg.eFualsIgnore=ase"0&$e0## ) S$stem.out.println"0Server [uits0#( return( 6 6 6 6 6

CLIENT:' import java.net.'( import java.io.'( public class &road=lient ) public static void main"String args*+#throws -.ception ) DatagramSoc,et ds/ new DatagramSoc,et"O555#( while"true# ) tr$ ) b$te*+ buf/new b$te*458A+( DataInputStream dis/ new DataInputStream"S$stem.in#( String msg/ null( Datagram@ac,et dp/ new Datagram@ac,et"bufBbuf.length#( ds.receive"dp#( msg/new String"dp.getData"#B5Bdp.get ength"##( InetAddress ia/dp.getAddress"#( S$stem.out.println"0Trom2 03ia30 Iessage2 03msg#( if"msg.eFualsIgnore=ase"0&$e0## ) S$stem.out.println"0=lient [uits0#( return( 6 6 catch"-.ception e# ) S$stem.out.println"J-rrorL3e#( 6 6 6 6

O&TP&T: SER1ER:' -21cn7javac &roadServer.java -21cn7java &roadServer Server2 hai Iessage successfull$ sent to =lient2 s$s4 Unable To =onnect at2 s$s8java.net.Un,nown!ost-.ception2 s$s82 s$s8 Unable To =onnect at2 s$sHjava.net.Un,nown!ost-.ception2 s$sH2 s$sH Unable To =onnect at2 s$sAjava.net.Un,nown!ost-.ception2 s$sA2 s$sA Unable To =onnect at2 s$sOjava.net.Un,nown!ost-.ception2 s$sO2 s$sO Unable To =onnect at2 s$s;java.net.Un,nown!ost-.ception2 s$s;2 s$s; Unable To =onnect at2 s$sXjava.net.Un,nown!ost-.ception2 s$sX2 s$sX Unable To =onnect at2 s$s<java.net.Un,nown!ost-.ception2 s$s<2 s$s< Unable To =onnect at2 s$s:java.net.Un,nown!ost-.ception2 s$s:2 s$s: Unable To =onnect at2 s$s845java.net.Un,nown!ost-.ception2 s$s452 s$s45 Server 2 -.ception in thread JmainL java.lng.%ull@ointer-.ception At &roadSender.main"&roadSender.java24;#

-21cn7
CLIENT:' -21cn7javac &road=lient.java -21cn7java &road=lient

-21cn7

OTHER: -21cn7 javac &road=lient.java -21cn7java &road=lient Trom2 94;:.8OA.A4.A8 Iessage2 hai

-21cn7 javac &road=lient.java -21cn7java &road=lient Server2 -21cn7

RES&LT: Thus the java program implementing the process of 2road,ast.*/ has been successfull$ coded and e.ecuted.

EXNO: 1!2 AIM:'

M&LTICASTING

To write a java program to perform JM-9t.,ast.*/L. ALGORITHM:S

SER1ER:'
STEP12 Import the java pac,age and create class IultiServer. STEP 2 String of argument is passed to the args *+. STEP!2 Tirst we enable the soc,et object for multicasting soc,et. STEP"2 Using the soc,et objectBwe join the multicast group using the host name. STEP#2 Cnce we join the group the message is read from the server and it is send to the client. STEP$2 Similarl$ the soc,et object to recive the message from client side is enabled and using the get data methodBwe recive the pac,ets through the given port. STEP%2 Mhen it reaches J&$eL it Fuits from the group. STEP52 -nd of main . STEP72 -nd of IultiServer class.

CLIENT:' STEP12 Import the java pac,age and create class Iulti=lient. STEP 2 String of argument is passed to the args *+. STEP!2 !ere using the soc,et we join the multicast group. STEP"2 Using the Datagram pac,ets object Bwe read the message b$ string in W buffered arra$ . STEP#2 Similarl$ b$ using read ine method input got from client as b$te. STEP$2 The message is passed using the soc,et object using read method in the W enabled port. STEP%2 -nd of main. STEP52 -nd of &road=lient class.

SER1ER SIDE:' import java.net.'( import java.io.'( class IultiServer ) public static void main"String args*+#throws -.ception ) IulticastSoc,et soc,et( Datagram@ac,et pac,et( String msgBmsg4Bmsg8( b$te*+ buf/new b$te*O555+( DataInputStream one/new DataInputStream"S$stem.in#( soc,et/new IulticastSoc,et"#( soc,et.join>roup"InetAddress.get&$%ame"088A.5.5.40##( S$stem.out.println"01n1n ocalI@2 03InetAddress.get ocal!ost"##( while"true# ) S$stem.out.println"0Iessage !ere20#( msg4/one.read ine"#( msg8/ InetAddress.get ocal!ost"#.toString"#( msg/msg430030Trom Server03msg8( buf/msg.get&$tes"#( pac,et/ new Datagram@ac,et"bufBbuf.lengthBInetAddress.get&$%ame"04;:.8OA.8A5.<0#BAAAO#( soc,et.send"pac,et#( if"msg4.eFualsIgnore=ase"0&$e0## ) S$stem.out.println"0Server [uits0#( return( 6 pac,et / null( msg/null( buf/new b$te*4555+( pac,et/new Datagram@ac,et"bufBbuf.length#( soc,et.receive"pac,et#( msg/new String"pac,et.getData"#B5Bpac,et.get ength"##( S$stem.out.println"0Iessage2 03msg#( 6 66

CLIENT SIDE:' import java.io.'( import java.net.'( class Iulti=lient ) public static void main"String args*+#throws -.ception ) IulticastSoc,et soc,et/new IulticastSoc,et"AAAO#( soc,et.join>roup"InetAddress.get&$%ame"088A.5.5.40##( String msgBmsg4Bmsg8( DataInputStream one/new DataInputStream"S$stem.in#( b$te*+ buf/new b$te*4O55+( S$stem.out.println"0 ocal I@2 03InetAddress.get ocal!ost"##( while"true# ) Datagram@ac,et pac,et/new Datagram@ac,et"bufBbuf.length#( soc,et.receive"pac,et#( msg/new String"pac,et.getData"#B5Bpac,et.get ength"##( S$stem.out.println"0Iessage2 03msg#( int c/45( char c4*+/new char*c+( msg.get=hars"5BHBc4B5#( String temp/0 0( for"int i/5(iNH(i33# ) temp/temp3c4*i+( 6 if"temp.eFualsIgnore=ase"0&$e0## ) S$stem.out.println"0=lient [uits0#( return( 6 msg/null( buf/new b$te*4555+( S$stem.out.println"0Iessage2 0#( msg4/one.read ine"#( msg8/InetAddress.get ocal!ost"#.toString"#( msg/msg430 030Trom =lient2 03msg8( buf/msg.get&$tes"#( InetAddress address/pac,et.getAddress"#( int port/pac,et.get@ort"#( pac,et/new Datagram@ac,et"bufBbuf.lengthBaddressBport#( soc,et.send"pac,et#( 666

O&TP&T:' SER1ER O&TP&T:' =21jd,4.H1bin7javac IultiServer.java =21jd,4.H1bin7java IultiServer ocalI@ 2 G>=-TS= A&94:8.4;<.4.45 Iessage !ere... Melcome To @udu=herr$.... Iessage2&ut The =limate Is Rer$ !ot....Trom The =lient2 G>=-TS= A&9S 4:8.4;<.4.45 Iessage !ere... &$e Server [uits =21jd,4.H1bin7 CLIENT O&TP&T:' =21jd,4.H1bin7javac Iulti=lient.java =21jd,4.H1bin7java Iulti=lient ocalI@ 2 G>=-TS= A&94:8.4;<.4.45 Iessage !ere... Iessage2 Melcome To @udu=herr$...Trom The Server G>=-TS= A&9S 4:8.4;<.4.45 Iessage !ere... &ut The =limate Is Rer$ !ot... Iessage2 &$e Trom The =lient 2 G>=-TS= A&94:8.4;<.4.45 Iessage !ere... &$e =21jd,4.H1bin7

RES&LT:' Thus the program has been e.ecuted and the output is verified successfull$ EX NO: 1" IMPLEMENTATION OF ADDRESS RESOL&TION PROTOCOL

AIM: To write a java program to implement Address Reso9-t.o* Proto,o9. ALGORITHM: CLIENT SIDE: STEP1: -stablish a connection between the =lient and Server. Soc,et ss/new Soc,et"InetAddress.get ocal!ost"#B4455#( STEP : =reate instance output stream writer .@rintMriter ps/new @rintMriter"s.getCutputStream"#Btrue#( STEP!: >et the I@ Address to resolve its ph$sical address. STEP": Send the I@Address to its output Stream.ps.println"ip#( STEP#: @rint the @h$sical Address received from the server.

SER1ER SIDE: STEP12 Accept the connection reFuest b$ the client. ServerSoc,et ss/new ServerSoc,et"8555#( Soc,et s/ss.accept"#( STEP 2 >et the I@address from its inputstream.&ufferedGeader br4/new &ufferedGeader"new InputStreamGeader"s.getInputStream"###( ip/br4.read ine"#( STEP!2 During runtime e.ecute the process Guntime r/Guntime.getGuntime"#( @rocess p/r.e.ec"0arp Sa 03ip); STEP": Send the @h$sical Address to the client.

PROGRAM:

ARP CLIENT import java.io.'( import java.net.'( class Arp=lient ) public static void main"String args*+#throws IC-.ception ) tr$ ) Soc,et ss/new Soc,et"InetAddress.get ocal!ost"#B4455#( @rintStream ps/new @rintStream"ss.getCutputStream"##( &ufferedGeader br/new &ufferedGeader"new InputStreamGeader"S$stem.in##( String ip( S$stem.out.println"0-nter the I@ADDG-SS20#( ip/br.read ine"#( ps.println"ip#( String strBdata( &ufferedGeader br8/new &ufferedGeader"new InputStreamGeader"ss.getInputStream"###( S$stem.out.println"0AG@ Trom Server220#( do ) str/br8.read ine"#( S$stem.out.println"str#( 6while"P"str.eFualsIgnore=ase"0end0###( 6 catch"IC-.ception e# ) S$stem.out.println"0-rror03e#( 6 6 6 ARP SER1ER import java.io.'( import java.net.'( class ArpServer ) public static void main"String args*+#throws IC-.ception ) tr$ ) ServerSoc,et ss/new ServerSoc,et"4455#( Soc,et s/ss.accept"#( @rintStream ps/new @rintStream"s.getCutputStream"##(

&ufferedGeader br4/new &ufferedGeader"new InputStreamGeader"s.getInputStream"###( String ip( ip/br4.read ine"#( Guntime r/Guntime.getGuntime"#( @rocess p/r.e.ec"0arp Sa 03ip#( &ufferedGeader br8/new &ufferedGeader"new InputStreamGeader"p.getInputStream"###( String str( while""str/br8.read ine"##P/null# ) ps.println"str#( 6 6 catch"IC-.ception e# ) S$stem.out.println"0-rror03e#( 6 66

O&TP&T

=21%etwor,ing @rograms7java ArpServer =21%etwor,ing @rograms7java Arp=lient -nter the I@ADDG-SS2 4:8.4;<.44.O< AG@ Trom Server22 Interface2 4:8.4;<.44.OX on Interface 5.455555H Internet Address 4:8.4;<.44.O< @h$sical Address 55S4AS<OS;XS44S<A T$pe d$namic

RES&LT: Thus the .m<9eme*tat.o* of ARP is done V e.ecuted successfull$.

EX0NO:1# AIM:

CR)PTOGRAPH)

To write a java program to implement the ,9.e*t ser4er ,ry<to/ra<hy0 ALGORITHM: SER1ER: STEP1: Start the program . STEP : Import .net and other necessar$ pac,ages. STEP!: Declare objects for Soc,etBServerSoc,et and @rintStream to transfer the encr$pted string . STEP": Initiali?e string variables to null. STEP#: >et an integer value form the user as ,e$ and a string from the user. STEP$: Gead the string in character to integer and add the ,e$ value to displa$ it as a encr$pted string. STEP%: =onvert each character to integer and the ,e$ value to displa$ it as a encr$pted string. STEP5: Send the encr$pted string and ,e$ value to the client using @rintStream a Soc,et STEP7: After sending the string and ,e$ e.it the program. CLIENT: STEP1: Start the program STEP : Import .net and other necessar$ pac,ages. STEP!: Declare objects for Soc,et and InputStream to receive the string and ,e$ from server.

STEP": Store the string and the ,e$ to different variabls. STEP#: Gead the string character wise to its length. STEP$: GeFuest the user to enter the ,e$ for decr$ption. STEP%: =ompare the ,e$ with received ,e$. STEP5: If both the ,e$s are eFual thenB =onvert the each character of the string to integer and deduce the ,e$ value. =onvert the integer value to character and form it into a string and displa$ the decr$pted string. -lse @rint the message as cannot decr$ptB wrong message and Fuit. STEP7: -nd the program.

PROGRAM:

SER1ER: import java.io.'( import java.net.'( class eser ) public static void main"String args*+# throws -.ception ) tr$ ) ServerSoc,et ss/new ServerSoc,et":555#( Soc,et s/ss.accept"#( @rintStream ps/new @rintStream"s.getCutputStream"##( &ufferedGeader br/new &ufferedGeader"new InputStreamGeader"S$stem.in##( int i/5B,( String s8/0 0( S$stem.out.println"01n -%T-G A STGI%>20#( String s4/br.read ine"#( S$stem.out.print"01n -%T-G T!- Q-E20#( ,/Integer.parseInt"br.read ine"##( while"iNs4.length"## ) char c4/s4.charAt"i33#( int n/"int#c43,34( c4/"char#n( s83/c4( 6 S$stem.out.println"0-%=GE@T-D STGI%> IS203s8#( ps.println"s8#( ps.println",#( ps.close"#( s.close"#( ss.close"#( 6 catch"-.ception e# ) S$stem.out.println"01n -GGCG203e#( 6 6 6

CLIENT:

import java.io.'( import java.net.'( class ecli ) public static void main"String args*+# throws -.ception ) Soc,et s/new Soc,et"0 ocal!ost0B:555#( &ufferedGeader br/new &ufferedGeader"new InputStreamGeader"s.getInputStream"###( int i/5B,4( &ufferedGeader br4/new &ufferedGeader"new InputStreamGeader"S$stem.in##( String sH/0 0( String s8/br.read ine"#( int ,/Integer.parseInt"br.read ine"##( S$stem.out.println"0G-=-IR-D IS>203s8#( S$stem.out.println"01n -%T-G T!- Q-E20#( ,4/Integer.parseInt"br4.read ine"##( if",//,4# ) while"iNs8.length"## ) char c4/s8.charAt"i33#( int n/"int#c4S,4S4( c4/"char#n( sH3/c4( 6 S$stem.out.println"0D-=GE@T-D STGI%> IS203sH#( s.close"#( 6 6 6

O&TP&T: SER1ER: =21jd,4.H1bin7java eser -%T-G A STGI%>2the server -%T-G T!- Q-E2A -%=GE@T-D STGI%> IS2 $mjY.jw)jw CLIENT: =21jd,4.H1bin7java ecli G-=-IR-D IS>2 $mjY.jw)jw -%T-G T!- Q-E2A D-=GE@T-D STGI%> IS2 ]the server

RES&LT: Thus the java program implementing the process of ,ry<to/ra<hy has been successfull$ coded and e.ecuted. EX0NO:1$ ST&D) OF IEEE 58 0! PROTOCOL

AIM: To stud$ the IEEE 58 0! Proto,o9.

IEEE 58 0! Proto,o9: The I---S<58.H @rotocol is based on the Kero. %etwor, Standard "K%S# called -thernet. -thernet protocols refer to the famil$ of localSarea networ, " A%# covered b$ the I--- <58.H. In the -thernet standardB there are two modes of operation2 halfSduple. and fullSduple. modes. In the half duple. modeB data are transmitted using the popular =arrierSSense Iultiple Access9=ollision Detection "=SIA9=D# protocol on a shared medium. The main disadvantages of the halfSduple. are the efficienc$ and distance limitationB in which the lin, distance is limited b$ the minimum IA= frame si?e. This restriction reduces the efficienc$ drasticall$ for highSrate transmission. ThereforeB the carrier e.tension techniFue is used to ensure the minimum frame si?e of O48 b$tes in >igabit -thernet to achieve a reasonable lin, distance. The -thernet s$stem consists of three basic elements2 4. the ph$sical medium used to carr$ -thernet signals between computersB 8. a set of medium access control rules embedded in each -thernet interface that allow multiple computers to fairl$ arbitrate access to the shared -thernet channelB and H. an -thernet frame that consists of a standardi?ed set of bits used to carr$ data over the s$stem. As with all I--- <58 protocolsB the ISC data lin, la$er is divided into two I--- <58 sub la$ersB the Iedia Access =ontrol "IA=# sub la$er and the IA=Sclient sub la$er. The I--- <58.H ph$sical la$er corresponds to the ISC ph$sical la$er. The IA= subSla$er has two primar$ responsibilities2
Data

encapsulationB including frame assembl$ before transmissionB and frame parsing9error detection during and after reception Iedia access controlB including initiation of frame transmission and recover$ from transmission failure The IA=Sclient subSla$er ma$ be one of the following2 ogical in, =ontrol " =#B which provides the interface between the -thernet IA= and the upper la$ers in the protocol stac, of the end station. The = sub la$er is defined b$ I--- <58.8 standards. &ridge entit$B which provides A%StoS A% interfaces between A%s that use the same protocol "for e.ampleB -thernet to -thernet# and also between different protocols "for e.ampleB -thernet to To,en Ging#. &ridge entities are defined b$ I--- <58.4 standards.

-ach -thernetSeFuipped computer operates independentl$ of all other stations on the networ,2 there is no central controller. All stations attached to an -thernet are connected to a shared signaling s$stemB also called the medium. To send data a station first listens to the channelB and when the channel is idle the station transmits its data in the form of an -thernet frameB or pac,et. After each frame transmissionB all stations on the networ, must contend eFuall$ for the ne.t frame transmission opportunit$. Access to the shared channel is determined b$ the medium access control "IA=# mechanism embedded in the -thernet interface located in each station. The medium access control mechanism is based on a s$stem called =arrier Sense Iultiple Access with =ollision Detection "=SIA9=D#. As each -thernet frame is sent onto the shared signal channelB all -thernet interfaces loo, at the destination address. If the destination address of the frame matches with the interface addressB the frame will be read entirel$ and be delivered to the networ,ing software running on that computer. All other networ, interfaces will stop reading the frame when the$ discover that the destination address does not match their own address. Mhen it comes to how signals flow over the set of media segments that ma,e up an -thernet s$stemB it helps to understand the topolog$ of the s$stem. The signal topolog$ of the -thernet is also ,nown as the logical topolog$B to distinguish it from the actual ph$sical la$out of the media cables. The logical topolog$ of an -thernet provides a single channel "or bus# that carries -thernet signals to all stations. Ma6.m-m Tra*sfer Rate: The Ia.imum Data Transfer Gate for I--- <58.H is 45 Ibps "45B555B555 bits per second of data#. In factB data transfer is dependent on how man$ users are fighting for the busSSand how fast the user^s data can get on the bus. Tour data rates are currentl$ defined for operation over optical fiber and twistedSpair cables2
45 Ibps S 45&aseST -thernet "I--- <58.H# 455 Ibps S Tast -thernet "I--- <58.Hu# 4555

Ibps S >igabit -thernet "I--- <58.H?# S 45 >bps -thernet "I--- <58.Hae#.

45S>igabit

Proto,o9 Str-,t-re ' Ether*et: The basic I--- <58.H -thernet IA= Data Trame for 459455Ibps -thernet2 T=S

@reamble

"@G-#S X b$tes. The @G- is an alternating pattern of ones and ?eros that tells receiving stations that a frame is comingB and that provides a means to s$nchroni?e the frameSreception portions of receiving ph$sical la$ers with the incoming bit stream. StartSofSframe delimiter "STD#S 4 b$te. The SCT is an alternating pattern of ones and ?erosB ending with two consecutive 4Sbits indicating that the ne.t bit is the leftSmost bit in the leftSmost b$te of the destination address.
Destination Source

address "DA#S ; b$tes. The DA field identifies which station"s# should receive the frame. addresses "SA#S ; b$tes. The SA field identifies the sending station.

ength9T$peS 8 b$tes. This field indicates either the number of IA=Sclient data b$tes that are contained in the data field of the frameB or the frame t$pe ID if the frame is assembled using an optional format. Is a seFuence of n b$tes "A;/N n /N4O55# of an$ value. "The total frame minimum is ;Ab$tes.# chec, seFuence "T=S#S A b$tes. This seFuence contains a H8Sbit c$clic redundanc$ chec, "=G=# valueB which is created b$ the sending IA= and is recalculated b$ the receiving IA= to chec, for damaged frames.

DataS

Trame

Note: Iultiple -thernet segments can be lin,ed together to form a larger -thernet A% using a signal amplif$ing and retiming device called a repeater. Through the use of repeatersB a given -thernet s$stem of multiple segments can grow as a 0nonSrooted branching tree.0 _`%onSrooted0 means that the resulting s$stem of lin,ed segments ma$ grow in an$ directionB and does not have a specific root segment. Iost importantl$B segments must never be connected in a loop. -ver$ segment in the s$stem must have two endsB since the -thernet s$stem will not operate correctl$ in the presence of loop paths.

-ven though the media segments ma$ be ph$sicall$ connected in a star patternB with multiple segments attached to a repeaterB the logical topolog$ is still that of a single -thernet channel that carries signals to all stations

EX0NO:1%: ST&D) OF 3E) DISTRI;&TION AND CERTIFICATION SCHEMES

AIM: To stud$ the ,e$ d.str.2-t.o* a*d ,ert.f.,at.o* s,hemes

3E) DISTRI;&TION AND CERTIFICATION2 @ublic ,e$ encr$ption has its own difficultiesB in particular the problem of obtaining someone^s true public ,e$. &oth of these problemsSSdetermining a shared ,e$ for s$mmetric ,e$ cr$ptograph$ and securel$ obtaining the public ,e$ for public ,e$ cr$ptograph$SScan be solved using atr-sted .*termed.ary0 Tor s$mmetric ,e$ cr$ptograph$B the trusted intermediar$ is called a :ey d.str.2-t.o* ,e*ter "QD=#B which is a singleB trusted networ, entit$ with whom one has established a shared secret ,e$. Me will see that one can use the QD= to obtain the shared ,e$s needed to communicate securel$ with all other networ, entitiesB avoiding some of the pitfalls we uncovered in. Tor public ,e$ cr$ptograph$B the trusted intermediar$ is called a ,ert.f.,at.o* a-thor.ty ?CA@0 A certification authorit$ certifies that a public ,e$ belongs to a particular entit$ "a person or a networ, entit$#. Tor a certified public ,e$B if one can safel$ trust the =A that certified the ,e$B then one can be sure about to whom the public ,e$ belongs. Cnce a public ,e$ is certifiedB then it can be distributed from just about an$whereB including a public ,e$ serverB a personal Meb pageB or a dis,ette.

THE 3E) DISTRI;&TION CENTER: Suppose once again that &ob and Alice want to communicate using s$mmetric ,e$ cr$ptograph$. The$ have never met "perhaps the$ just met in an online chat room# and thus have not established a shared secret ,e$ in advance. !ow can the$ now agree on a secret ,e$B given that the$ can communicate with each other onl$ over the networ,D A solution often adopted in practice is to use a trusted ,e$ distribution center. The QD= is a server that shares a different secret s$mmetric ,e$ with each registered user. This ,e$ might be manuall$ installed at the server when a user first registers. The QD= ,nows the secret ,e$ of each userB and each user can communicate securel$ with the QD= using this ,e$. et^s see how ,nowledge of this one ,e$ allows a user to securel$ obtain a ,e$ for communicating with an$ other registered user. Suppose that Alice and &ob are users of the QD=(

the$ onl$ ,now their individual ,e$B KA-KDC and KB-KDCB respectivel$B for communicating securel$ with the QD=.

4. Using KA-KDC to encr$pt her communication with the QD=B Alice sends a message to the QD= sa$ing she "A# wants to communicate with &ob "B#. Me denote this messageB KAKDC"ABB#. 8. The QD=B ,nowing KA-KDCB decr$pts KA-KDC"ABB#. The QD= then generates a random numberB R1. This is the shared ,e$ value that Alice and &ob will use to perform s$mmetric encr$ption when the$ communicate with each other. This ,e$ is referred to as a o*e't.me sess.o* :eyA as Alice and &ob will use this ,e$ for onl$ this one session that the$ are currentl$ setting up. The QD= now needs to inform Alice and &ob of the value of R1. The QD= thus sends bac, a message to AliceB encr$pted using KASKDCB containing the following2

R1B the oneStime session ,e$ that Alice and &ob will use to communicate. A pair of values2 AB and R1B encr$pted b$ the QD= using &ob^s ,e$B KBSKDC. Me denote this KBSKDC"ABR1#. It is important to note that QD= is sending Alice not onl$ the value of R1 for her own useB but also an encr$pted version of R1 and Alice^s nameB encr$pted using &ob^s ,e$. Alice can^t decr$pt this pair of values in the message "she doesn^t ,now &ob^s encr$ption ,e$#B but then she doesn^t reall$ need to. Me^ll see shortl$ that Alice will simpl$ forward this encr$pted pair of values to &ob "who can decr$pt them#. These items are put into a message and encr$pted using Alice^s shared ,e$. The message from the QD= to Alice is thusKASKDC"R1BKBSKDC"R1##.

H. Alice receives the message from the QD=B e.tracts R1 from the message and saves it. Alice now ,nows the oneStime session ,e$B R1. Alice also e.tracts KBSKDC"ABR1# and forwards this to &ob. A. &ob decr$pts the received messageB KBSKDC"ABR1#B using KBSKDCand e.tracts A and R1. &ob now ,nows the oneStime session ,e$B R1B and the person with whom he is sharing this ,e$B A. Cf courseB he ta,es care to authenticate Alice using R1 before proceeding an$ further. P&;LIC 3E) CERTIFICATION: Cne of the principle features of public ,e$ encr$ption is that it is possible for two entities to e.change secret messages without having to e.change secret ,e$s. Tor e.ampleB when Alice wants to send a secret message to &obB she simpl$ encr$pts the message with &ob^s public ,e$ and sends the encr$pted message to &ob( she doesn^t need to ,now &ob^s secret "that isB private#

,e$B nor does &ob need to ,now her secret ,e$. ThusB public ,e$ cr$ptograph$ obviates the need for QD= infrastructureB such as Qerberos. Cf courseB with public ,e$ encr$ptionB the communicating entities still have to e.change public ,e$s. A user can ma,e its public ,e$ publicl$ available in man$ wa$sB for e.ampleB b$ posting the ,e$ on the user^s personal Meb pageB placing the ,e$ in a public ,e$ serverB or b$ sending the ,e$ to a correspondent b$ eSmail. A Meb commerce site can place its public ,e$ on its server in a manner such that browsers automaticall$ download the public ,e$ when connecting to the site. Gouters can place their public ,e$s on public ,e$ serversB thereb$ allowing other networ, entities to retrieve them. &inding a public ,e$ to a particular entit$ is t$picall$ done b$ a ,ert.f.,at.o* a-thor.ty "=A#B whose job it is to validate identities and issue certificates. A =A has the following roles2
1. A =A verifies that an entit$ "a personB a routerB and so on# is who it sa$s it is. There are

no mandated procedures for how certification is done. Mhen dealing with a =AB one must trust the =A to have performed a suitabl$ rigorous identit$ verification. Tor e.ampleB if Trud$ were able to wal, into the Tl$Sb$S%ight certificate authorit$ and simpl$ announce 0I am Alice0 and receive certificates associated with the identit$ of 0AliceB0 then one shouldn^t put much faith in public ,e$s certified b$ the Tl$Sb$S%ight certificate authorit$. Cn the other handB one might "or might notP# be more willing to trust a =A that is part of a federalSSor stateSSsponsored program "for e.ampleB *Utah 4:::+#. Cne can trust the 0identit$0 associated with a public ,e$ onl$ to the e.tent that one can trust a =A and its identit$Sverification techniFues. Mhat a tangled web of trust we spinP 8. Cnce the =A verifies the identit$ of the entit$B the =A creates a ,ert.f.,ate that binds the public ,e$ of the identit$ to the identit$. The certificate contains the public ,e$ and globall$ uniFue identif$ing information about the owner of the public ,e$ "for e.ampleB a human name or an I@ address#. The certificate is digitall$ signed b$ the =A.
3.

et us now see how certificates can be used to combat pi??aSordering pran,stersB li,e Trud$B and other undesirables. Mhen Alice receives &ob^s orderB she gets &ob^s certificateB which ma$ be on his Meb pageB in an eSmail messageB or in a certificate server. Alice uses the =A^s public ,e$ to verif$ that the public ,e$ in the certificate is indeed &ob^s. If we assume that the public ,e$ of the =A itself is ,nown to all "for e.ampleB it could be published in a trustedB publicB and wellS,nown placeB such as The New York Times, so that it is ,nown to all and cannot be spoofed#B then Alice can be sure that she is indeed dealing with &ob. Illustrates the steps involved in =ASmediated public ,e$ encr$ption. standards for certification authorities. ITU K.O5: *ITU 4::H+ specifies an authentication service as well as a specific s$nta. for certificates. GT= 4A88 describes =ASbased ,e$ management for use with secure Internet eSmail. It is compatible with K.O5: but goes be$ond K.O5: b$ establishing procedures and conventions for a ,e$ management architecture. Table describes some of the important fields in a certificate.

4. &oth the International Telecommunication Union "ITU# and the I-TT have developed

Selected fields in a K.O5: and GT= 4A88 public ,e$ certificate F.e9d Name Rersion Serial %umber Signature Issuer %ame Ralidit$ @eriod Subject %ame Subject Qe$ Des,r.<t.o* Rersion number of K.O5: specification =ASissued uniFue identifier for a certificate Specifies the algorithm used b$ =A to 0sign0 this certificate Identit$ of =A issuing this certificateB in soScalled Distinguished %ame"D%# *GT= 88OH+ format Start and end of period of validit$ for certificate Identit$ of entit$ whose public ,e$ is associated with this certificateB in D% format

@ublic The subject^s public ,e$ as well as an indication of the public ,e$ algorithm "and algorithm parameters# to be used with this ,e$

RES&LT: Thus :ey d.str.2-t.o* a*d ,ert.f.,at.o* s,hemes were studied successfull$.

You might also like