Sie sind auf Seite 1von 94

Ex.

no:1 CLIENT-SERVER CHAT PROGRAM


Date: USING TCP
AIM
To write a C program for implementing Client-Server Chat
using TCP.
ALGORITHM
SERVER
Step 1: Start the program.
Step 2: Create an unnamed socket for the server using the
Parameters A!"#$T as domain and the S%C&!ST'$A(
as t)pe.
Step *: #ame the socket using +ind, - s)stem call with the
parameters server!sockfd and the server address ,sin!addr
and sin!sport-.
Step .: Create a connection /ueue and wait for clients using the
listen,- s)stem call with the num+er of clients re/uest as
parameters.
Step 0: Accept the connection using accept, - s)stem call when
client re/uests for connection.
Step 1: 2et the message which has to +e sent to the client and
check that it is not e/ual to 34)e5.
Step 6: "f the message is not e/ual to 34)e5 then write the message
to the client and 2oto step 1.
Step 7: "f the message is 34)e5 then terminate the Process.
Step 8: Stop the program e9ecution.
CLIENT
Step 1: Start the program.
Step 2: Create an unnamed socket for client using socket, - s)stem.
Step *: Call with parameters A!"#$T as domain and
S%C&!ST'$A( as t)pe.
Step .: #ame the socket using +ind , - s)stem call.
Step 0: #ow connect the socket to server using connect , - s)stem
call.
Step 1: 'ead the message from the server socket and compare it
with 34)e5.
Step 6: "f the message is not e/ual to 34)e5 then print the message
to the server %utput device and repeat the steps 1 : 6.
Step 7: 2et the message from the client side.
Step 8: ;rite the message to server sockfd and goto step ..
Step 1<:"f the message is e/ual to 34)e5 then print good +)e
message and terminate the process.
Step 11: Stop the process.
PROGRAM:
SERVER
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
=include>string.h?
main,-
A
int sdBsd2BnsdBclilenBsportBlenC
char sendmsgD2<EBrcvmsgD2<EC
struct sockaddr!in servaddrBcliaddrC
printf,F$nter the Server portF-C
printf,FGn!!!!!!!!!!!!!!!!!!!!!GnF-C
scanf,FHdFB:sport-C
sdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,sd><-
printf,FCanJt Create GnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,sport-C
sd2I+ind,sdB,struct sockaddrM-:servaddrBsiNeof,servaddr--C
if,sd2><-
printf,F CanJt 4indGnF-C
else
printf,FGn 4indedGnF-C
listen,sdB0-C
clilenIsiNeof,cliaddr-C
nsdIaccept,sdB,struct sockaddrM-:cliaddrB:clilen-C
if,nsd><-
printf,FCanJt AcceptGnF-C
else
printf,FAcceptedGnF-C
printf,FGn'eceived (essagesGnF-C
do
A
recv,nsdBrcvmsgB2<B<-C
printf,FHsFBrcvmsg-C
fgets,sendmsgB2<Bstdin-C
lenIstrlen,sendmsg-C
sendmsgDlen-1EIJG<JC
send,nsdBsendmsgB2<B<-C
wait,2<-C
O
while,strcmp,sendmsgBF+)eF-PI<-C
O
CLIENT
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
main,-
A int csdBcportBlenC
char sendmsgD2<EBrevmsgD2<EC
struct sockaddr!in servaddrC
printf,F$nter the portGnF-C
scanf,FHdFB:cport-C
csdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,csd><-
printf,FCanJt CreateGnF-C
else
printf,FScocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,cport-C
if,connect,csdB,struct sockaddrM-:servaddrBsiNeof,servaddr--><-
printf,FCanJt ConnectGnF-C
else
printf,FConnectedGnF-C
do
A
fgets,sendmsgB2<Bstdin-C
lenIstrlen,sendmsg-C
sendmsgDlen-1EIJG<JC
send,csdBsendmsgB2<B<-C
wait,2<-C
recv,csdBrevmsgB2<B<-C
printf,FHsFBrevmsg-C
O
while,strcmp,revmsgBF+)eF-PI<-C
O
OUTPUT:
Client Side
D1me11Qlocalhost RES cc tcpclient.c
D1me11Qlocalhost RES. @a.out
$nter the port
102*
Socket is CreatedT
ConnectedTT
Uello
Se!e Side
D1me11Qlocalhost RES cc tcpserver.c.c
D1me11Qlocalhost RES. @a.out
$nter the server portT
10.*
Socket is Created
4inded
Accepted
'eceived (essagesT. Uello
RESULT:
Thus the C program for chat using TCP is e9ecuted and the output
is verified successfull).
Ex.no:"
Date: CLIENT-SERVER CHAT USING UDP
AIM
To write a C program for implementing chat program using VKP.
ALGORITHM
SERVER
Step 1: Start the program.
Step 2: Create an unnamed socket for the server using the
parameters A!"#$T as domain and the S%C&!K2'A(
as t)pe.
Step *: #ame the socket using +ind, - s)stem call with the
parameters server!sockfd and the server address
,sin!addr and sin!sport-.
Step .: The server gets the message from the client.
Step 0: Prints the message.
Step 1: Stop the program e9ecution.
CLIENT
Step 1: Start the program.
Step 2: Create an unnamed socket for client using socket
Step *: Call with parameters A!"#$T as domain an
S%C&!K2'A( as t)pe.
Step .: #ame the socket using +ind, - s)stem call.
Step 0: The Sendto, - s)stem call is used to deliver the
(essage to the server.
Step 1: Stop the program e9ecution.
PROGRAM
SERVER
=include>stdio.h?
=include>s)s@t)pes.h?
=include>s)s@socket.h?
=include>netinet@in.h?
main,-
A
struct sockaddr!in saddBcaddC
int idBaB+BlenBportC
char r+uffD1<<EC
widIsocket,P!"#$TBS%C&!K2'A(B<-C
if,id><-
printf,FCanJt CreateGnF-C
else
printf,FCreatedGnF-C
printf,F$nter the port AddressGnF-C
printf,F!!!!!!!!!!!!!!!!!!!!GnF-C
scanf,FHdFB:port-C
sadd.sin!famil)IP!"#$TC
sadd.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
sadd.sin!portIhtons,port-C
+I+ind,idB,struct sockaddrM-:saddBsiNeof,sadd--C
if,+><-
printf,FCanJt 4indF-C
else
printf,F4indedGnF-C
printf,FRRRRRRGnF-C
lenIsiNeof,cadd-C
if,recvfrom,idBr+uffBsiNeof,r+uff-B<B,struct sockaddrM-:caddB:len-><-
printf,F'eceived $rrorGnF-C
else
printf,FServer received IHsGnFBr+uff-C
close,id-C
O
CLIENT
=include>stdio.h?
=include>s)s@socket.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
main,-
A
struct sockaddr!in saddBcaddC
int idBlenBnBcBsB+BportC
char strD1<<EBserstrD1<<EC
idIsocket,P!"#$TBS%C&!K2'A(B<-C
if,id><-
printf,FCanJt CreateGnF-C
else
printf,FSocket is CreatedGnF-C
printf,F$nter the "P addressGnF-C
scanf,FHsFBserstr-C
printf,F$nter the port AddressGnF-C
scanf,FHdFB:port-C
cadd.sin!famil)IP!"#$TC
cadd.sin!addr.s!addrIinet!addr,serstr-C
cadd.sin!portIhtons,port-C
printf,F$nter the KataGnF-C
scanf,FHsFBstr-C
+I+ind,idB,struct sockaddrM-:caddBsiNeof,cadd--C
if,sendto,idBstrBsiNeof,str-B<B,struct sockaddrM-:caddBsiNeof,cadd--><-
printf,FTransmit $rrorF-C
else
printf,FServer TransmittedIHsGnFBstr-C
close,id-C
O
OUTPUT:
Client Side
D1me11Qlocalhost RES cc udpclient.c
D1me11Qlocalhost RES. @a.out
Socket is CreatedT
$nter the "P Address
162.10.16<.1<.
$nter the port address
10.*
$nter the data
Uello
Server transmitted I hello
Se!e Side
D1me11Qlocalhost RES cc udpserver.c
D1me11Qlocalhost RES. @a.out
Created
$nter the port address
TTTT.
10.*
4inded
TTTTT.
RESULT
Thus the C program for chat using VKP is e9ecuted and the output
is verified successfull).
Ex. No. #a PRINTING THE CLIENT ADDRESS
Date: AT THE SERVER END
AIM
To write a C program for printing the client address at the server
end.
ALGORITHM
SERVER
Step 1: Start the program.
Step 2: Create an unnamed socket for the server using the
parameters A!"#$T as domain and the S%C&!ST'$A(
as t)pe.
Step *: #ame the socket using +ind, - s)stem call with the
parameters server!sockfd and the server address,sin!addr
and sin!sport-.
Step .: Create a connection /ueue and wait for clients
using the listen, - s)stem call with the num+er of clients
re/uest as parameters.
Step 0: Accept the connection using accept, - s)stem call when
client re/uests for connection.
Step 1: "f the descriptor is less than NeroBthen the connection is not
esta+lished and the stop the process.
Step 6: Print the "P address sent +) the client to the server.
Step 7: Stop the program e9ecution.
CLIENT
Step 1: Start the program.
Step 2: Create an unnamed socket for client using socket, - s)stem.
Step *: Call with parameters A!"#$T as domain and
Socket stream as t)pe.
Step .: #ame the socket using +ind, - s)stem call.
Step 0: #ow connect the socket to server using connect, - s)stem
call.
Step 1: "f the descriptor is less than NeroB then the
connection is not esta+lished.
Step 6: "f there is no connectionBthen terminate the process.
Step 7: $lse send the "P address to the server.
Step 8: Stop the process.
PROGRAM
SERVER
=include>stdio.h?
=include>s)s@socket.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
=include>string.h?
main,-
A
int sdBsd2BnsdBclilenBsportBlenC
char sendmsgD2<EBrcvmsgD2<EC
struct sockaddr!in servaddrBcliaddrC
printf,F$nter the PortGnF-C
scanf,FHdFB:sport-C
sdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,sd><-
printf,FCanJt Create GnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIinet!addr,F162.10.16<.1<.F-C
servaddr.sin!portIhtons,sport-C
sd2I+ind,sdB,struct sockaddrM-:servaddrBsiNeof,servaddr--C
if,sd2><-
printf,F CanJt 4indGnF-C
else
printf,FGn 4indedGnF-C
listen,sdB0-C
clilenIsiNeof,cliaddr-C
nsdIaccept,sdB,struct sockaddrM-:cliaddrB:clilen-C
if,nsd><-
printf,FCanJt AcceptGnF-C
else
printf,FAcceptedGnF-C
printf,FThe Client Address is HsFBinet!ntoa,cliaddr.sin!addr.s!addr--C
O
CLIENT
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
main,-
A
int csdBcportBlenC
char sendmsgD2<EBrevmsgD2<EC
struct sockaddr!in servaddrC
printf,F$nter the portGnF-C
scanf,FHdFB:cport-C
csdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,csd><-
printf,FCanJt CreateGnF-C
else
printf,FScocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIinet!addr,F162.10.16<.1<.F-C
servaddr.sin!portIhtons,cport-C
if,connect,csdB,struct sockaddrM-:servaddrBsiNeof,servaddr--><-
printf,FCanJt ConnectGnF-C
else
printf,FConnectedGnF-C
O
OUTPUT:
Client Side
D1me11Qlocalhost RES cc addressclient.c
D1me11Qlocalhost RES. @a.out
$nter the port:
10.*
Socket is Created...
Se!e Side
D1me11Qlocalhost RES cc addressserver.c
D1me11Qlocalhost RES. @a.out
$nter the port:
10.*
Created...
4indedTT
RESULT
Thus the C program for printing the client "P Address at the server
end is e9ecuted and the output is verified successfull).
Ex.no: #$ DATE-TIME SERVER
DATE-TIME SERVER
Date:
AIM
To write a C program for implementing the simple TCP client-
server where the server acts as a Kate-Time server.
ALGORITHM
SERVER
Step 1 :Start the program
Step 2 :Create an unnamed socket for the server using parameters
A!"#$T as domain and S%C&!ST'$A( as t)pe.
Step * : Keclare the time varia+les t.
Step . :2et the server port num+er.
Step 0 :'egister the host address to the s)stem +) using +ind,-
s)stem call in server side.
Step 1 :Create a connection /ueue and wait for clients using listen,-
s)stem call with the num+er of clients re/uests as
parameter.
Step 6 :Accept the connection using accept, - s)stem call when the
client re/uest for connection.
Step 7 :Stop the Program e9ecution.
CLIENT
Step 1 :Start the program.
Step 2 :Create an unnamed socket for the client using parameters
A!"#$T as domain and S%C&!ST'$A( as t)pe.
Step * :2et the client port num+er.
Step . :#ow connect the socket to server using connect, - s)stem
call.
Step 0 :The recv,- s)stem call gets the response of Kate-Time
re/uest from the server. Print the date and time
Step 1 : Stop the program.
PROGRAM
SERVER
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
=include>string.h?
=include>time.h?
main,-
A
int sdBsd2BnsdBclilenBsportBlenC
char sendmsgD2<EBrcvmsgD2<EC
time!t tC
struct sockaddr!in servaddrBcliaddrC
printf,F$nter the Port noGnF-C
scanf,FHdFB:sport-C
sdIsocket,A!"#$TBS%C&!ST'$A(B<-C
time,:t-C
strcp),sendmsgBctime,:t--C
printf,FHsFBsendmsg-C
if,sd><-
printf,FCanJt Create GnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,sport-C
sd2I+ind,sdB,struct sockaddrM-:servaddrBsiNeof,servaddr--C
if,sd2><-
printf,F CanJt 4indGnF-C
else
printf,FGn 4inded GnF-C
listen,sdB0-C
clilenIsiNeof,cliaddr-C
nsdIaccept,sdB,struct sockaddrM-:cliaddrB:clilen-C
if,nsd><-
printf,FCanJt AcceptGnF-C
else
printf,FAcceptedGnF-C
send,nsdBsendmsgB1<<B<-C
O
CLIENT
=include>stdio.h?
=include>s)s@t)pes.h?
=include>s)s@socket.h?
=include>netinet@in.h?
=include>stdli+.h?
=include>time.h?
main,-
A
int csdBcportBlenC
char rcvmsgD1<<EC
struct sockaddr!in servaddrC
printf,F$nter the portGnF-C
scanf,FHdFB:cport-C
csdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,csd><-
printf,FCanJt CreateGnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,cport-C
if,connect,csdB,struct sockaddrM-:servaddrBsiNeof,servaddr--><-
printf,FConnection errorGnF-C
recv,csdBrcvmsgB1<<B<-C
printf,FHsGnFBrcvmsg-C
O
OUTPUT:
Client Side
D1me11Qlocalhost RES cc dateclient.c
D1me11Qlocalhost RES. @a.out
$nter the port:
70.*
Socket is Created...
ConnectedT
Se!e Side
D1me11Qlocalhost RES cc dateserver.c
D1me11Qlocalhost RES. @a.out
$nter the port:
70.*
ri Sep 16 <*:<0:26 2<1<
Socket is Created...
RESULT
Thus the C program for printing Kate and time is e9ecuted and the
output is verified successfull).
Ex.no:#% &ILE TRANS&ER USING TCP
Date: &ILE TRANS&ER USING TCP
AIM:
To write a C program for transferring a file using TCP.
ALGORITHM:
SERVER:
Step 1: Start the program.
Step 2: Create an unnamed socket for the server using parameters
A!"#$T as domain and S%C&!ST'$A( as t)pe.
Step *: 2et the server port num+er.
Step .: 'egister the host address to the s)stem +) using +ind,-
s)stem call in server side.
Step 0: Create a connection /ueue and wait for clients using listen,-
s)stem call with the num+er of clients re/uests as
parameter.
Step 1: Create a Child process using fork, - s)stem call.
Step 6: "f the process identification num+er is e/ual to Nero accept
the connection using accept, - s)stem call when the client
re/uest for connection.
Step 7: "f pid is not e/ual to Nero then e9it the process.
Step 8: Stop the Program e9ecution.
CLIENT:
Step 1: Start the program.
Step 2: Create an unnamed socket for the client using parameters
A!"#$T as domain and S%C&!ST'$A( as t)pe.
Step *: 2et the client port num+er.
Step .: #ow connect the socket to server using connect, - s)stem
call.
Step 0: $nter the file name.
Step 1: The file is transferred from client to server using send , -
function.
Step 6: Print the contents of the file in a new file.
Step 7: Stop the program.
PROGRAM:
SERVER
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
=include>string.h?
main,-
A
"W$ MfpC
int sdBnewsdBserBnBaBcliBpidB+dBportBclilenC
char nameD1<<EBfilereadD1<<EBfnameD1<<EBchBfileD1<<EBrcvD1<<EC
struct sockaddr!in servaddrBcliaddrC
printf,F$nter the port address: F-C
scanf,FHdFB:port-C
sdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,sd><-
printf,FCanJt Create GnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,port-C
aIsiNeof,servaddr-C
+dI+ind,sdB,struct sockaddrM-:servaddrBa-C
if,+d><-
printf,F CanJt 4indGnF-C
else
printf,FGn 4indedGnF-C
listen,sdB0-C
clilenIsiNeof,cliaddr-C
newsdIaccept,sdB,struct sockaddrM-:cliaddrB:clilen-C
if,newsd><-
printf,FCanJt AcceptGnF-C
else
printf,FAcceptedGnF-C
nIrecv,newsdBrcvB1<<B<-C
rcvDnEIJG<JC
fpIfopen,rcvBFrF-C
if,fpII#VWW-
A
send,newsdBFerrorFB0B<-C
close,newsd-C
O
else
A
while,fgets,filereadBsiNeof,fileread-Bfp--
A
if,send,newsdBfilereadBsiNeof,fileread-B<-><-
A
printf,FCanJt sendGnF-C
O
sleep,1-C
O
if,Pfgets,filereadBsiNeof,fileread-Bfp--
A
send,newsdBFcompletedFB888888888B<-C
O
return,<-C
O
O
CLIENT
=include>stdio.h?
=include>s)s@socket.h?
=include>netinet@in.h?
main,-
A
"W$ MfpC
int csdBnBserBsBcliBcportBnewsdC
char nameD1<<EBrcvmsgD1<<EBrcvgD1<<EBfnameD1<<EC
struct sockaddr!in servaddrC
printf,F$nter the portF-C
scanf,FHdFB:cport-C
csdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,csd><-
A
printf,F$rror...F-C
e9it,<-C
O else
printf,FSocket is Created...GnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-Cservaddr.sin!portIh
tons,cport-C
if,connect,csdB,struct sockaddrM-:servaddrBsiNeof,servaddr--><-
printf,F$rror in Connection...GnF-C
else
printf,FConnected...GnF-C
printf,F$nter the e9isting file name: F-C
scanf,FHsFBname-C
printf,FGn$nter the new filename: F-C
scanf,FHsFBfname-C
fpIfopen,fnameBFwF-C
send,csdBnameBsiNeof,name-B<-C
while,1-
A
sIrecv,csdBrcvgB1<<B<-C
rcvgDsEIJG<JC
if,strcmp,rcvgBFerrorF-II<-
printf,File is not Availa+le...GnF-C
if,strcmp,rcvgBFcompletedF-II<- A
printf,Ffile is transferred...GnF-C
fclose,fp-C
close,csd-C
+reakC
O
else
fputs,rcvgBstdout-C
fprintf,fpBFHsFBrcvg-C
O
O
OUTPUT:
Se!e Side
D1me11Qlocalhost RES cc ftpclient.c
D1me11Qlocalhost RES. @a.out
$nter the port address:
711*
Socket is Created
4inded
ConnectedT
Client Side
D1me11Qlocalhost RES cc ftpserver.c
D1me11Qlocalhost RES. @a.out
Socket is Created..
Connected
$nter the e9isting file name: net
$nter the new file name: network
;elcome to #etwork Wa+
ile is transferred...
RESULT
Thus the C program for transferring file from one machine to
another machine using TCP is e9ecuted and the output is verified
successfull).
E'.NO:( SIMULATION O& SLIDING )INDO) PROTOCOL
DATE: SIMULATION O& SLIDING )INDO)
PROTOCOL
AIM
To write a C program for the simulation of Sliding ;indow
Protocol.
ALGORITHM
SENDER
Step 1: Start the program.
Step 2: Create a Socket for the Sender and +ind it with the receiver.
Step *: Set the siNe of the window.
Step .: Send the frames upto the siNe of the window to the receiver
Step 0: "f an) of the frames are lost then retransmit those frames to
the receiver
Step 1: Stop the e9ecution.
RECEIVER
Step 1: Start the program.
Step 2: Create the Socket for the 'eceiverB +ind it and listen for the
frames from the sender.
Step *: "f all the frames are successfull) receivedB send the
acknowledgement for the last frame to the sender.
Step .: "f an) of the frames is lostB then send the acknowledgement
of the last frameB which was successfull) received.
Step 0: &eep on receiving and acknowledging the frames until the
sender sends.
Step 1: Stop the program e9ecution.
PROGRAM:
SERVER
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
=include>string.h?
=include>s)s@socket.h?
main,-
A int aB+dBsdBnewsdBportBclilenC
char lostD2<EBsendmsgD2<EBrecvmsgD2<EC
struct sockaddr!in servaddrBcliaddrC
sdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,sd><-
printf,FCanJt Create GnF-C
else
printf,FSocket is CreatedGnF-C
printf,F$nter the port noGnF-C
scanf,FHdFB:port-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,port-C
aIsiNeof,servaddr-C
+dI+ind,sdB,struct sockaddrM-:servaddrBa-C
if,+d><-
printf,F CanJt 4indGnF-C
else
printf,FGn 4indedGnF-C
listen,sdB0-C
clilenIsiNeof,cliaddr-C
newsdIaccept,sdB,struct sockaddrM-:cliaddrB:clilen-C
if,newsd><-
printf,FCanJt AcceptGnF-C
else
printf,FAcceptedGnF-C
printf,F$nter the lost frameGnF-C
scanf,FHsFBlost-C
send,newsdBlostB2<B<-C
recv,newsdBrecvmsgB2<B<-C
printf,FGn rame Hs is successfull) receivedFBrecvmsg-C
O
CLIENT
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
=include>string.h?
main,-
A int iBsdBnBportC
char sendmsgD1<<EBrecvmsgD1<<EC
struct sockaddr!in servaddrC
printf,F$nter the portGnF-C
scanf,FHdFB:port-C
sdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,sd><-
printf,FCanJt CreateGnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,port-C
if,connect,sdB,struct sockaddrM-:servaddrBsiNeof,servaddr--><-
printf,FCanJt ConnectGnF-C
else
printf,FConnectedGnF-C
printf,F$nter the no of framesGnF-C
scanf,FHdFB:n-C
printf,FGnThe frames allGnF-C
for,iI1Ci>InCiXX-
printf,Frame HdGnFBi-C
recv,sdBrecvmsgB2<B<-C
printf,FGn Wost frame Hs is retransmitted FBrecvmsg-C
strcp),sendmsgBrecvmsg-C
send,sdBsendmsgB2<B<-C
O
OUTPUT:
Se!e:
D1me11alhostRE: Y" swserver.c
D1me11alhostRE: CC swserver.c
D1me11alhostRE: @a.out
$nter the port address
70.*
Socket is created
4inded
Accepted
$nter the lost frame: *
rame tcpserver.c is successfull) transmitted
Client:
D1me11alhostRE: Y" swclient.c
D1me11alhostRE: CC swclient.c
D1me11alhostRE: @a.out
$nter the client port no
70.*
Socket is created
ConnectedTTTT..
$nter the no of frames: .
The frames all
rame 1@n rame 2@n rame *@n rame .@n
RESULT
Thus the C program for the simulation of Sliding ;indow Protocol
has +een e9ecuted and the output is verified successfull).
E'.NO:*
DOMAIN NAME S+STEM
DATE:
AIM
To write a C program for the simulation of Komain #ame S)stem
ALGORITHM
SERVER
Step 1: Start the program.
Step 2: Create the Socket for the Server.
Step *: 4ind the Socket to the Port.
Step .: Wisten for the incoming client connection.
Step 0: 'eceive the "P address from the client to +e resolved.
Step 1: 2et the domain name from the client.
Step 6: Check the e9istence of the domain in the server.
Step 7: "f domain matches then send the corresponding address to
the client.
Step 8: Stop the program e9ecution.
CLIENT
Step 1: Start the program.
Step 2: Create the Socket for the client.
Step *: Connect the Socket to the server.
Step .: Send the hostname to the server to +e resolved.
Step 0: "f the server responds the print the address and terminates
the process.
PROGRAM
SERVER
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
=include>string.h?
main,-
A
int sdBsd2BnsdBclilenBsportBlenBiC
char sendmsgD2<EBrecvmsgD2<EC
char ipidD2<E
D2<EIAF162.10.1..11FBF162.10....00FBF162.10.**...FBF162.10.22.**FOC
char hostidD2<E
D2<EIAFwww.)ahoo.comFBFwww.google.comFBFwww.hotmail.comFOC
struct sockaddr!in servaddrBcliaddrC
printf,FK#S Server SideGnF-C
printf,F$nter the PortGnF-C
scanf,FHdFB:sport-C
sdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,sd><-
printf,FCanJt Create GnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,sport-C
sd2I+ind,sdB,struct sockaddrM-:servaddrBsiNeof,servaddr--C
if,sd2><-
printf,FCanJt 4indGnF-C
else
printf,FGn 4indedGnF-C
listen,sdB0-C
clilenIsiNeof,cliaddr-C
nsdIaccept,sdB,struct sockaddrM-:cliaddrB:clilen-C
if,nsd><-
printf,FCanJt AcceptGnF-C
else
printf,FAcceptedGnF-C
recv,nsdBrecvmsgB2<B<-C
for,iI<Ci>.CiXX-
A
if,strcmp,recvmsgBhostidDiE-II<-
A
send,nsdBipidDiEB2<B2<-C
+reakC
O
O
O
CLIENT
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
main,-
A
int csdBcportBlenC
char sendmsgD2<EBrecvmsgD2<EC
struct sockaddr!in servaddrC
printf,FK#S Client SideGnF-C
printf,F$nter the Client portGnF-C
scanf,FHdFB:cport-C
csdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,csd><-
printf,FCanJt CreateGnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,cport-C
if,connect,csdB,struct sockaddrM-:servaddrBsiNeof,servaddr--><-
printf,FCanJt ConnectGnF-C
else
printf,FConnectedGnF-C
printf,F$nter the host addressGnF-C
scanf,FHsFBsendmsg-C
send,csdBsendmsgB2<B<-C
recv,csdBrecvmsgB2<B2<-C
printf,FThe Coresponding "P Address isGnF-C
printf,FHsFBrecvmsg-C
O
OUTPUT:
Se!e:
D1me11alhostRE: Y" dnsserver.c
D1me11alhostRE: CC dnsserver.c
D1me11alhostRE: @a.out
$nter the port no
70.*
Socket is created
4inded
Accepted
Client:
D1me11alhostRE: Y" dnsclient.c
D1me11alhostRE: CC dnsclient.c
D1me11alhostRE: @a.out
$nter the client port no
70.*
Socket is created
ConnectedTTTT..
$nter the host address
www.)ahoo.com
The corresponding "P Address is
162.10.1..11
RESULT
Thus the C program for the simulation of Komain #ame S)stem
has +een e9ecuted and the output is verified successfull).
E'.NO:,a
SIMULATION O& ROUTING PROTOCOLS
DATE:
AIM
To Simulate Shortest Path 'outing Algorithm
ALGORITHM
Step 1: Start the Program
Step 2: Create a distance listB a previous verte9 listB a visited listB
and a current verte9.
Step *: All the values in the distance list are set to infinit) e9cept
the starting verte9 which is set to Nero.
Step .: All values in visited list are set to false.
Step 0: All values in the previous list are set to a special value
signif)ing that the) are undefined.
Step 1: Current node is set as the starting verte9.
Step 6: (ark the current verte9 as visited.
Step 7: Vpdate distance and previous lists +ased on those vertices
which can +e immediatel) reached from the current verte9.
Step 8: Vpdate the current verte9 to the unvisited verte9 that can +e
reached +) the shortest path from the starting verte9.
Step 1<:'epeat ,from step 1- until all nodes are visited.
Step 11:Stop the program e9ecution.
PROGRAM:
=include>stdio.h?
int main,-
A
int iBZBkBnBaD1<ED1<EB+D1<ED1<EC
printf,[$nter the no of nodes\-C
scanf,[Hd\B:n-C
for,iI<Ci>nCiXX-
A
for,ZI<CZ>nCZXX-
A
printf,[$nter the distance +etween the host:Hd Hd\BiX1BZX1-C
scanf,[Hd\B:aDiEDZE-C
O
O
for,iI<Ci>nCiXX-
A
for,ZI<CZ>nCZXX-
printf,[HdGn\B:aDiEDZE-CO
for,kI<Ck>nCkXX-
A
for,iI<Ci>nCiXX-
A
for,ZI<CZ>nCZXX-
A
if,aDiEDZE?aDiEDkEXaDkEDZE-
aDiEDZEIaDiEDkEXaDkEDZEC
O
O
O
for,iI<Ci>nCiXX-
A
for,ZI<CZ>nCZXX-
A
+DiEDZEIaDiEDZEC
if,iIIZ-
+DiEDZEI<C
O
O
printf,[The output matri9 is Gn\-C
for,iI<Ci>nCiXX-
A
for,ZI<CZ>nCZXX-
printf,[HdGt\B+DiEDZE-CO
return <C
O
OUTPUT
$nter the no of nodes:2
$nter the distance +etween the host:1 12
$nter the distance +etween the host:1 2*
$nter the distance +etween the host:2 1.
$nter the distance +etween the host:2 20
2*
.0
the output matri9 is
< * . <
RESULT:
Thus the Program for simulating Shortest Path 'outing Algorithm
is e9ecuted and the output is verified successfull).
E'.NO:,$
UNI&ORM RESOURCE LOCATOR -URL.
DATE:
AIM
To retrieve the data using Vniform 'esource Wocators.
ALGORITHM
Step 1: Start the Program.
Step 2: Create an o+Zect for the V'W class.
Step *: Specif) the address from which the data is to +e retrieved
inside the V'W class
Step .: %pen the V'W connection
Step 0: 'e/uest the content WengthB modified date etc. using
appropriate the methods.
Step 1: Kispla) the contents to the user
Step 6: Stop the program
PROGRAM:
=include>stdio.h?
=include>dos.h?
=include>conio.h?
=include>string.h?
void main,-
A
char cC
int lenI<C
struct date dC
struct time tC
"W$ MfpC
getdate,:d-C
gettime,:t-C
fpIfopen,Fwelcome.htmlFBFrF-C
printf,FContent t)pe I te9t@htmlGnF-C
printf,FGn Kate : Hd-Hd-Hd Time : Hd:Hd:Hd
GnFBd.da!da)Bd.da!monBd.da!)earBt.ti!hourBt.ti!minBt.ti!sec-C
cIfgetc,fp-C
scanf,[Hc\B:c-C
lenXXC
while,,cIfgetc,fp--PI-1-
A
if,cPIJGnJ]]J J-C
lenXXC
scanf,[Hc\B:c-C
O
printf,FGn Content length is HdFBlen-C
getch,-C
O
OUTPUT:
C%#T$#T TLP$Ite9t@html
Kate:<*-11-2<1< time:10:1*:27
>html?
>head?
>title?welcome>@title?
>+od) +gcolorI\+lue\?
>h1?welcome to network la+-1>@h?
>@+od)?
>@html?
content length is 1<8
RESULT
Thus the program for retrieving the data using V'W is e9ecuted
and the output is verified successfull).
Ex.No:/a
MULTICLIENT-SERVER CHAT
Date:
AIM:
To write a C program for implementing Client-Server Chat using
TCP.
ALGORITHM:
SERVER:
Step 1: Start the program.
Step 2: Create an unnamed socket for the server using the
parameters A!"#$T as domain and the S%C&!ST'$A(
as t)pe.
Step *: #ame the socket using +ind , - s)stem call with the
parameters server!sockfd and the server address ,sin!addr
and sin!sport-.
Step .: Create a connection /ueue and wait for clients using the
listen, - s)stem call with the num+er of clients re/uest as
parameters.
Step 0: 2et the client5s id as input from the user to communicate. "f
the client5s id is < then go to step 1< otherwise go to step 1.
Step 1: Accept the connection using accept , - s)stem call when
client re/uests for connection.
Step 6: 2et the message which has to +e sent to the client and
check that it is not e/ual to 34)e5.
Step 7: "f the message is not e/ual to 34)e5 then write the message
to the client and 2oto step 1.
Step 8: "f the message is 34)e5 then terminates the connection with
current client and 2o to step 0.
Step 1<:Stop the program e9ecution.
CLIENT:
Step 1: Start the program.
Step 2: Create an unnamed socket for client using socket , - s)stem.
Step *: Call with parameters A!"#$T as domain and
S%C&!ST'$A( as t)pe.
Step .: #ame the socket using +ind, - s)stem call.
Step 0: #ow connect the socket to server using connect , - s)stem call.
Step 1: 'ead the message from the server socket and compare it with
34)e5.
Step 6: "f the message is not e/ual to 34)e5 then print the message to
the server output device and repeat the steps 1 : 6.
Step 7: 2et the message from the client side.
Step 8: ;rite the message to server sockfd and goto step ..
Step 1<:"f the message is e/ual to 34)e5then print good +)e message
and terminate the process.
Step 11:Stop the process.
PROGRAM:
SERVER
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
=include>string.h?
main,-
A
int iBsdBsd2BnsdBclilenBsportBlenC
char sendmsgD2<EBrcvmsgD2<EC
struct sockaddr!in servaddrBcliaddrC
printf,[$nter the port no:Gn\-C
scanf,FHdFB:sport-C
sdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,sd><-
printf,FCanJt Create GnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,sport-C
sd2I+ind,sdB,struct sockaddrM-:servaddrBsiNeof,servaddr--C
if,sd2><-
printf,FCanJt 4indGnF-C
else
printf,FGn 4indedGnF-C
listen,sdB0-C
do
A
printf,F$nter the client no to communicateGnF-C
scanf,FHdFB:i-C
if,iII<-
e9it,<-C
printf,FClient Hd is connectedGnFBi-C
clilenIsiNeof,cliaddr-C
nsdIaccept,sdB,struct sockaddrM-:cliaddrB:clilen-C
if,nsd><-
printf,FCanJt AcceptGnF-C
else
printf,FAcceptedGnF-C
do
A
recv,nsdBrcvmsgB2<B<-C
printf,FHsFBrcvmsg-C
fgets,sendmsgB2<Bstdin-C
lenIstrlen,sendmsg-C
sendmsgDlen-1EIJG<JC
send,nsdBsendmsgB2<B<-C
wait,2<-C
Owhile,strcmp,sendmsgBF+)eF-PI<-C
Owhile,iPI<-C
O
CLIENT 0 1
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
main,-
A
int csdBcportBlenC
char sendmsgD2<EBrevmsgD2<EC
struct sockaddr!in servaddrC
printf,F$nter the port no:GnF-C
scanf,FHdFB:cport-C
csdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,csd><-
printf,FCanJt CreateGnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,cport-C
if,connect,csdB,struct sockaddrM-:servaddrBsiNeof,servaddr--><-
printf,FCanJt ConnectGnF-C
else
printf,FConnectedGnF-C
do
A
fgets,sendmsgB2<Bstdin-C
lenIstrlen,sendmsg-C
sendmsgDlen-1EIJG<JC
send,csdBsendmsgB2<B<-C
wait,2<-C
recv,csdBrevmsgB2<B<-C
printf,FHsFBrevmsg-C
O
while,strcmp,revmsgBF+)eF-PI<-C
O
CLIENT 0 "
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
main,-
A int csdBcportBlenC
char sendmsgD2<EBrevmsgD2<EC
struct sockaddr!in servaddrC
printf,F$nter the port no:GnF-C
scanf,FHdFB:cport-C
csdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,csd><-
printf,FCanJt CreateGnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,cport-C
if,connect,csdB,struct sockaddrM-:servaddrBsiNeof,servaddr--><-
printf,FCanJt ConnectGnF-C
else
printf,FConnectedGnF-C
do
A
fgets,sendmsgB2<Bstdin-C
lenIstrlen,sendmsg-C
sendmsgDlen-1EIJG<JC
send,csdBsendmsgB2<B<-C
wait,2<-C
recv,csdBrevmsgB2<B<-C
printf,FHsFBrevmsg-C
O
while,strcmp,revmsgBF+)eF-PI<-C
O
OUTPUT:
SERVER SIDE:
D1me2Qlocalhost RES vi (ultiuserserver.c
D1me2Qlocalhost RES cc (ultiuserserverc
D1me2Qlocalhost RES .@a.out
$nter the port no
70.*
socket is created
4inded
$nter the client to communicate: 1
Client 1 is connected
Accepted
hiiiii
4)eeeeee
$nter the client no to communicate: 2
client 2 is connected
Accepted
hiiiiiiiiii
hello
$nter the client no to communicate: <
CLIENT SIDE 1:
D1me2Qlocalhost RES vi multiuserclient1.c
D1me2Qlocalhost RES cc multiuserclient1.c
D1me2Qlocalhost RES .@a.out
$nter the port no
70.*
Socket is created
Connected
hiiiiii
4)eeeee
CLIENT SIDE 0":
D1me2Qlocalhost RES vi multiuserclient2.c
D1me2Qlocalhost RES cc multiuserclient2.c
D1me2Qlocalhost RES .@a.out
$nter the port no
70.*
Socket is created
Connected
Uiiiiiiiii
hello
RESULT
Thus the C program for chat multiclient-serve chat program using
tcp has +een e9ecuted successfull).
Ex.No:/$
ELECTRONIC MAIL
Date:
AIM:
To email the contents of a file.
ALGORITHM:
Step 1: Start the Program
Step 2: 2et the input from the user for the file to mail to the list of
mailid5s.
Step *: The file siNe is compared with the mailid5s siNe. "f the file
siNe is greater than mailid5s siNe then displa) the errorB
otherwise go to step ..
Step .: The contents of a file are transferred using mail statement
followed +) the su+Zect.
Step 0: The user can open the "n+o9 to see the incoming messages
+) specif)ing 3mail userid5
Step 1: Stop the program.
PROGRAM
=include >stdli+.h?
=include >string.h?
=define cknull,9- if,,9-II#VWW- Aperror,FF-C
e9it,$^"T!A"WV'$-CO
=define cknltN,9- if,,9-><- Aperror,FF-C e9it,$^"T!A"WV'$-CO
=define W"ST!W$# .
@@char MfIFsam.t9tFC
void email!it,char Mfilename-C
main,-
A
char fnameD10EC
printf,Fenter the filenameGnF-C
scanf,FHsFBfname-C
email!it,fname-C
O
void email!it,char Mfilename-
A
char tmpD201EIA<9<OC
char fp4ufferD.<<EIA<9<OC
char email!listDW"ST!W$#E
D201EIAAFmecse*Qlocalhost.localdomainFOBA<9<OOC
int iI<C
for,iI<CMemail!listDiE?<9<CiXX-
A
cknull,strcp),tmpB email!listDiE--C
cknltN,sprintf ,fp4ufferBFmail -s JHs HsJ Hs > HsFB
FPlease 'eview:FB filenameB tmpBfilename--C
if,s)stem ,fp4uffer-II,-1--
A
perror,Femail failureF-C
e9it,$^"T!A"WV'$-C
O
O
O
OUTPUT:
D1me2Qlocalhost RES vi email.c
D1me2Qlocalhost RES cc email.c
D1me2Qlocalhost RES .@a.out
$nter the file name: sample.c
D1me2Qlocalhost RES@home@1me1@dead.letterT.saved message in
@home@1me1@dead.letterT..
RESULT
Thus the program for developing $-mail application is e9ecuted
and the output is verified successfull).
Ex. No:1 SIMULATION O& SIMPLE NET)OR2
Date: MANAGEMENT PROTOCOLS
AIM:
To write a C program for simulation of Simple #etwork
management Protocols.
ALGORITHM:
MANAGER:
Step 1: Start the program.
Step 2: Create an unnamed socket for client using socket , -
s)stem.
Step *: Call with parameters A!"#$T as domain and
S%C&!ST'$A( as t)pe.
Step .: #ame the socket using +ind , - s)stem call.
Step 0: #ow connect the socket to agent using connect , - s)stem
call.
Step 1: 2et the input for the t)pe of information needed from the
agent.
Step 6: "f the input is e/ual to 3TCP connection5 then goto ne9t step
else "f it is e/ual to 3s)stem5 2oto step 8.
Step 7: 'ead the input for the o+ZectB send it and receive the details
of the TCP connection of that o+Zect from the agent. 2o to
step 1<.
Step 8: 'ead the input for the o+ZectB send it and receive the details
of the s)stem from the agent. 2o to step 1<.
Step 1<: 'eceive the messageB print and terminate the process.
Step 11: Stop the process.
AGENTS
Step 1: Start the program.
Step 2: Create an unnamed socket for the server using the
parameters A!"#$T as domain and the S%C&!ST'$A(
as t)pe.
Step *: #ame the socket using +ind, - s)stem call with the
parameters server!sockfd and the manager
address,sin!addr and sin!sport-.
Step .: Create a connection /ueue and wait for manager using the
listen, - s)stem call with the num+er of manager re/uest
as parameters.
Step 0: Accept the connection using accept, - s)stem call when
manager re/uests for connection.
Step 1: 'eceive the message from the manager. "f the re/uest is for
3TCP connections5 then send the details of the re/uested
o+ZectB else if the re/uest is for 3S)stem5 then send the
details of the re/uested s)stem.
Step 6: Stop the program e9ecution.
PROGRAM:
AGENT1
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
=include>string.h?
main,-
A
int iBsdBsd2BnsdBclilenBsportBlenC
char sendmsgD2<EBrecvmsgD1<<EC
char oidD0ED1<EIAFclient1FBFclient2FBFclient*FBFcleint.FBFclient0FOC
char wsiNeD0ED0EIAF0FBF1<FBF10FBF*FBF1FOC
struct sockaddr!in servaddrBcliaddrC
printf,F"Jm the Agent - TCP ConnectionGnF-C
printf,FGn$nter the Server portF-C
printf,FGn!!!!!!!!!!!!!!!!!!!!!GnF-C
scanf,FHdFB:sport-C
sdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,sd><-
printf,FCanJt Create GnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,sport-C
sd2I+ind,sdB,struct sockaddrM-:servaddrBsiNeof,servaddr--C
if,sd2><-
printf,F CanJt 4indGnF-C
else
printf,FGn 4indedGnF-C
listen,sdB0-C
clilenIsiNeof,cliaddr-C
nsdIaccept,sdB,struct sockaddrM-:cliaddrB:clilen-C
if,nsd><-
printf,FCanJt AcceptGnF-C
else
printf,FAcceptedGnF-C
recv,nsdBrecvmsgB1<<B<-C
for ,iI<Ci>0CiXX-
A
if,strcmp,recvmsgBoidDiE-II<-
A
send,nsdBwsiNeDiEB1<<B<-C
+reakC
O
O
O
AGENT "
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
=include>string.h?
main,-
A
int iBsdBsd2BnsdBclilenBsportBlenC
char sendmsgD2<EBrecvmsgD1<<EC
char oidD0E
D1<EIAFS)stem1FBFS)stem2FBFS)stem*FBFS)stem.FBFS)stem0FOC
char mdateD0ED10EIAF1-1<-<80FBF1<-<*-
<7FBF1..<*.71FBF11.<6.<6FBF16.12.66FOC
char timeD0ED10EIAF8amFBF1<pmFBF11amFBF12.*<pmFBF11.*<amFOC
struct sockaddr!in servaddrBcliaddrC
printf,F$nter the Server portF-C
printf,FGn!!!!!!!!!!!!!!!!!!!!!GnF-C
scanf,FHdFB:sport-C
sdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,sd><-
printf,FCanJt Create GnF-C
else
printf,FSocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,sport-C
sd2I+ind,sdB,struct sockaddrM-:servaddrBsiNeof,servaddr--C
if,sd2><-
printf,F CanJt 4indGnF-C
else
printf,FGn 4indedGnF-C
listen,sdB0-C
clilenIsiNeof,cliaddr-C
nsdIaccept,sdB,struct sockaddrM-:cliaddrB:clilen-C
if,nsd><-
printf,FCanJt AcceptGnF-C
else
printf,FAcceptedGnF-C
recv,nsdBrecvmsgB1<<B<-C
for,iI<Ci>0CiXX-
A
if,strcmp,recvmsgBoidDiE-II<-
A
send,nsdBmdateDiEB1<<B<-C
send,nsdBtimeDiEB1<<B<-C
+reakC
O
O
O
MANAGER
=include>stdio.h?
=include>s)s@t)pes.h?
=include>netinet@in.h?
main,-
A
int csdBcportBlenBiC
char sendmsgD2<EBrcvmsgD1<<EBrmsgD1<<EBoidD1<<EC
struct sockaddr!in servaddrC
printf,F$nter the portGnF-C
scanf,FHdFB:cport-C
csdIsocket,A!"#$TBS%C&!ST'$A(B<-C
if,csd><-
printf,FCanJt CreateGnF-C
else
printf,FScocket is CreatedGnF-C
servaddr.sin!famil)IA!"#$TC
servaddr.sin!addr.s!addrIhtonl,"#AKK'!A#L-C
servaddr.sin!portIhtons,cport-C
if,connect,csdB,struct sockaddrM-:servaddrBsiNeof,servaddr--><-
printf,FCanJt ConnectGnF-C
else
printf,FConnectedGnF-C
printf,FGn 1.TCP ConnectionGnF-C
printf,FGn 2. S)stem GnF-C
printf,F$nter the num+er for the t)pe of informtion needed....GnF-C
scanf,FHdFB:i-C
if,iII1-
A
printf,F$nter the %+Zect "K for ClientGnF-C
scanf,FHsFBoid-C
send,csdBoidB1<<B<-C
recv,csdBrmsgB1<<B<-C
printf,FGn The window siNe of Hs is HsFBoidBrmsg-C
O
else
A
printf,FGn$nter the %+Zect "K for the S)stemGnF-C
scanf,FHsFBoid-C
send,csdBoidB1<<B<-C
recv,csdBrmsgB1<<B<-C
printf,FGnThe (anufacturing date for Hs is HsFBoidBrmsg-C
recv,csdBrmsgB1<<B<-C
printf,FGnThe time of Wast VtiliNation for Hs is HsFBoidBrmsg-C
O
O
OUTPUT:
AGENT1:
D1me1.Qlocalhost RES vi Agent1.c
D1me1.Qlocalhost RES cc Agent1.c
D1me1.Qlocalhost RES .@a.out
"Jm the Agent - TCP Connection
$nter the Server port
!!!!!!!!!!!!!!!!!!!!!
70.*
Socket is created
4inded
Accepted
MANGER:
D1me1.Qlocalhost RES vi (anager.c
D1me1.Qlocalhost RES cc (anger.c
D1me1.Qlocalhost RES .@a.out
$nter the port
70.*
Socket is Created
Connected
1.TCP Connection
2. S)stem
$nter the num+er for the t)pe of information needed: 1
$nter the %+Zect "K for Client: Client1
The window siNe of client1 is 0
AGENT":
D1me1.Qlocalhost RES vi Agent2.c
D1me1.Qlocalhost RES cc Agent2.c
D1me1.Qlocalhost RES .@a.out
$nter the Server port
!!!!!!!!!!!!!!!!!!!!!
70.*
Socket is Created
4inded
Accepted
MANGER:
D1me1.Qlocalhost RES vi (anager.c
D1me1.Qlocalhost RES cc (anger.c
D1me1.Qlocalhost RES .@a.out
$nter the port
70.*
Socket is Created
Connected
1.TCP Connection
2. S)stem
$nter the num+er for the t)pe of informtion needed: 2
$nter the %+Zect "K for Client: S)stem*
The (anufacturing date for s)stem* is 1..<*.71
The time of last utiliNation for s)stem* is 11am
RESULT
Thus the C program for simple network management protocols has
+een e9ecuted successfull).

