Ex No:1 (I) Program Using TCP Sockets Date and Time Server Date: Aim
Ex No:1 (I) Program Using TCP Sockets Date and Time Server Date: Aim
Ex No:1 (I) Program Using TCP Sockets Date and Time Server Date: Aim
String line#
*ataInputStream is,null0is1,null#
PrintStream os,null#
Socket c,null#
try
$
s,ne/ ServerSocket&DDDD)#
8
catch&I749ception e)
$
System.out.println&e)#
8
try
$
c,s.accept&)#
is,ne/ *ataInputStream&c.getInputStream&))#
is1,ne/ *ataInputStream&System.in)#
os,ne/ PrintStream&c.get7utputStream&))#
do
$
line,is.read-ine&)#
System.out.println&3Client536line)#
System.out.println&3Server53)#
line,is1.read-ine&)#
os.println&line)#
8/hile&line.eIualsIgnoreCase&3Iuit3),,false)#
is.close&)#
os.close&)#
8
catch&I749ception e)
$
System.out.println&e)#
8
8
8
TCP,-ie.t1*+a)a
import java.net."#
import java.io."#
pu%lic class TCPclient1
$
pu%lic static void main&String arg'()
$
Socket c,null#
String line#
*ataInputStream is0is1#
PrintStream os#
!
try
$
c,ne/ Socket&312.2.222.3E30DDDD)#
8
catch&I749ception e)
$
System.out.println&e)#
8
try
$
os,ne/ PrintStream&c.get7utputStream&))#
is,ne/ *ataInputStream&System.in)#
is1,ne/ *ataInputStream&c.getInputStream&))#
do
$
System.out.println&3Client53)#
line,is.read-ine&)#
os.println&line)#
System.out.println&3Server53 6 is1.read-ine&))#
8/hile&line.eIualsIgnoreCase&3Iuit3),,false)#
is1.close&)#
os.close&)#
8
catch&I749ception e)
$
System.out.println&3Socket ClosedJ=essage Passing is over3)#
8
8
E
OUT PUT:
Server
C5?Program @iles?Aava?jdk1.!.2?%inBjavac TCPserver1.java
;ote5 TCPserver1.java uses or overrides a deprecated +PI.
;ote5 >ecompile /ith Cdeprecation for details.
C5?Program @iles?Aava?jdk1.!.2?%inBjava TCPserver1
Client5 .ai Server
Server5
.ai Client
Client5 .o/ are you
Server5
@ine
Client5 Iuit
Server5
Kuit
C-ie.t
C5?Program @iles?Aava?jdk1.!.2?%inBjavac TCPclient1.java
;ote5 TCPclient1.java uses or overrides a deprecated +PI.
;ote5 >ecompile /ith Cdeprecation for details.
C5?Program @iles?Aava?jdk1.!.2?%inBjava TCPclient1
Client5
.ai Server
Server5 .ai Client
Client5
.o/ are you
Server5 @ine
Client5
Iuit
Server5 Iuit
G
RESULT:
Thus the a%ove program a clientCserver application for chat using TCP H IP /as e9ecuted and
successfully
Ex No:1 (iii) PROGRAM USING TCP SOCKETS
IMPLEMENTATION OF TCP/IP ECHO
Date:
AIM:
To implementation of echo client server using TCPHIP.
ALGORITHM:
Ste 1: start the program
Ste !: Include necessary package in java
Ste ": To create a socket in client to server.
Ste #: The client esta%lishes a connection to the server.
Ste $: The client accept the connection and send data to server and the server to replay the
echo message to the client
Ste %: The client communicate the server to send the end of the message
Ste &: Stop the program.
PROGRAM:
ESe()e(*+a)a
import java.net."#
import java.io."#
pu%lic class 4Server
$
pu%lic static void main&String args'()
$
ServerSocket s,null#
String line#
*ataInputStream is#
PrintStream ps#
Socket c,null#
try
$
s,ne/ ServerSocket&D222)#
8
catch&I749ception e)
$
System.out.println&e)#
8
1
try
$
c,s.accept&)#
is,ne/ *ataInputStream&c.getInputStream&))#
ps,ne/ PrintStream&c.get7utputStream&))#
/hile&true)
$
line,is.read-ine&)#
ps.println&line)#
8
8
catch&I749ception e)
$
System.out.println&e)#
8 88
EC-ie.t*+a)a
import java.net."#
import java.io."#
pu%lic class 4Client
$
pu%lic static void main&String arg'()
$
Socket c,null#
String line#
*ataInputStream is0is1#
PrintStream os#
try
$
c,ne/ Socket&312.2.222.330D222)#
8
catch&I749ception e)
$
System.out.println&e)#
8
try
$
os,ne/ PrintStream&c.get7utputStream&))#
is,ne/ *ataInputStream&System.in)#
is1,ne/ *ataInputStream&c.getInputStream&))#
/hile&true)
$
System.out.println&3Client53)#
line,is.read-ine&)#
os.println&line)#
System.out.println&3Server53 6 is1.read-ine&))#
8
8
D
catch&I749ception e)
$
System.out.println&3Socket ClosedJ3)#
8
8
8
OUTPUT:
Server
C5?Program @iles?Aava?jdk1.!.2?%inBjavac 4Server.java
;ote5 4Server.java uses or overrides a deprecated +PI.
;ote5 >ecompile /ith Cdeprecation for details.
C5?Program @iles?Aava?jdk1.!.2?%inBjava 4Server
C5?Program @iles?Aava?jdk1.!.2?%inB
Client
C5?Program @iles?Aava?jdk1.!.2?%inBjavac 4Client.java
;ote5 4Client.java uses or overrides a deprecated +PI.
;ote5 >ecompile /ith Cdeprecation for details.
C5?Program @iles?Aava?jdk1.!.2?%inBjava 4Client
Client5
.ai Server
Server5.ai Server
Client5
.ello
Server5.ello
Client5
end
Server5end
Client5
ds
Socket ClosedJ
12
RESULT:
Thus the a%ove program a simple echo clientCserver application for using TCP H IP /as
e9ecuted and successfully.
AIM:
To /rite a java program to implement Lser *atagram Protocol &L*P).
ALGORITHM:
Server:
Ste 1: Start the program.
Ste !: Create a socket /ith reIuired sender and receiver port addresses.
Ste ": Send and receive data.
Ste #: Close the connection.
Ste $: Stop the program.
Client
Ste 1: Start the program.
Ste !: Create a socket /ith reIuired sender and receiver port addresses.
Ste ": Send and receive data.
Ste #: Close connection.
Ste $: Stop the program.
PROGRAM:
import java.net."#
import java.io."#
class udp
$
pu%lic static void main&String args'()
$
try
$
String s10s20host#
Muffered>eader in,ne/ Muffered>eader&ne/ InputStream>eader&System.in))#
System.out.println&34nter the port no. for source N destination3)#
s1,in.read-ine&)#
s2,in.read-ine&)#
System.out.println&34nter the hostname of the dest.3)#
host,in.read-ine&)#
System.out.println&3Type e9it to Iuit the connection3)#
*atagramSocket ds,ne/ *atagramSocket&Integer.parseInt&s1))#
ne/ sender&ds0s20host)#
11
Ex No:! (i) PROGRAMS USING UDP SOCKETS
PROGRAM FOR SIMPLE UDP
Date:
ne/ receive&ds)#
8
catch&49ception e)$8
8
8
class sender e9tends Thread
$
*atagramSocket ds#
%yte data'(,ne/ %yte'122(#
int i,20port#
String host#
sender&*atagramSocket d10String str0String host1)
$
ds,d1#
port,Integer.parseInt&str)#
host,host1#
start&)#
8
pu%lic void run&)
$
/hile&true)
$
try
$
data'i66(,&%yte)System.in.read&)#
if&data'iC1(,,O?nO)
$
ds.send&ne/ *atagramPacket&data0iC10Inet+ddress.getMy;ame&host)0port))#
if&ne/ String&data020iC2).eIuals&349it3))
$
System.out.println&3<our /rite mode on e9it3)#
%reak#
8
i,2# 88
catch&49ception e)$8
888
class receive e9tends Thread
$
*atagramSocket ds#
%yte data'(,ne/ %yte'122(#
receive&*atagramSocket d1)
$
ds,d1#
start&)#
8
pu%lic void run&)
$ /hile&true) $
try
12
$
*atagramPacket dp,ne/ *atagramPacket&data0data.length)#
ds.receive&dp)#
System.out.println&ne/ String&dp.get*ata&)020dp.get-ength&)))#
if&ne/ String&dp.get*ata&)020dp.get-ength&)).eIuals&349it3))
$
System.out.println&3<our >ead mode on e9it3)#
%reak#
8 8
catch&49ception tr)$8
888
OUTPUT:
Se()e(
C5?jdk1.3?%inBjava udp
4nter the port no. for source N destination
2222
3222
4nter the hostname of the dest.
localhost
Type e9it to Iuit the connection
hello
/elcome
to
all
C-ie.t
C5?jdk1.3?%inBjava udp
4nter the port no. for source N destination
3222
2222
4nter the hostname of the dest.
localhost
Type e9it to Iuit the connection
hello
/elcome
to
all
13
RESULT:
The codes are compiled and the output is o%tained successfully.
AIM:
To /rite a java program to implement domain name system.
ALGORITHM:
Ste 1: Start the program.
Ste !: Include the header files.
Ste ": *eclare the varia%les and assign the values.
Ste #: In try selection declare the runtime and process.
Ste $: Input the domain name of domain name system.
Ste %: >eturn the IP address of corresponding domain name to the reIuested client
from
domain name server.
Ste &: Stop the program.
PROGRAM:
import java.net.Inet+ddress#
import java.net.Inet+ddress#
import java.io."#
class Simple*;S $
pu%lic static void main&String'( args) $
String host;ame#
if & args.length J, 1 ) $
System.out.println&3Lsage5 java Simple*;S host;ame3)#
System.e9it&1)#
8
host;ame , args'2(#
try $
Inet+ddress address , Inet+ddress.getMy;ame&host;ame)#
%yte ip'( , address.get+ddress&)#
for &int octet,2# octet P ip.length# octet66) $
System.out.print& &&int)ip'octet( N 29ff) 6 3 3 )#
1
Ex No:! (ii) PROGRAMS USING UDP SOCKETS
IMPLEMENTATION OF DOMAIN NAME S0STEM (DNS)
Date:
8
System.out.println&)#
8 catch &I749ception *;Serror) $
System.err.println&*;Serror)#
System.e9it&1)#
8
8
8
OUTPUT:
C5?jdk1.3?%inBjava Simple*;S localhost
12G 2 2 1
1!
RESULT:
The codes are compiled and the output is o%tained successfully.
AIM:
To implement Socket Creation
ALGORITHM:
Ste1: Start the program
Ste!: *eclare t/o integers socket fd10fd2
Ste": *efine sockfd socket /hich transmit data as stream of %ytes.
Ste#: *efine sockfd2 as socket /hich transmit data as datagram
Ste$: If socket fd is C1 then display socket 1 is not created
Ste%: If sockfd2 is C1 then display socket 2 is not created else o%tain file descriptor
Ste&: Stop the Program
PROGRAM:
QincludePstdio.hB
QincludePstdli%.hB
QincludePsysHsocket.hB
QincludePnetinetHin.hB
QincludeParpaHinet.hB
QincludePunistd.hB
$
printf&R?n Socket CreationS)#
int sockfd10sockfd2#
sockfd1,socket&+@TI;4T0S7CUTST>4+=02)#
sockfd2,socket&+@TI;4T0S7CUTST>4+=02)#
if&sockfd1,,C1)
$
printf&S?nSocket is not createdS)#
8
4lse
$
prints&R?nSocket1 is not createdS)#
printf&R?n socket1 file descriptor is R Vd0sockfd1)#
1E
Ex No:" (i)
PROGRAMS USING RA1 SOCKETS
IMPLEMENTATION OF PACKET CAPTURING
Date:
8
if&sockfd2,,C1)
$
printf&R?n cokcet1 is not createdS)#
8
4lse
$
printf&R?n socket is createdS)#
printf&R?n socket2 file descriptor is 5Vd0sockfd2)#
8
8
OUTPUT
SOCKET CREATION:
Socket1 is createdSocket1
file descriptor is 53
Socket2 is created
Socket2 file descriptor is 53
1G
RESULT:
The codes are compiled and the output is o%tained successfully.
AIM:
To implement Socket Minding
ALGORITHM:
Ste1: Start the program
Ste!: *efine the portno glo%ally as 2222
Ste": *eclare the initial varia%le sockfd1
Ste#: *efine the structure for %oth client and server
Ste$: If sockfd is transmitted as stream of %ytes it is eIual to C1 then display R 4rror =essageS
Ste%: Lsing the mem%er fun access the structure value such assinTfamily0sinTport0sinTaddr
Ste&: If siWe of %ind value is not C1 then display socket %ounded portno else display Minderror
Ste2: Stop the Program.
PROGRAM:
QincludePstdio.hB
QincludePstdli%.hB
QincludePsysHsocket.hB
QincludePnetinetHin.hB
QincludeParpaHinet.hB
QincludePunistd.hB
Qdefi%e P7>T;7 2222
int main&)
$
printf&R?n Socket MindingS)#
int sockfd0i,P7>T;7#
struct sockaddrTin myaddr#
if&&sockfd,socket&+@TI;4T0S7CUTST>4+=02)),,C1)
$
printf&R?n socket creation error)#
8
11
Ex No:" (ii)
PROGRAMS USING RA1 SOCKETS
IMPLEMENTATION OF SOCKET 3INDING/FILTERING
Date:
myaddr.sinTfamily,+@T;4T#myaddr.sinTport,htone&P7>T;7)
#myaddr.sinTaddr.sTaddr,I;+**>T+;<#
memset&N&myaddr.sinTWero0X?2X01))#
if&%ind&sockfd0&struct sockaddr")Nmytaddr0siWeof&myaddr))J,C1)
$
printf&R?nsocket is %inded to port num%er VdS0i)#
8
4lse
$
printf&R?n %inding errorS)#
8
8
OUTPUT:
Socket %inding
Socket %ounded to port num%er 2222
1D
RESULT:
Thus Socket has %een created successfully
Ex No:#
IMPLEMENTATION OF REMOTE PROCEDURE CALL
Date:
AIM:
To /rite java program using >PC application /ith interface class and implementation
class.
ALGORITHM:
Ste 1: Start the program.
Ste !: Create an interface class and declare all the rmi applications.
Ste ": Create an implementation class.
Ste #: In implementation class declare0 the rmi application /ith the operation to %e
Performed on the varia%les.
Ste $: Create a server calculation class and using re%ind method get the naming of the
local host.
Ste %: Create a class calculator client0 and then using the %oth up method get the rmi
local host.
Ste &: Print the add0 su%0 mul0 div method.
Ste 2: Stop the program.
PROGRAM:
INTERFACE
import java.rmi."#
pu%lic interface >eceive=essageInterface e9tends >emote
$
void receive=essage&String 9) thro/s >emote49ception#
8
CLIENT
22
import java.rmi."#
import java.rmi.registry."#
import java.net."#
pu%lic class >miClient
$
static pu%lic void main&String args'()
$
>eceive=essageInterface rmiServer#
>egistry registry#
String server+ddress,args'2(#
String serverPort,args'1(#
String te9t,args'2(#
System.out.println&3sending 36te9t63 to 36server+ddress63536serverPort)#
try$
HH get the RregistryS
registry,-ocate>egistry.get>egistry&
server+ddress0
&ne/ Integer&serverPort)).intYalue&)
)#
HH look up the remote o%ject
rmiServer,
&>eceive=essageInterface)®istry.lookup&3rmiServer3))#
HH call the remote method
rmiServer.receive=essage&te9t)#
8
catch&>emote49ception e)$
e.printStackTrace&)#
8
catch&;otMound49ception e)$
e.printStackTrace&)#
8
8
8
SERVER:
import java.rmi."#
import java.rmi.registry."#
import java.rmi.server."#
import java.net."#
pu%lic class >miServer e9tends java.rmi.server.Lnicast>emote7%ject
implements >eceive=essageInterface
$
int thisPort#
String this+ddress#
>egistry registry# HH rmi registry for lookup the remote o%jects.
HH This method is called from the remote client %y the >=I.
HH This is the implementation of the R>eceive=essageInterfaceS.
pu%lic void receive=essage&String 9) thro/s >emote49ception
21
$
System.out.println&9)#
8
pu%lic >miServer&) thro/s >emote49ception
$
try$
HH get the address of this host.
this+ddress, &Inet+ddress.get-ocal.ost&)).toString&)#
8
catch&49ception e)$
thro/ ne/ >emote49ception&3canOt get inet address.3)#
8
thisPort,3232# HH this port®istryXs port)
System.out.println&3this address,36this+ddress630port,36thisPort)#
try$
HH create the registry and %ind the name and o%ject.
registry , -ocate>egistry.create>egistry& thisPort )#
registry.re%ind&3rmiServer30 this)#
8
catch&>emote49ception e)$
thro/ e#
8
8
static pu%lic void main&String args'()
$
try$
>miServer s,ne/ >miServer&)#
8
catch &49ception e) $
e.printStackTrace&)#
System.e9it&1)# 8 8 8
22
OUTPUT:
SERVER
C5?jdk1.3?%inBjavac >miServer.java
C5?jdk1.3?%inBjavac >eceive=essageInterface.java
C5?jdk1.3?%inBrmic >miServer
C5?jdk1.3?%inBjava >miServer
this address,arulCPCH12G.2.2.10port,3232
hello
CLIENT
C5?jdk1.3?%inBjavac >miClient.java
C5?jdk1.3?%inBjava >miClient localhost 3232 hello
sending hello to localhost53232
23
RESULT:
The codes are compiled and the output is o%tained successfully.
Ex No:$
SIMULATION OF SLIDING 1INDO1 PROTOCOLS
Date:
AIM:
To /rite a C program to perform sliding /indo/.
ALGORITHM:
Ste 1: Start the program.
Ste !: Fet the frame siWe from the user
Ste ": To create the frame %ased on the user reIuest.
Ste #:To send frames to server from the client side.
Ste $: If your frames reach the server it /ill send +CU signal to client other/ise it /ill
send ;+CU signal to client.
Ste %: Stop the program
PROGRAM:
QincludePstdio.hB
main&)
$
int m0k0f0%s0i0%'22(0in,20out,20s0ch,20r#
printf&3?n 4nter the %uffer siWe53)#
scanf&3Vd30N%s)#
printf&3?n 4nter the siWe of the sliding /indo/53)#
scanf&3Vd30Ns)#
k,s#
for&i,2#iP%s#i66)
2
$
printf&3?n Sender'Vd(530in)#
scanf&3Vd30N%'i()#
in,in61#
8
printf&3?n 4nter the starting place of sliding /indo/53)#
scanf&3Vd30Nf)# s,s6f#
/hile&%sBf)
$
if&sP,%s)
$
printf&3?n The data in the slide /indo/?n3)#
for&i,f#iPs#i66)
printf&3?nVd30%'i()#
s66#
8
else
$
m,%sCk#
printf&3?n The data in the sliding /indo/ is 5?n3)#
for&i,m#iP%s#i66)
printf&3?nVd30%'i()#
8
r,%'f(#
printf&3?n The data is received ?n receiver 'Vd(Vd30f0r)#
f66# printf&3?nackVd30f)#
8
8
2!
OUTPUT:
'mcala%Zlocalhost e9am21([ cc sliding.c Co sliding.out
'mcala%Zlocalhost e9am21([ .Hsliding.out
4nter the %uffer siWe5!
4nter the siWe of the sliding /indo/52
Sender'2(51
Sender'1(52
Sender'2(53
Sender'3(5
Sender'(5!
4nter the starting place of sliding /indo/52
The data in the slide /indo/
3
!
The data is received
receiver '3(
ack
The data in the sliding /indo/ is 5
!
The data is received
2E
receiver '(!
ack !
RESULT:
The codes are compiled and the output is o%tained successfully.
2G
Ex No:% (i)
E4PERIMENTS USING SIMULATORS (LIKE OPNET)
SHARED ETHERNET NET1ORKS
Date:
21
2D
32
31
32
33
3
3!
3E
3G
31
RESULT:
Thus the program for shared ethernet has %een e9ecuted successfully.
3D
2
Ex No:% (ii)
E4PERIMENTS USING SIMULATORS (LIKE OPNET)
SHARED ETHERNET NET1ORKS- ROUTING PROTOCOLS
Date:
1
2
3
!
E
G
RESULT:
Thus the program for routing information protocol has %een e9ecuted successfully.
1
Ex No:&
PERFORMANCE COMPARISION OF MAC PROTOCOLS
Date:
AIM:
To compare the performance of =+C protocols
ALGORTHIM:
Ste1: create a ne/ simulator
Ste!: open the net/ork animator file /hich is the namfile outman
Ste": set the agent trace and the router trace in the 7; state and then get the =+C traceas7@@
state.
Ste#: Construct four nodes namely n20n10n2 and n3 and the color for trandfering the packetsis
set as green and red.
Ste$: The delay time for each nodes and the node agent for each nodes are set.
Ste%: The droptail Iueues are used to transfer the packets %y capturing them in a Iueue as
specified.
PROGRAM :
Set ns'ne/ Simulator
[ns color1 Mlue
[ns color 2 >edSet nf'open out.nam /(
[ns namtraceCall
[nf Proc finish$8$glo%al ns nf
[ns flushTtraceclose
[nf e9ec nam out.nam N e9it 2
8
Set no'[ns node(
Set n1'[ns node(
Set n2'[ns node(
Set n3'[ns node(
[ns duple9Clink [n2 [n2 2 =% 12ms *ropTail
[ns duple9Clink [n1 [n2 2 =% 12ms *ropTail
[ns duple9Clink [n2 [n3 1.G =% 22ms *ropTail
[ns IueueClink [n2 [n2 [n3 12
[ns duple9ClinkCop [n2 [n2 orient rightCdo/n
[ns duple9ClinkCop [n1 [n2 orient rightCup
[ns duple9ClinkCop [n2 [n3 orient right
[ns duple9ClinkCop [n2 [n3 IueueP7s 2.!
Set tcp'ne/ +gentHTCP(
[tcp set classT2
[ns attachCagent [no [tcp
Set sink'ne/ +gentHTCPSink(
[ns attachCagent [n3 [sink
D
[ns connect [tcp [sink
[tcp set fidT1
Set ftp'ne/ +pplicationH@TP(
[ftp attachCagent [tcp
[ftp set typeT@TP
Set udp'ne/ +gentHL*P(
[ns attachCagent [n1 [udp
Set null'ne/ +gentH;ull(
[ns attachCagent [n3 [null
[ns connect [udp [null
[udp set fidT2
Set c%r 'ne/ +pplicationHTrafficHCM>(
[c%r attachTagent [u*P
[c%r set typeTCM>
[c%r set packetTsiWeT1222
[c%r set rateT1m%
[c%r set randomTfalse
[ns at 2.1 R[c%r startS
[ns at 1.2 R[ftp startS
[ns at .2 R[ftp stopS
[ns at .! R[c%r stopS
[ns at .! R[ns detachCagent [n2 [tcp#[ns
detachCagent [n3 [sinkS
[ns at !.2 RfinishS
Puts RCM> packet siWe,'[c%r set packetTsiWeT(S
Puts RCM> interval,'[c%r set intervalT(S
[ns run
!2
OUTPUT:
!1
RESULT:
Thus the program for comparison of =+C protocols using ;SC2 simulators has %een
e9ecuted successfully.
!2
Ex No:2
PERFORMANCE COMPARISION OF ROUTING PROTOCOLS
Date:
AIM:
To compare the performance of >outing protocols
PROGRAM: AODV
Set val&mn) 12# Q num%er of mo%ilenodes
Set val&rp)+7*Y# Qrouting protocol
Set Yal&9)122
Set Yal&y)122
Set as';e/ Simulator(
QnsCrandom 2
Set f'open aodv120tr0/(
[ns traceCall sf Set namtrace'open aodv120nam /(
[ns namtraceCallC/ireless [namtrace [val&9) [val&y)
Set f2 'open packetsTreceived.tr /(
Set f1 'open packetsTlost.tr /(
Set f2 'open projTout2. tr /(
Set f3 'open projTout3.tr /(
Set topo 'ne/ Topography(
[topo loadTflatgrid 122 122
createCgod [val&nn)
Set chanT1 'ne/ [val&chan)(
Set chanT2 'ne/ [val&chan)(
Set chanT3 'ne/ [val&chan)(
Set chanT 'ne/ [val&chan)(
Set chanT! 'ne/ [val&chan)(
Set chanTE 'ne/ [val&chan)(
Q C7;@IFL>4 +;* C>4+T4 ;7*4S
*S>
Set val&nn) 12
Set val&rp) *S>
Set val&9)122
Set val&9)122
Qset val&stop)12.2s
et ns'ne/ Simulator(
QnsCrandom 2
Set f'open dsr1!.tr0/(
[ns traceCall sf
Set namtrace'open dsr1!.tr /(
!3
[ns namtraceCallC/ireless [namtrace [val&9) [val&y)
Set f2 'open packetsTreceived.tr /(
Set f1 'open packetsTlost.tr /(
Set f2 'open projTout2. tr /(
Set f3 'open projTout3.tr /(
Set topo 'ne/ Topography(
[topo loadTflatgrid 122 122
createCgod [val&nn)
Set chanT1 'ne/ [val&chan)(
Set chanT2 'ne/ [val&chan)(
Set chanT3 'ne/ [val&chan)(
Set chanT 'ne/ [val&chan)(
Set chanT! 'ne/ [val&chan)(
Set chanTE 'ne/ [val&chan)(
Set chanTG 'ne/ [val&chan)(
Set chanT1 'ne/ [val&chan)(
Set chanTD 'ne/ [val&chan)(
Set chanT12 'ne/ [val&chan)(
QC7;@IFL>4 +;* C>4+T4 ;7*4S
!
OUTPUT:
!!
RESULT:
Thus the comparing the performance of +7*Y and *S> is e9ecutes successfully.
Ex No:5
STUD0 OF TCP/UDP PERFORMANCE
Date:
AIM: To study a%out L*P and TCP Performance
The Lser *atagram Protocol &L*P) is one of the core mem%ers of the Internet Protocol
Suite0 the set of net/ork protocols used for the Internet. \ith L*P0 computer applications can
send messages0 in this case referred to as datagrams0 to other hosts on an Internet Protocol&IP)
net/ork /ithout reIuiring prior communications to set up special transmission channels or data
paths. The protocol /as designed %y *avid P. >eed in 1D12 and formally defined in >@C GE1.
L*P uses a simple transmission model /ithout implicit handCshaking dialogues for
providing relia%ility0 ordering0 or data integrity. Thus0 L*P provides an unrelia%le service and
datagrams may arrive out of order0 appear duplicated0 or go missing /ithout notice. L*P
assumes that error checking and correction is either not necessary or performed in the
application0 avoiding the overhead of such processing at the net/ork interface level. TimeC
sensitive applications often use L*P %ecause dropping packets is
It is also possi%le to terminate the connection %y a 3C/ay handshake0 /hen host + sends
a @I; and host M replies /ith a @I; N +CU &merely com%ines 2 steps into one) and host +
replies /ith an +CU. This is perhaps the most common method. It is possi%le for %oth hosts to
send @I;s simultaneously then %oth just have to +CU. This could possi%ly %e considered a 2C
/ay handshake since the @I;H+CU seIuence is done in parallel for %oth directions.
Some host TCP stacks may implement a 3halfCduple93 close seIuence0 as -inu9 or .PC
L: do. If such a host actively closes a connection %ut still has not read all the incoming data the
stack already received from the link0 this host sends a >ST instead of a @I;&Section .2.2.13 in
>@C 1122). This allo/s a TCP application to %e sure the remote application has read all the data
the former sent]/aiting the @I; from the remote side0 /hen it actively closes the connection.
.o/ever0 the remote TCP stack cannot distinguish %et/een a Connection +%orting >ST and
this *ata -oss >ST.
Moth cause the remote stack to thro/ a/ay all the data it received0 %ut that the
application still didnXt read.'clarification needed (Some application protocols may violate the
7SI model layers0 using the TCP openHclose handshaking for the application protocol openHclose
handshaking C these may find the >ST pro%lem on active close. +s an e9ampleXs ,
connect&remote)#send&s0 data)#close&s)#@or a usual program flo/ like a%ove0 a TCPHIP stack like
that descri%ed a%ove does nonguaranteed that all the data arrives to the other application unless
the programmer is sure that the remote side /ill not send anything.
TCP o(t'
=ain article5 TCP and L*P portTCP uses the notion of num%ers to identify sending and
receiving application endCpoints on a host0 or Internet sockets. 4ach side of a TCP connection
!E
has an associated 1EC%itunsigned port num%er &2CE!!3!) reserved %y the sending or receiving
application. +rriving TCP data packets are identified as %elonging to a specific TCP connection
%y its sockets0 that is 0 the com%ination of source host address0 source port0 destination host
address0 and destination port. This means that a server computer can provide several clients /ith
several services simultaneously0 as long as a client takes care of initiating any simultaneous
connections to one destination port from different source ports. Port num%ers are categoriWed
into three %asic categories5 /ellCkno/n0 registered0 and dynamicHprivate. The /ellCkno/n ports
are assigned %y the Internet +ssigned ;um%ers +uthority &I+;+) and are typically used %y
systemClevel or root processes. \ellCkno/n applications running as servers and passively
listening for connections typically use these ports.
Some e9amples include5 @TP &21)0 SS. &22)0T4-;4T&23)0 S=TP&2!) and .TTP &12).
>egistered ports are typically used %y end user applications as ephemeral source ports /hen
contacting servers0 %ut they can also identify named services that have %een registered %y a third
RESULT:-
!G
Thus the performance of L*P and TCP is studied successfully
!1