Ex. No:3 STUD+ O& NET)OR2 SIMULATOR
Date: PAC2AGES
AIM:
To stud) a+out #S2 - #etwork Simulator
INTRODUCTION:
#S is a discrete event simulator targeted at networking research.
#S provides su+stantial support for simulation of TCPB routingB and
multicast protocols over wired and wireless ,local and satellite- networks.
#S +egan as a variant of the '$AW network simulator in 1878 and has
evolved su+stantiall) over the past few )ears.
"n 1880 ns development was supported +) KA'PA through the
Y"#T proZect at W4WB ^ero9 PA'CB VC4B and VSC@"S". Currentl) ns
development is support through KA'PA with SA(A# and through #S
with C%#S$'B +oth in colla+oration with other researchers including
AC"'". #S has alwa)s included su+stantial contri+utions from
other researchersB including wireless code from the VC4 Kaedelus and
C(V (onarch proZects and Sun (icros)stems.
The network simulator ns-2 is a widel) accepted discrete event
network simulatorB activel) used for wired and wireless network
simulations. "t has a highl) detailed model of the lower la)ers ,Ph)sical
and (AC- of wireless "$$$ 7<2.11 networks.#s-2 has also an emulation
featureB i.e. the a+ilit) to introduce the simulator into a live network and
to simulate a desired network +etween real applications in real-time.
;ithin the scope of this proZect we developed some methods and
e9tensions to the ns-2 to com+ine wireless network simulation and
network emulation.
OVERVIE):
#S is an event driven network simulator developed at VC 4erkele)
that simulates variet) of "P networks. "t implements network protocols
such as TCP and VKPB traffic source +ehavior such as TPB TelnetB ;e+B
C4' and Y4'B router /ueue management mechanism such as Krop TailB
'$K and C4_B routing algorithms such as KiZkstraB and more. #S also
implements multicasting and some of the (AC la)er protocols for WA#
simulations. The #S proZect is now a part of the Y"#T proZect that
develops tools for simulation results displa)B anal)sis and converters that
convert network topologies generated +) well-known generators to #S
formats.
Currentl)B #S ,version 2- written in CXX and %Tcl ,Tcl script
language with %+Zect-oriented e9tensions developed at ("T- is availa+le.
This document talks +riefl) a+out the +asic structure of #SB and e9plains
in detail how to use #S mostl) +) giving e9amples. (ost of the figures
that are used in descri+ing the #S +asic structure and network
components are from the 0th Y"#T@#S Simulator Tutorial@;orkshop
slides and the #S (anual ,formerl) called F#S #otes and
KocumentationF-B modified little +it as needed.
Si45li6ied U7e87 Vie9 o6 NS
"n a simplified userJs viewB #S is %+Zect-oriented Tcl ,%Tcl- script
interpreter that has a simulation event scheduler and network component
o+Zect li+rariesB and network setup ,plum+ing- module li+raries ,actuall)B
plum+ing modules are implemented asmem+er functions of the +ase
simulator o+Zect-. "n other wordsB to use #SB )ou program in %Tcl
script language.
To setup and run a simulation networkB a user should write an %Tcl
script that initiates an event schedulerB sets up the network topolog) using
the network o+Zects and the plum+ing functions in the li+rar)B and tells
traffic sources when to start and stop transmitting packets through the
event scheduler. The term Fplum+ingF is used for a network setupB
+ecause setting up a network is plum+ing possi+le data paths among
network o+Zects +) setting the Fneigh+orF pointer of an o+Zect to the
address of an appropriate o+Zect.
;hen a user wants to make a new network o+ZectB he or she can
easil) make an o+Zect either +) writing a new o+Zect or +) making a
compound o+Zect from the o+Zect li+rar)B and plum+ the data path through
the o+Zect. This ma) sound like complicated Zo+B +ut the plum+ing %Tcl
modules actuall) make the Zo+ ver) eas). The power of #S comes from
this plum+ing.
Another maZor component of #S +eside network o+Zects is the
event scheduler. An event in #S is a packet "K that is uni/ue for a packet
with scheduled time and the pointer to an o+Zect that handles the event. "n
#SB an event scheduler keeps track of simulation time and fires all the
events in the event /ueue scheduled for the current time +) invoking
appropriate network componentsB which usuall) are the ones who issued
the eventsB and let them do the appropriate action associated with packet
pointed +) the event.
#etwork components communicate with one another passing
packetsB however this does not consume actual simulation time. All the
network components that need to spend some simulation time handling a
packet ,i.e. need a dela)- use the event scheduler +) issuing an event for
the packet and waiting for the event to +e fired to itself +efore doing
further action handling the packet. or e9ampleB a network switch
component that simulates a switch with 2< microseconds of switching
dela) issues an event for a packet to +e switched to the scheduler as an
event 2< microsecond later. The scheduler after 2< microseconds
de/ueues the event and fires it to the switch componentB which then
passes the packet to an appropriate output link component. Another use of
an event scheduler is timer.
#S is written not onl) in %Tcl +ut in CXX also. or efficienc)
reasonB #S separates the data path implementation from control path
implementations. "n order to reduce packet and event processing time
,not simulation time-B the event scheduler and the +asic network
component o+Zects in the data path are written and compiled using CXX.
These compiled o+Zects are made availa+le to the %Tcl interpreter
through an %Tcl linkage that creates a matching %Tcl o+Zect for
each of the CXX o+Zects and makes the control functions and the
configura+le varia+les specified +) the CXX o+Zect act as mem+er
functions and mem+er varia+les of the corresponding %Tclo+Zect. "n this
wa)B the controls of the CXX o+Zects are given to %Tcl. "t is also possi+le
to add mem+er functions and varia+les to a CXX linked %Tcl o+Zect. The
o+Zects in CXX that do not need to +e controlled in a simulation or
internall) used +) another o+Zect do not need to +e linked
to %Tcl. WikewiseB an o+Zect ,not in the data path- can +e entirel)
implemented in %Tcl.

C++ and OTcl: The Duality
Architectural View of NS
The event schedulers and most of the network components are
implemented in CXX and availa+le to %Tcl through an %Tcl linkage that
is implemented using tclcl. The whole thing together makes #SB which is
a %% e9tended Tcl interpreter with network simulator li+raries.
This section +riefl) e9amined the general structure and architecture of
#S. At this pointB one might +e wondering a+out how to o+tain #S
simulation results.
;hen a simulation is finishedB #S produces one or more te9t-+ased
output files that contain detailed simulation dataB if specified to do so in
the input Tcl ,or more specificall)B %Tcl- script. The data can +e used for
simulation anal)sis ,two simulation result anal)sis e9amples are
presented in later sections- or as an input to a graphical simulation
displa)
tool called #etwork Animator ,#A(- that is developed as a part of Y"#T
proZect.
#A( has a nice graphical user interface similar to that of a CK
pla)er ,pla)B fast forwardB rewindB pause and so on-B and also has a
displa) speed controller. urthermoreB it can graphicall) present
information such as throughput and num+er of packet drops at each linkB
although the graphical information cannot +e used for accurate simulation
anal)sis.
This section shows a simple #S simulation script and e9plains
what each line does. $9ample * is an %Tcl script that creates the simple
network configuration and runs the simulation scenario.

A Si45le Net9o: To5olo;< and Si4=lation S%enaio
This network consists of . nodes ,n<B n1B n2B n*- as shown in
a+ove figure. The duple9 links +etween n< and n2B and n1 and n2 have 2
(+ps of +andwidth and 1< ms of dela). The duple9 link +etween n2 and
n* has 1.6 (+ps of +andwidth and 2< ms of dela). $ach node uses a
KropTail /ueueB of which the ma9imum siNe is 1<. A FtcpF agent is
attached to n<B and a connection is esta+lished to a tcp FsinkF agent
attached to n*. As defaultB the ma9imum siNe of a packet that a FtcpF
agent can generate is 1&4)te. A tcp FsinkF agent generates and sends
AC& packets to the sender ,tcp agent- and frees the received packets. A
FudpF agent that is attached to n1 is connected to a FnullF agent attached
to n*. A FnullF agent Zust frees the packets received.
The following is the e9planation of the script a+ove. "n generalB an #S
script starts with making a Simulator o+Zect instance.
7et n7 >ne9 Si4=lato?:
2enerates an #S simulator o+Zect instanceB and assigns it to
varia+le ns ,italics is used for varia+les and values in this section-.
1."nitialiNe the packet format,ignore this for now-
2.Create a scheduler,default is calendar scheduler-
*.Select the default address format,ignore this for now-
The FSimulatorF o+Zect has mem+er functions that do the following:
1. Create compound o+Zects such as nodes and links ,descri+ed later-
2. Connect network component o+Zects created ,e9. attach-agent-
*. Set network component parameters ,mostl) for compound o+Zects-
.. Create connections +etween agents.
0. Specif) #A( displa) options
(ost of mem+er functions are for simulation setup and schedulingB
however some of them are for the #A( displa). The FSimulatorF o+Zect
mem+er function implementations are located in the Fns-2@tcl@li+@ns-
li+.tclF file.
Sns color fid color: is to set color of the packets for a flow
specified +) the flow id ,fid-.
This mem+er function of FSimulatorF o+Zect is for the #A(
displa)B and has no effect on the actual simulation. ` Sns namtrace-all file-
descriptor: This mem+er function tells the simulator to record simulation
traces in #A( input format. "t also gives the file name that the trace will
+e written to later +) the command Sns flush-trace. Similarl)B the mem+er
function trace-all is for recording the simulation trace in a general format.
proc finish AO: is called after this simulation is over +) the command Sns
at 0.< FfinishF.
"n this functionB post-simulation processes are specified.
set n< DSns nodeE: The mem+er function node creates a node. A
node in #S is compound o+Zect made of address and port classifiers
,descri+ed in a later section-. Vsers can create a node +) separatel)
creating an address and a port classifier o+Zects and connecting them
together. UoweverB this mem+er function of Simulator o+Zect makes the
Zo+ easier. To see how a node is createdB look at the files: Fns-
2@tcl@li+s@ns-li+.tclF and Fns2@tcl@li+s@nsnode.tclF.
Sns duple9-link node1 node2 +andwidth dela) /ueue-t)pe: creates
two simple9 links of specified +andwidth and dela)B and connects the two
specified nodes.
"n #SB the output /ueue of a node is implemented as a part of a
linkB therefore users should specif) the /ueue-t)pe when creating links.
"n the a+ove simulation scriptB KropTail /ueue is used. "f the reader
wants to use a '$K /ueueB simpl) replace the word KropTail with '$K.
The #S implementation of a link is shown in a later section. Wike a
nodeB a link is a compound o+ZectB and users can create its su+-o+Zects
and connect them and the nodes.
Wink source codes can +e found in Fns-2@tcl@li+s@ns-li+.tclF and Fns-
2@tcl@li+s@ns-link.tclF files. %ne thing to note is that )ou can insert error
modules in a link component to simulate a loss) link ,actuall) users can
make and insert an) network o+Zects-. 'efer to the #S documentation to
find out how to do this. ` Sns /ueue-limit node1 node2 num+er: This line
sets the /ueue limit of the two simple9 links that connect node1 and
node2 to the num+er specified. At this pointB the authors do not know
how man) of these kinds of mem+er functions of Simulator o+Zects are
availa+le and what the) are. Please take a look at Fns-2@tcl@li+s@ns-li+.tclF
and Fns- 2@tcl@li+s@ns-link.tclFB or #S documentation for more
information.
Sns duple9-link-op node1 node2 ...: The ne9t couple of lines are
used for the #A( displa). To see the effects of these linesB users can
comment these lines out and tr) the simulation. #ow that the +asic
network setup is doneB the ne9t thing to do is to setup traffic agents such
as TCP and VKPB traffic sources such as TP and C4'B and attach them
to nodes and agents respectivel). ` set tcp Dnew Agent@TCPE: This line
shows how to create a TCP agent. 4ut in generalB users can create an)
agent or traffic sources in this wa). Agents and traffic sources are in
fact +asic o+Zects ,not compound o+Zects-B mostl) implemented in CXX
and linked to %Tcl. ThereforeB there are no specific Simulator o+Zect
mem+er functions that create these o+Zect instances.
To create agents or traffic sourcesB a user should know the class
names these o+Zects ,Agent@TCPB Agnet@TCPSinkB Application@TP and
so on-. This information can +e found in the #S documentation or partl)
in this documentation. 4ut one shortcut is to look at the Fns-2@tcl@li+s@ns-
default.tclF file. This file contains the default configura+le parameter
value settings for availa+le network o+Zects. ThereforeB it works as a good
indicator of what kind of network o+Zects are availa+le in #S and what
are the configura+le parameters.
Sns attach-agent node agent: The attach-agent mem+er function
attaches an agent o+Zect created to a node o+Zect. Actuall)B what this
function does is call the attach mem+er function of specified nodeB which
attaches the given agent to itself. ThereforeB a user can do the same thing
+)B for e9ampleB Sn< attach Stcp.
Sns connect agent1 agent2: After two agents that will communicate
with each other are createdB the ne9t thing is to esta+lish a logical network
connection +etween them. This line esta+lishes a network connection +)
setting the destination address to each othersJ network and port address
pair.Assuming that all the network configuration is doneB the ne9t thing to
do is write a simulation scenario ,i.e. simulation scheduling-. The
Simulator o+Zect has man) scheduling mem+er functions. UoweverB the
one that is mostl) used is the following:
Sns at time FstringF: This mem+er function of a Simulator o+Zect
makes the scheduler ,scheduler! is the varia+le that points the scheduler
o+Zect created +) Dnew SchedulerE command at the +eginning of the
script- to schedule the e9ecution of the specified string at given
simulation time. or e9ampleB Sns at <.1 FSc+r startF will make the
scheduler call a start mem+er function of the C4' traffic source o+ZectB
which starts the C4' to transmit data. "n #SB usuall) a traffic source does
not transmit actual dataB +ut it notifies the underl)ing agent that it has
some amount of data to transmitB and the agentB Zust knowing how much
of the data to transferB creates packets and sends them.
After all network configurationB scheduling and post-simulation
procedure specifications are doneB the onl) thing left is to run the
simulation. This is done +) Sns run.
NET)OR2 COMPONENTS
Class Hierarchy (Partial)
The root of the hierarch) is the Tcl%+Zect class that is the
superclass of all %Tcl li+rar) o+Zects ,schedulerB network componentsB
timers and the other o+Zects including #A( related ones-. As an ancestor
class of Tcl%+ZectB #s%+Zect class is the superclass of all +asic network
component o+Zects that handle packetsB which ma) compose compound
network o+Zects such as nodes and links.
The +asic network components are further divided into two
su+classesB Connector and ClassifierB +ased on the num+er of the possi+le
output data paths. The +asic network o+Zects that have onl) one output
data path are under the Connector classB and switching o+Zects that have
possi+le multiple output data paths are under the Classifier class.
NODE AND ROUTING:
A node is a compound o+Zect composed of a node entr) o+Zect and
classifiers .There are two t)pes of nodes in #S. A unicast node has an
address classifier that does unicast routing and a port classifier. A
multicast nodeB in additionB has a classifier that classif) multicast packets
from unicast packets and a multicast classifier that performs multicast
routing.

Node (nicast and !ulticast)
"n #SB Vnicast nodes are the default nodes. To create (ulticast
nodes the user must e9plicitl) notif) in the input %Tcl scriptB right after
creating a scheduler o+ZectB that all the nodes that will +e created are
multicast nodes. After specif)ing the node t)peB the user can also select a
specific routing protocol other than using a default one.
Uni%a7t
- Sns rtproto t)pe
- t)pe: StaticB SessionB KYB costB multi-path
` (ulticast
- Sns multicast ,right after set Sns Dnew SchedulerE-
- Sns mrtproto t)pe
- t)pe: Ctr(castB K(B STB 4ST
LIN2:
A link is another maZor compound o+Zect in #S. ;hen a user
creates a link using a duple9-link mem+er function of a Simulator o+ZectB
two simple9 links in +oth directions are created.
"in#

%ne thing to note is that an output /ueue of a node is actuall)
implemented as a part of simple9 link o+Zect. Packets de/ueued from a
/ueue are passed to the Kela) o+Zect that simulates the link dela)B and
packets dropped at a /ueue are sent to a #ull Agent and are freed there.
inall)B the TTW o+Zect calculates Time To Wive parameters for each
packet received and updates the TTW field of the packet.
"n #SB network activities are traced around simple9 links. "f the
simulator is directed to trace network activities ,specified using Sns trace-
all file or Sns namtrace-all file-B the links created after the command will
have the following trace o+Zects inserted.Vsers can also specificall)
create a trace o+Zect of t)pe t)pe +etween the given src and dst nodes .
$nsertin% Trace O&'ects
;hen each inserted trace o+Zect ,i.e. $n/TB Ke/TB KrpT and
'ecvT- receives a packetB itwrites to the specified trace file without
consuming an) simulation timeB and passes the packet to the ne9t
network o+Zect. The trace format will +e e9amined in the 2eneral
Anal)sis $9ample section. _ueue (onitor 4asicall)B tracing o+Zects are
designed to record packet arrival time at which the) are located. Although
a user gets enough information from the traceB he or she might +e
interested in what is going on inside a specific output /ueue. or
e9ampleB a user interested in '$K /ueue +ehavior ma) want to measure
the d)namics of average /ueue siNe and current /ueue siNe of a specific
'$K /ueue ,i.e. need for /ueue monitoring-. _ueue monitoring can +e
achieved using /ueue monitor o+Zects and snoop /ueue o+Zects
!onitorin% (ueue
;hen a packet arrivesB a snoop /ueue o+Zect notifies the /ueue
monitor o+Zect of this event. The /ueue monitor using this information
monitors the /ueue. A '$K /ueue monitoring e9ample is shown in the
'$K _ueue (onitor $9ample section. #ote that snoop /ueue o+Zects can
+e used in parallel with tracing o+Zects even though it is not shown in the
a+ove figure.
PAC2ET &LO) E'AMPLE:
Vntil nowB the two most important network components ,node and
link- were e9amined. The network consist of two nodes ,n< and n1- of
which the network addresses are < and 1 respectivel). A TCP agent
attached to n< using port < communicates with a TCP sink o+Zect
attached to n1 port <. inall)B an TP application ,or traffic source- is
attached to the TCP agentB asking to send some amount of data.
Pac#et )low *+a,-le
#ote that the a+ove figure does not show the e9act +ehavior of a
TP over TCP. "t onl) shows the detailed internals of simulation network
setup and a packet flow.
PAC2ET:
A #S packet is composed of a stack of headersB and an optional
data space As +riefl) mentioned in the FSimple Simulation $9ampleF
sectionB a packet header format is initialiNed when a Simulator o+Zect is
createdB where a stack of all registered ,or possi+l) usea+le- headersB such
as the common header that is commonl) used +) an) o+Zects as neededB"P
headerB TCP headerB 'TP header ,VKP uses 'TP header- and trace
headerB is definedB and the offset of each header in the stack is recorded.
;hat this means is that whether or not a specific header is usedB a
stack composed of all registered headers is created when a packet is
allocated +) an agentB and a network o+Zect can access an) header in the
stack of a packet it processes using the corresponding offset value.
NS Pac#et )or,at

Vsuall)B a packet onl) has the header stack ,and a data space
pointer that is null-. Although a packet can carr) actual data ,from an
application- +) allocating a data spaceB ver) few application and agent
implementations support this. This is +ecause it is meaningless to carr)
data around in a non-real-time simulation. UoweverB if )ou want to
implement an application that talks to another application cross the
networkB )ou might want to use this feature with a little modification in
the underl)ing agent implementation. Another possi+le approach would
+e creating a new header for the application and modif)ing the
underl)ing agent to write data received from the application to the new
header. The second approach is shown as an e9ample in a later section
called FAdd #ew Application and AgentF.
RESULT:
Thus the details a+out #S2,#etwork Simulator 2- has +een studied.
Ex. No: 1@
Date: STUD+ O& OPNET
Date:
AIM:
To stud) a+out %P#$T - #etwork Simulator
INTRODUCTION:
%P#$T ,%ptimiNed #etwork $ngineering Tools- is a commercial
tool from ("W* "nc. "t is +eing developed for almost 10 )ears. As
ever)one should guessB no much technical detail are availa+le a+out the
internals.
USE:
#etwork with several hundreds of nodes can +e simulatedB +ut it
would take time for the computation. %P#$T is used +) companies like
Thomson-CS or C#$T which use it to model AT( networks and
validate various la)ers protocolsB packet switched radio networks. An
e9ample of use of %P#$T is 2eorge (ason Vniversit) ,_ualit) of
Service "P #etwork Simulation-.
THE PAC2AGE
The software comprises several tools and is divided in several
partsB %P#$T (odeler and %P#$T PlannerB the (odel Wi+rar)B and the
Anal)sis tool. eatures included in this generic simulator are an event-
driven scheduled simulation kernelB integrated anal)sis tools for
interpreting and s)nthesiNing output dataB graphical specification of
models and a hierarchical o+Zect-+ased modeling.
%P#$T (odeler is intended for modelingB simulating and
anal)Ning the performance of large communications networksB computer
s)stems and applications. Common uses are assessing and feasi+ilit) of
new designsB optimiNing alread) developed communication s)stems and
predicting performance. The modeling methodolog) of %P#$T is
organiNed in a hierarchical structure.
At the lowest levelB Process models are structured as a finite state
machine. State and transitions are specified graphicall) using state-
transition diagrams whereas conditions that specif) what happen within
each state are programmed with a C-like language called Proto-C. Those
processes and +uilt-in modules in %P#$T ,source and destination
modulesB traffic generatorsB /ueuesB ...- are then configured with menus
and organiNed into data flow diagrams that represent nodes using the
graphical #ode $ditor. Vsing a graphical #etwork $ditorB nodes and links
are selected to +uild up the topolog) of a communication network.
The Anal)sis Tool provides a graphical environment to view and
manipulate data collected during simulation runs. 'esults can +e anal)Ned
for an) network element. %P#$T Planner is an application that allows
administrators to evaluate the performance of communications networks
and distri+uted s)stemsB without programming or compiling. Planner
anal)ses +ehavior and performance +) discrete-event simulations. (odels
are +uilt using a graphical interface. The user onl) chooses pre-defined
models ,from the ph)sical la)er to the application- from the li+rar) and
sets attri+utes. The user cannot define new modelsB he should contact
("W*Js modeling service.
The modeling li+raries are included with %P#$T (odeler and
%P#$T Planner and contains protocols and anal)sis environmentsB
among them AT(B TCPB "PB rame 'ela)B KK"B $thernetB link models
such as point-to-point or +usB /ueueing service disciplines such as irst-
in- irst-%ut ,"%-B Wast-"n-irst-%ut ,W"%-B priorit) non-preemptive
/ueueingB shortest first Zo+B round-ro+in or preempt and resume.
%P#$T (odeler is the industr)Js leading environment for network
modeling and simulationB allowing )ou to design and stud)
communication networksB devicesB protocolsB and applications with
unmatched fle9i+ilit) and scala+ilit). (odeler is used +) the worldJs
largest network e/uipment manufacturers to accelerate the ':K of
network devices and technologies such as Yo"PB TCPB %SPv*B (PWSB
"Pv1B and more.
#etworking technolog) has +ecome too comple9 for traditional
anal)tical methods or Frules of thum+F to )ield an accurate understanding
of s)stem +ehavior. Since 1871B %P#$T Technologies "nc.B has +een the
leader in developing predictive software solutions for networking
professionals. %P#$T software ena+les its users to optimiNe the
performance and ma9imiNe the availa+ilit) of communications networks
and applications.
%P#$T is the state-of-art network simulation tool for modelingB
simulating and anal)sing theperformance of
i. Communication #etworksB Kistri+uted S)stems
ii. Computer s)stems and Applications.
Product modules provide value-added capa+ilities to %P#$TJs intelligent
network management software. (odules span a wide range of
applications and receive regular updates under %P#$TJs maintenance
program.
OPNET MODULES:
1. (odeler
2. Terrain (odeling (odule ,T((-
*. Uigh Wevel Architecture ,UWA-
MODELER:
%P#$T (odeler is intended for modelingB simulating and
anal)sing the performance of large communications networksB computer
s)stems and applications. Common uses are assessing and feasi+ilit) of
new designsB optimiNing alread) developed communication s)stems and
predicting performance.
The modeling methodolog) of %P#$T is organiNed in a
hierarchical structure. At the lowest levelB Process models are structured
as a finite state machine. State and transitions are specified graphicall)
using state-transition diagrams whereas conditions that specif) what
happen within each state are programmed with a C-like language called
Proto-C. Those processes and +uilt-in modules in %P#$T ,source and
destination modulesB traffic generatorsB /ueuesB ...- are then configured
with menus and organiNed into data flow diagrams that represent nodes
using the graphical #ode $ditor. Vsing a graphical #etwork $ditorB nodes
and links are selected to +uild up the topolog) of a communication
network.
TERRAIN MODELING MODULE -TMM.
4uilding on the capa+ilities of %P#$TJs ;ireless (oduleB the
Terrain (odeling (odule provides the ne9t level of accurac) and control
for wireless network design and planning. This module allows )ou to
model environmental effects on wireless network communications
an)where.
eaturing an open-source Wongle)-'ice modelB the Terrain
(odeling (odule is read) to replicate an) known atmospheric or
topological conditions and their com+ined impact on signal propagation.
Create elevation mapsB line-of-sight profilesB and signal-power
comparisons of mo+ile network models. "nterfaces to read KT$K and
VS2S K$( terrain data are provided. %pen and fle9i+leB the Terrain
(odeling (odule is supported +) the standard 'adio Transceiver
PipelineB which ena+les eas) implementation of custom propagation
models
HIGH LEVEL ARCHITECTURE -HLA.
The Uigh-Wevel Architecture ,UWA- (odule supports +uilding and
running a federation of man) simulatorsB each modeling some aspect of a
composite s)stem. The %P#$T UWA (odule ena+les %P#$T
simulations to model some portion ,or the entiret)- of the
Communications aspects of the UWA federation models. The %P#$T-
UWA interface provides the various simulators ,federates- the necessar)
mechanisms to share a common o+Zect representation ,for persistent
elements-B to e9change messages ,interactions-B and to maintain
appropriate time s)nchroniNation.
The module supports a large su+set of the UWA interfaceB
including:
1. Time management such that an %P#$T simulation remains
s)nchroniNed with overall
UWA time
2. 2eneration and reception of 'T" interactions using %P#$T packet
*. CreationB destructionB or discover) of 'T" o+Zects during the
simulation
.. 2eneration of 'T" o+Zect attri+ute updates +ased on changes to
%P#$T attri+ute values
0. Automatic updates of %P#$T attri+utes upon reception of 'T" o+Zect
attri+ute updates
1. A user-defined mapping specif)ing the relation +etween 'T" and
%P#$T o+Zects
RESULT:
Thus the #etwork Simulator-%P#$T has +een studied.

Das könnte Ihnen auch gefallen