You are on page 1of 59

Ex.

no:1 Date:

CLIENT-SERVER CHAT PROGRAM 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 so !et for the server using the parameters "#$%&ET as domain and the S'C($ST)E"* as t+pe. Step ,: &ame the so !et using -ind. / s+stem all with the parameters server$so !fd and the server address.sin$addr and sin$sport/. Step 0: Create a onne tion 1ueue and wait for lients using the listen. / s+stem all with the num-er of lients re1uest as parameters. Step 2: " ept the onne tion using a ept. / s+stem all when lient re1uests for onne tion. Step 3: 4et the message whi h has to -e sent to the lient and he ! that it is not e1ual to 56+e7. Step 8: %f the message is not e1ual to 56+e7 then write the message to the lient and 4oto step 3. Step 9: %f the message is 56+e7 then terminate the Pro ess. Step :: Stop the program exe ution.

CLIENT: Step 1: Start the program. Step 2: Create an unnamed so !et for lient using so !et. / s+stem. Step ,: Call with parameters "#$%&ET as domain and S'C($ST)E"* as t+pe. Step 0: &ame the so !et using -ind. / s+stem all. Step 2: &ow onne t the so !et to server using onne t. / s+stem all. Step 3: )ead the message from the server so !et and ompare it with 56+e7. Step 8: %f the message is not e1ual to 56+e7 then print the message to the server output devi e and repeat the steps 3 ; 8. Step 9: 4et the message from the lient side. Step :: <rite the message to server so !fd and goto step 0. Step 1=:%f the message is e1ual to 56+e7then print good -+e message and terminate the pro ess. Step 11:Stop the pro ess.

CLIENT SERVER CHAT USING TCP SERVER: >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ >in lude?string.h@ main./ B int sdCsd2CnsdC lilenCsportClenD har sendmsgE2=FCr vmsgE2=FD stru t so !addr$in servaddrC liaddrD printf.GHn Enter the Server portG/D s anf.GIdGC;sport/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if.sd?=/ printf.GHn CanKt Create G/D else printf.GHn So !et is Created G/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons.sport/D sd2J-ind.sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//D if.sd2?=/ printf.GHn CanKt 6ind G/D else printf.GHn 6inded G/D listen.sdC2/D lilenJsiNeof. liaddr/D nsdJa ept.sdC.stru t so !addrM/; liaddrC; lilen/D if.nsd?=/ printf.GCanKt " eptHnG/D else printf.G" eptedHnG/D printf.GHn)e eived *essagesHnG/D do B re v.nsdCr vmsgC2=C=/D printf.GIsGCr vmsg/D fgets.sendmsgC2=Cstdin/D

lenJstrlen.sendmsg/D sendmsgElen-1FJKH=KD send.nsdCsendmsgC2=C=/D wait.2=/D Owhile.str mp.sendmsgCG-+eG/PJ=/D O CLIENT >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ main./ B int sdC portClenD har sendmsgE2=FCrevmsgE2=FD stru t so !addr$in servaddrD printf.GHn Enter the port G/D s anf.GIdGC; port/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if. sd?=/ printf.GHn CanKt Create G/D else printf.GHn So !et is Created G/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons. port/D if. onne t. sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//?=/ printf.GHn CanKt Conne t G/D else printf.GHn Conne ted G/D do B fgets.sendmsgC2=Cstdin/D lenJstrlen.sendmsg/D sendmsgElen-1FJKH=KD send. sdCsendmsgC2=C=/D wait.2=/D re v. sdCrevmsgC2=C=/D printf.GHn IsGCrevmsg/D Owhile.str mp.revmsgCG-+eG/PJ=/D O

OUTPUT: Client Side E1me13Qlo alhost RFS t p lient. E1me13Qlo alhost RFS. Aa.out Enter the lient port:322, So !et is CreatedT Conne tedTT Uello Server Side E1me13Qlo alhost RFS t pserver. . E1me13Qlo alhost RFS. Aa.out Enter the server port:320, So !et is Created 6inded " epted )e eived *essagesT. Uello

RESULT The C program for hat using TCP is exe uted and the output is verified su essfull+.

Ex.no:2 Date: AIM

CLIENT-SERVER CHAT USING UDP

To write a C program for implementing hat program using VDP. ALGORITHM SERVER: Step 1: Start the program. Step 2: Create an unnamed so !et for the server using the parameters "#$%&ET as domain and the S'C($D4)"* as t+pe. Step ,: &ame the so !et using -ind. / s+stem all with the parameters server$so !fd and the server address.sin$addr and sin$sport/. Step 0: The server gets the message from the lient. Step 2: Prints the message. Step 3: Stop the program exe ution. CLIENT Step 1: Start the program. Step 2: Create an unnamed so !et for lient using so !et Step ,: Call with parameters "#$%&ET as domain an S'C($D4)"* as t+pe. Step 0: &ame the so !et using -ind. / s+stem all. Step 2: The Sendto. / s+stem all is used to deliver the message to the server. Step 3: Stop the program exe ution.

CLIENT SERVER CHAT USING UDP SERVER >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?s+sAso !et.h@ >in lude?netinetAin.h@ main./ B stru t so !addr$in saddC addD int idCaC-ClenCportD har r-uffE1==FD idJso !et.P#$%&ETCS'C($D4)"*C=/D if.id?=/ printf.GHn CanKt CreateG/D else printf.GHn CreatedG/D printf.GHn Enter the port "ddressG/D s anf.GIdGC;port/D sadd.sin$famil+JP#$%&ETD sadd.sin$addr.s$addrJhtonl.%&"DD)$"&L/D sadd.sin$portJhtons.port/D -J-ind.idC.stru t so !addrM/;saddCsiNeof.sadd//D if.-?=/ printf.GHn CanKt 6indG/D else printf.GHn 6indedG/D lenJsiNeof. add/D if.re vfrom.idCr-uffCsiNeof.r-uff/C=C.stru t so !addrM/; addC;len/?=/ printf.GHn )e eived Error G/D else printf.GHn Server re eived JIsGCr-uff/D lose.id/D O

CLIENT >in lude?stdio.h@ >in lude?s+sAso !et.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ main./ B stru t so !addr$in saddC addD int idClenCnC CsC-CportD har strE1==FCserstrE1==FD idJso !et.P#$%&ETCS'C($D4)"*C=/D if.id?=/ printf.GHn CanKt Create G/D else printf.GHn So !et is CreatedHnG/D printf.GHn Enter the %P address:G/D s anf.GIsGCserstr/D printf.GEnter the port "ddressHnG/D s anf.GIdGC;port/D add.sin$famil+JP#$%&ETD add.sin$addr.s$addrJinet$addr.serstr/D add.sin$portJhtons.port/D printf.GEnter the DataHnG/D s anf.GIsGCstr/D -J-ind.idC.stru t so !addrM/; addCsiNeof. add//D if.sendto.idCstrCsiNeof.str/C=C.stru t so !addrM/; addCsiNeof. add//?=/ printf.GTransmit ErrorG/D else printf.GServer TransmittedJIsHnGCstr/D lose.id/D O

OUTPUT: Client Side E1me13Qlo alhost RFS udp lient. E1me13Qlo alhost RFS. Aa.out So !et is CreatedT Enter the %P "ddress:182.12.18=.1=0 Enter the port address:320, Enter the data: Uello Server transmitted J Uello Server Side E1me13Qlo alhost RFS udpserver. E1me13Qlo alhost RFS. Aa.out Created Enter the port address:320, 6inded TTTTT.

RESULT The C program for hat using VDP is exe uted and the output is verified su essfull+.

Ex.no: 1 Date: AIM

DATE-TIME SERVER

To write a C program for implementing the simple TCP lient-server where the server a ts as a Date-Time server. ALGORITHM SERVER Step 1 :Start the program Step 2 :Create an unnamed so !et for the server using parameters "#$%&ET as domain and S'C($ST)E"* as t+pe. Step , : De lare the time varia-les t. Step 0 :4et the server port num-er. Step 2 :)egister the host address to the s+stem -+ using -ind./ s+stem all in server side. Step 3 :Create a onne tion 1ueue and wait for lients using listen./ s+stem all with The num-er of lients re1uests as parameter. Step 8 :" ept the onne tion using a ept. / s+stem all when the lient re1uest for onne tion. Step 9 :Stop the Program exe ution.

CLIENT Step 1 :Start the program. Step 2 :Create an unnamed so !et for the lient using parameters "#$%&ET as domain and S'C($ST)E"* as t+pe. Step , :4et the lient port num-er. Step 0 :&ow onne t the so !et to server using onne t. / s+stem all. Step 2 :The re v./ s+stem all gets the response of Date-Time re1uest from the server. Step 3 :Print the date and time. Step 8 :Stop the program.

DISPLAYING TIME AT THE CLIENT END SERVER >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ >in lude?string.h@ >in lude?time.h@ main./ B int sdCsd2CnsdC lilenCsportClenD har sendmsgE2=FCr vmsgE2=FD time$t tD stru t so !addr$in servaddrC liaddrD printf.GEnter the Port noHnG/D s anf.GIdGC;sport/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D time.;t/D str p+.sendmsgC time.;t//D printf.GIsGCsendmsg/D if.sd?=/ printf.GCanKt Create HnG/D else printf.GSo !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons.sport/D sd2J-ind.sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//D if.sd2?=/ printf.G CanKt 6indHnG/D else printf.GHn 6inded HnG/D listen.sdC2/D lilenJsiNeof. liaddr/D nsdJa ept.sdC.stru t so !addrM/; liaddrC; lilen/D if.nsd?=/ printf.GCanKt " eptHnG/D else printf.G" eptedHnG/D send.nsdCsendmsgC1==C=/D O

CLIENT >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?s+sAso !et.h@ >in lude?netinetAin.h@ >in lude?stdli-.h@ >in lude?time.h@ main./ B int sdC portClenD har revmsgE1==FD stru t so !addr$in servaddrD printf.GEnter the portHnG/D s anf.GIdGC; port/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if. sd?=/ printf.GCanKt CreateHnG/D else printf.GSo !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons. port/D if. onne t. sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//?=/ printf.GConne tion errorHnG/D re v. sdCrevmsgC1==C=/D printf.GIsHnGCrevmsg/D O

OUTPUT: Client Side E1me13Qlo alhost RFS date lient. E1me13Qlo alhost RFS. Aa.out Enter the port: 920, So !et is Created... Conne tedT Server Side E1me13Qlo alhost RFS dateserver. E1me13Qlo alhost RFS. Aa.out Enter the port: 920, #ri Sep 18 =,:=2:28 2=1= So !et is Created...

RESULT The C program for printing Date and time is exe uted and the output is verified su essfull+.

EW.&':0 D"TE: AIM

SIMULATION OF SLIDING WINDOW PROTOCOL

To write a C program for the simulation of Sliding <indow Proto ol. ALGORITHM SENDER Step 1: Start the program. Step 2: Create a So !et for the Sender and -ind it with the re eiver. Step ,: Set the siNe of the window. Step 0: Send the frames upto the siNe of the window to the re eiver Step 2: %f an+ of the frames are lost then retransmit those frames to the re eiver Step 3: Stop the exe ution. RECEIVER Step 1: Start the program. Step 2: Create the So !et for the )e eiverC -ind it and listen for the frames from the sender. Step ,: %f all the frames are su essfull+ re eivedC send the a !nowledgement for the last frame to the sender. Step 0: %f an+ of the frames is lostC then send the a !nowledgement of the last frameC whi h was su essfull+ re eived. Step 2: (eep on re eiving and a !nowledging the frames until the sender sends. Step 3: Stop the program exe ution.

SLIDING WINDOW PROTOCOL SERVER >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ >in lude?string.h@ >in lude?s+sAso !et.h@ main./ B int aC-dCsdCnewsdCportC lilenD har lostE2=FCsendmsgE2=FCre vmsgE2=FD stru t so !addr$in servaddrC liaddrD sdJso !et."#$%&ETCS'C($ST)E"*C=/D if.sd?=/ printf.GCanKt Create HnG/D else printf.GSo !et is CreatedHnG/D printf.GEnter the port noHnG/D s anf.GIdGC;port/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons.port/D aJsiNeof.servaddr/D -dJ-ind.sdC.stru t so !addrM/;servaddrCa/D if.-d?=/ printf.G CanKt 6indHnG/D else printf.GHn 6indedHnG/D listen.sdC2/D lilenJsiNeof. liaddr/D newsdJa ept.sdC.stru t so !addrM/; liaddrC; lilen/D if.newsd?=/ printf.GCanKt " eptHnG/D else printf.G" eptedHnG/D printf.GEnter the lost frameHnG/D s anf.GIsGClost/D send.newsdClostC2=C=/D re v.newsdCre vmsgC2=C=/D

printf.GHn #rame Is is su essfull+ re eivedGCre vmsg/D O CLIENT >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ >in lude?string.h@ main./ B int iCsdCnCportD har sendmsgE1==FCre vmsgE1==FD stru t so !addr$in servaddrD printf.GEnter the portHnG/D s anf.GIdGC;port/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if.sd?=/ printf.GCanKt CreateHnG/D else printf.GSo !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons.port/D if. onne t.sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//?=/ printf.GCanKt Conne tHnG/D else printf.GConne tedHnG/D printf.GEnter the no of framesHnG/D s anf.GIdGC;n/D printf.GHnThe frames allHnG/D for.iJ1Di?JnDiXX/ printf.G#rame IdHnGCi/D re v.sdCre vmsgC2=C=/D printf.GHn Yost frame Is is retransmitted GCre vmsg/D str p+.sendmsgCre vmsg/D send.sdCsendmsgC2=C=/D O

OUTPUT: Server: E1me13alhostRF: Z% swserver. E1me13alhostRF: CC swserver. E1me13alhostRF: Aa.out Enter the port address 920, So !et is reated 6inded " epted Enter the lost frame: , #rame t pserver. is su essfull+ transmitted Client: E1me13alhostRF: Z% sw lient. E1me13alhostRF: CC sw lient. E1me13alhostRF: Aa.out Enter the lient port no 920, So !et is reated Conne tedTTTT.. Enter the no of frames: 0 The frames all #rame 1An #rame 2An #rame ,An #rame 0An

RESULT The C program for the simulation of Sliding <indow Proto ol has -een exe uted and the output is verified su essfull+.

EW.&':2 D"TE: AIM

DOMAIN NAME SYSTEM

To write a C program for the simulation of Domain &ame S+stem ALGORITHM SERVER Step 1: Start the program. Step 2: Create the So !et for the Server. Step ,: 6ind the So !et to the Port. Step 0: Yisten for the in oming lient onne tion. Step 2: )e eive the %P address from the lient to -e resolved. Step 3: 4et the domain name from the lient. Step 8: Che ! the existen e of the domain in the server. Step 9: %f domain mat hes then send the orresponding address to the lient. Step :: Stop the program exe ution. CLIENT Step 1: Start the program. Step 2: Create the So !et for the lient. Step ,: Conne t the So !et to the server. Step 0: Send the hostname to the server to -e resolved. Step 2: %f the server responds the print the address and terminates the pro ess.

DOMAIN NAME SYSTEM SERVER >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ >in lude?string.h@ main./ B int sdCsd2CnsdC lilenCsportClenCiD har sendmsgE2=FCre vmsgE2=FD har ipidE2=FE2=FJBG182.12.30.33GCG182.12.00.22GC G182.12.,,.00GCG182.12.22.,,GOD har hostidE2=FE2=FJBGwww.+ahoo. omGCGwww.google. omGC Gwww.hotmail. omGOD stru t so !addr$in servaddrC liaddrD printf.GD&S Server SideHnG/D printf.GEnter the PortHnG/D s anf.GIdGC;sport/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if.sd?=/ printf.GCanKt Create HnG/D else printf.GSo !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons.sport/D sd2J-ind.sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//D if.sd2?=/ printf.GCanKt 6indHnG/D else printf.GHn 6indedHnG/D listen.sdC2/D lilenJsiNeof. liaddr/D nsdJa ept.sdC.stru t so !addrM/; liaddrC; lilen/D if.nsd?=/ printf.GCanKt " eptHnG/D else printf.G" eptedHnG/D re v.nsdCre vmsgC2=C=/D

for.iJ=Di?0DiXX/ B if.str mp.re vmsgChostidEiF/JJ=/ B send.nsdCipidEiFC2=C2=/D -rea!D O O O CLIENT >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ main./ B int sdC portClenD har sendmsgE2=FCre vmsgE2=FD stru t so !addr$in servaddrD printf.GD&S Client SideHnG/D printf.GEnter the Client portHnG/D s anf.GIdGC; port/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if. sd?=/ printf.GCanKt CreateHnG/D else printf.GSo !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons. port/D if. onne t. sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//?=/ printf.GCanKt Conne tHnG/D else printf.GConne tedHnG/D printf.GEnter the host addressHnG/D s anf.GIsGCsendmsg/D send. sdCsendmsgC2=C=/D re v. sdCre vmsgC2=C2=/D printf.GThe Coresponding %P "ddress isHnG/D printf.GIsGCre vmsg/D O

OUTPUT: Server: E1me13alhostRF: Z% dnsserver. E1me13alhostRF: CC dnsserver. E1me13alhostRF: Aa.out Enter the port no 920, So !et is reated 6inded " epted Client: E1me13alhostRF: Z% dns lient. E1me13alhostRF: CC dns lient. E1me13alhostRF: Aa.out Enter the lient port no 920, So !et is reated Conne tedTTTT.. Enter the host address www.+ahoo. om The orresponding %P "ddress is 182.12.30.33

RESULT The C program for the simulation of Domain &ame S+stem has -een exe uted and the output is verified su essfull+.

Ex &o: Date:

MULTICLIENT-SERVER CHAT

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 so !et for the server using the parameters "#$%&ET as domain and the S'C($ST)E"* as t+pe. Step ,: &ame the so !et using -ind . / s+stem all with the parameters server$so !fd and the server address .sin$addr and sin$sport/. Step 0: Create a onne tion 1ueue and wait for lients using the listen. / s+stem all with the num-er of lients re1uest as parameters. Step 2: 4et the lient[s id as input from the user to ommuni ate. %f the lient[s id is = then go to step 1= otherwise go to step 3. Step 3: " ept the onne tion using a ept . / s+stem all when lient re1uests for onne tion. Step 8: 4et the message whi h has to -e sent to the lient and he ! that it is not e1ual to \6+e]. Step 9: %f the message is not e1ual to \6+e] then write the message to the lient and 4oto step 3. Step :: %f the message is \6+e] then terminates the onne tion with urrent lient and 4o to step 2. Step 1=: Stop the program exe ution.

CLIENT: Step 1: Start the program. Step 2: Create an unnamed so !et for lient using so !et . / s+stem. Step ,: Call with parameters "#$%&ET as domain and S'C($ST)E"* as t+pe. Step 0: &ame the so !et using -ind. / s+stem all. Step 2: &ow onne t the so !et to server using onne t . / s+stem all. Step 3: )ead the message from the server so !et and ompare it with \6+e]. Step 8: %f the message is not e1ual to \6+e] C then print the message to the server output devi e and repeat the steps 3 ; 8. Step 9: 4et the message from the lient side. Step :: <rite the message to server so !fd and goto step 0. Step 1=: %f the message is e1ual to ^6+e[then print good -+e message and terminate the pro ess. Step 11: Stop the pro ess.

MULTI USER CHAT SERVER >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ >in lude?string.h@ main./ B int iCsdCsd2CnsdC lilenCsportClenD har sendmsgE2=FCr vmsgE2=FD stru t so !addr$in servaddrC liaddrD printf.\Enter the port no:Hn]/D s anf.GIdGC;sport/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if.sd?=/ printf.GCanKt Create HnG/D else printf.GSo !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons.sport/D sd2J-ind.sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//D if.sd2?=/ printf.GCanKt 6indHnG/D else printf.GHn 6indedHnG/D listen.sdC2/D do B printf.GEnter the lient no to ommuni ateHnG/D s anf.GIdGC;i/D if.iJJ=/ exit.=/D printf.GClient Id is onne tedHnGCi/D lilenJsiNeof. liaddr/D nsdJa ept.sdC.stru t so !addrM/; liaddrC; lilen/D if.nsd?=/ printf.GCanKt " eptHnG/D

else printf.G" eptedHnG/D do B re v.nsdCr vmsgC2=C=/D printf.GIsGCr vmsg/D fgets.sendmsgC2=Cstdin/D lenJstrlen.sendmsg/D sendmsgElen-1FJKH=KD send.nsdCsendmsgC2=C=/D wait.2=/D Owhile.str mp.sendmsgCG-+eG/PJ=/D Owhile.iPJ=/D O CLIENT >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ main./ B int sdC portClenD har sendmsgE2=FCrevmsgE2=FD stru t so !addr$in servaddrD printf.GEnter the port no:HnG/D s anf.GIdGC; port/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if. sd?=/ printf.GCanKt CreateHnG/D else printf.GSo !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons. port/D if. onne t. sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//?=/ printf.GCanKt Conne tHnG/D else printf.GConne tedHnG/D do B fgets.sendmsgC2=Cstdin/D lenJstrlen.sendmsg/D

sendmsgElen-1FJKH=KD send. sdCsendmsgC2=C=/D wait.2=/D re v. sdCrevmsgC2=C=/D printf.GIsGCrevmsg/D Owhile.str mp.revmsgCG-+eG/PJ=/D O CLIENT - ! >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ main./ B int sdC portClenD har sendmsgE2=FCrevmsgE2=FD stru t so !addr$in servaddrD printf.GEnter the port no:HnG/D s anf.GIdGC; port/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if. sd?=/ printf.GCanKt CreateHnG/D else printf.GSo !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons. port/D if. onne t. sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//?=/ printf.GCanKt Conne tHnG/D else printf.GConne tedHnG/D do B fgets.sendmsgC2=Cstdin/D lenJstrlen.sendmsg/D sendmsgElen-1FJKH=KD send. sdCsendmsgC2=C=/D wait.2=/D re v. sdCrevmsgC2=C=/D printf.GIsGCrevmsg/D Owhile.str mp.revmsgCG-+eG/PJ=/D O

OUTPUT: SERVER SIDE: E1me2Qlo alhost RFS vi *ultiuserserver. E1me2Qlo alhost RFS *ultiuserserver E1me2Qlo alhost RFS .Aa.out Enter the port no 920, so !et is reated 6inded Enter the lient to ommuni ate: 1 Client 1 is onne tedC " epted Uiiiii 6+eeeeee Enter the lient no to ommuni ate: 2 lient 2 is onne tedC " epted Uiiiiiiiiii Uello CLIENT SIDE : E1me2Qlo alhost RFS vi multiuser lient1. E1me2Qlo alhost RFS multiuser lient1. E1me2Qlo alhost RFS .Aa.out Enter the port no 920, So !et is reated Conne ted Uiiiiii 6+eeeee CLIENT SIDE "!: E1me2Qlo alhost RFS vi multiuser lient2. E1me2Qlo alhost RFS multiuser lient2. E1me2Qlo alhost RFS .Aa.out Enter the port no 920, So !et is reated Conne ted Uiiiiiiiii Uello

RESULT The C program for hat multi lient-serve hat program using t p has -een exe uted su essfull+.

Ex. &o: Date: AIM:

SIMULATION OF SIMPLE NETWOR# MANAGEMENT PROTOCOLS

To write a C program for simulation of Simple &etwor! management Proto ols. ALGORITHM: MANAGER: Step 1: Start the program. Step 2: Create an unnamed so !et for lient using so !et . / s+stem. Step ,: Call with parameters "#$%&ET as domain and S'C($ST)E"* as t+pe. Step 0: &ame the so !et using -ind . / s+stem all. Step 2: &ow onne t the so !et to agent using onne t . / s+stem all. Step 3: 4et the input for the t+pe of information needed from the agent. Step 8: %f the input is e1ual to TCP onne tion[ then goto next step else %f it is e1ual to ^s+stem[ 4oto step :. Step 9: )ead the input for the o-_e tC send it and re eive the details of the TCP onne tion of that o-_e t from the agent. 4o to step 1=. Step :: )ead the input for the o-_e tC send it and re eive the details of the s+stem from the agent. 4o to step 1=. Step 1=: )e eive the messageC print and terminate the pro ess. Step 11: Stop the pro ess.

AGENTS Step 1: Start the program. Step 2: Create an unnamed so !et for the server using the parameters "#$%&ET as domain and the S'C($ST)E"* as t+pe. Step ,: &ame the so !et using -ind. / s+stem all with the parameters server$so !fd and the manager address.sin$addr and sin$sport/. Step 0: Create a onne tion 1ueue and wait for manager using the listen./ s+stem all with the num-er of manager re1uest as parameters. Step 2: " ept the onne tion using a ept. / s+stem all when manager re1uests for onne tion. Step 3: )e eive the message from the manager. %f the re1uest is for ^TCP onne tions[ then send the details of the re1uested o-_e tC else if the re1uest is for ^S+stem[ then send the details of the re1uested s+stem. Step 8: Stop the program exe ution.

SIMPLE NETWOR# MANAGEMENT PROTOCOL AGENT >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ >in lude?string.h@ main./ B int iCsdCsd2CnsdC lilenCsportClenD har sendmsgE2=FCre vmsgE1==FD har oidE2FE1=FJBG lient1GCG lient2GCG lient,GCG leint0GCG lient2GOD har wsiNeE2FE2FJBG2GCG1=GCG12GCG,GCG3GOD stru t so !addr$in servaddrC liaddrD printf.G%Km the "gent - TCP Conne tionHnG/D printf.GHnEnter the Server portG/D s anf.GIdGC;sport/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if.sd?=/ printf.GCanKt Create HnG/D else printf.GSo !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons.sport/D sd2J-ind.sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//D if.sd2?=/ printf.G CanKt 6indHnG/D else printf.GHn 6indedHnG/D listen.sdC2/D lilenJsiNeof. liaddr/D nsdJa ept.sdC.stru t so !addrM/; liaddrC; lilen/D if.nsd?=/ printf.GCanKt " eptHnG/D else printf.G" eptedHnG/D re v.nsdCre vmsgC1==C=/D for .iJ=Di?2DiXX/ B

if.str mp.re vmsgCoidEiF/JJ=/ B send.nsdCwsiNeEiFC1==C=/D -rea!D O O O AGENT ! >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ >in lude?string.h@ main./ B int iCsdCsd2CnsdC lilenCsportClenD har sendmsgE2=FCre vmsgE1==FD har oidE2FE1=F JBGS+stem1GCGS+stem2GCGS+stem,GC GS+stem0GCGS+stem2GOD har mdateE2FE12FJBG1-1=-=:2GCG1=-=,-=9GC G10.=,.91GC G11.=8.=8GCG18.12.88GOD har timeE2FE12FJBG:amGCG1=pmGCG11amGCG12.,=pmGCG11.,=amGOD stru t so !addr$in servaddrC liaddrD printf.GEnter the Server port:G/D s anf.GId HnGC;sport/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if.sd?=/ printf.GCanKt Create HnG/D else printf.GSo !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons.sport/D sd2J-ind.sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//D if.sd2?=/ printf.G CanKt 6indHnG/D else printf.GHn 6indedHnG/D listen.sdC2/D lilenJsiNeof. liaddr/D nsdJa ept.sdC.stru t so !addrM/; liaddrC; lilen/D

if.nsd?=/ printf.GCanKt " eptHnG/D else printf.G" eptedHnG/D re v.nsdCre vmsgC1==C=/D for.iJ=Di?2DiXX/ B if.str mp.re vmsgCoidEiF/JJ=/ B send.nsdCmdateEiFC1==C=/D send.nsdCtimeEiFC1==C=/D -rea!D O O O MANAGER >in lude?stdio.h@ >in lude?s+sAt+pes.h@ >in lude?netinetAin.h@ main./ B int sdC portClenCiD har sendmsgE2=FCr vmsgE1==FCrmsgE1==FCoidE1==FD stru t so !addr$in servaddrD printf.GEnter the portHnG/D s anf.GIdGC; port/D sdJso !et."#$%&ETCS'C($ST)E"*C=/D if. sd?=/ printf.GCanKt CreateHnG/D else printf.GS o !et is CreatedHnG/D servaddr.sin$famil+J"#$%&ETD servaddr.sin$addr.s$addrJhtonl.%&"DD)$"&L/D servaddr.sin$portJhtons. port/D if. onne t. sdC.stru t so !addrM/;servaddrCsiNeof.servaddr//?=/ printf.GCanKt Conne tHnG/D else printf.GConne tedHnG/D printf.GHn 1.TCP Conne tionHnG/D printf.GHn 2. S+stem HnG/D printf.GEnter the num-er for the t+pe of informtion needed....HnG/D

s anf.GIdGC;i/D if.iJJ1/ B printf.GEnter the '-_e t %D for ClientHnG/D s anf.GIsGCoid/D send. sdCoidC1==C=/D re v. sdCrmsgC1==C=/D printf.GHn The window siNe of Is is IsGCoidCrmsg/D O else B printf.GHnEnter the '-_e t %D for the S+stemHnG/D s anf.GIsGCoid/D send. sdCoidC1==C=/D re v. sdCrmsgC1==C=/D printf.GHnThe *anufa turing date for Is is IsGCoidCrmsg/D re v. sdCrmsgC1==C=/D printf.GHnThe time of Yast VtiliNation for Is is IsGCoidCrmsg/D O O

OUTPUT: AGENT : E1me10Qlo alhost RFS vi "gent1. E1me10Qlo alhost RFS "gent1. E1me10Qlo alhost RFS .Aa.out %Km the "gent - TCP Conne tion Enter the Server port:920, So !et is reated 6inded " epted MANAGER: E1me10Qlo alhost RFS vi *anager. E1me10Qlo alhost RFS *anger. E1me10Qlo alhost RFS .Aa.out Enter the port 920, So !et is Created Conne ted 1.TCP Conne tion 2. S+stem Enter the num-er for the t+pe of information needed: 1 Enter the '-_e t %D for Client: Client1 The window siNe of lient1 is 2 AGENT!: E1me10Qlo alhost RFS vi "gent2. E1me10Qlo alhost RFS "gent2. E1me10Qlo alhost RFS .Aa.out

Enter the Server port:920, So !et is Created 6inded " epted MANGER: E1me10Qlo alhost RFS vi *anager. E1me10Qlo alhost RFS *anger. E1me10Qlo alhost RFS .Aa.out Enter the port 920, So !et is Created Conne ted 1.TCP Conne tion 2. S+stem Enter the num-er for the t+pe of informtion needed: 2 Enter the '-_e t %D for Client: S+stem, The *anufa turing date for s+stem, is 10.=,.91 The time of last utiliNation for s+stem, is 11am

RESULT: Thus the C program for simple networ! management proto ols has -een exe uted su essfull+.

E*"%Y >in lude ?stdli-.h@ >in lude ?string.h@ >define !null.x/ if..x/JJ&VYY/ Bperror.GG/D exit.EW%T$#"%YV)E/DO >define !nltN.x/ if..x/?=/ Bperror.GG/D exit.EW%T$#"%YV)E/DO >define Y%ST$YE& 0 AA har MfJGsam.txtGD void email$it. har Mfilename/D main./ B har fnameE12FD printf.Genter the filenameHnG/D s anf.GIsGCfname/D email$it.fname/D O void email$it. har Mfilename/ B har tmpE223FJB=x=OD har fp6ufferE0==FJB=x=OD har email$listEY%ST$YE&FE223FJBBGme se,Qlo alhost.lo aldomainGOC B=x=OOD int iJ=D for.iJ=DMemail$listEiF@=x=DiXX/ B !null.str p+.tmpC email$listEiF//D !nltN.sprintf .fp6ufferCGmail -s KIs IsK Is ? IsGC GPlease )eview:GC filenameC tmpCfilename//D if.s+stem .fp6uffer/JJ.-1// B

perror.Gemail failureG/D exit.EW%T$#"%YV)E/D O O O 'VTPVT: E1me2Qlo alhost RFS vi E1me2Qlo alhost RFS .Aa.out Enter the file name: sample. E1me2Qlo alhost RFSAhomeA1me1Adead.letterT.saved AhomeA1me1Adead.letterT.. )ESVYT Thus the program for developing E-mail appli ation is exe uted and the output is verified su essfull+. STVDL '# &ET<')( S%*VY"T') P"C("4ES Ex. &o: STVDL '# &S2 Date: message in email. E1me2Qlo alhost RFS email.

"%*: To stud+ a-out &S2 - &etwor! Simulator %&T)'DVCT%'&:

&S is a dis rete event simulator targeted at networ!ing resear h. &S provides su-stantial support for simulation of TCPC routingC and multi ast proto ols over wired and wireless .lo al and satellite/ networ!s. &S -egan as a variant of the )E"Y networ! simulator in 1:9: and has evolved su-stantiall+ over the past few +ears. %n 1::2 ns development was supported -+ D")P" through the Z%&T pro_e t at Y6YC Werox P")CC VC6C and VSCA%S%. Currentl+ ns development is support through D")P" with S"*"& and through &S# with C'&SE)C -oth in olla-oration with other resear hers in luding "C%)%. &S has alwa+s in luded su-stantial ontri-utions from other resear hersC in luding wireless ode from the VC6 Daedelus and C*V *onar h pro_e ts and Sun *i ros+stems. The networ! simulator ns-2 is a widel+ a epted dis rete event networ! simulatorC a tivel+ used for wired and wireless networ! simulations. %t has a highl+ detailed model of the lower la+ers .Ph+si al and *"C/ of wireless %EEE 9=2.11 networ!s. &s-2 has also an emulation featureC i.e. the a-ilit+ to introdu e the simulator into a live networ! and to simulate a desired networ! -etween real appli ations in real-time. <ithin the s ope of this pro_e t we developed some methods and extensions to the ns-2 to om-ine wireless networ! simulation and networ! emulation. 'ZE)Z%E<: &S is an event driven networ! simulator developed at VC 6er!ele+ that simulates variet+ of %P networ!s. %t implements networ! proto ols su h as TCP and VDPC traffi sour e -ehavior su h as #TPC TelnetC <e-C C6) and Z6)C router 1ueue management me hanism su h as Drop TailC )ED and C6`C routing algorithms su h as Di_!straC and more. &S also implements multi asting and some of the *"C la+er proto ols for Y"& simulations. The &S pro_e t is now a part of the Z%&T pro_e t that develops tools for simulation results displa+C anal+sis and onverters that onvert networ! topologies generated -+ well-!nown generators to &S formats. Currentl+C &S .version 2/ written in CXX and 'T l .T l s ript language with '-_e t-oriented extensions developed at *%T/ is availa-le. This do ument tal!s -riefl+ a-out the -asi stru ture of &SC and explains in detail how to use &S mostl+ -+ giving examples. *ost of the figures that are used in des ri-ing the &S -asi stru ture and networ! omponents are from the 2th Z%&TA&S Simulator TutorialA<or!shop slides and the &S *anual .formerl+ alled G&S &otes and Do umentationG/C modified little -it as needed.

#igure 1. Simplified VserKs Ziew of &S "s shown in #igure 1C in a simplified userKs viewC &S is '-_e t-oriented T l .'T l/ s ript interpreter that has a simulation event s heduler and networ! omponent o-_e t li-rariesC and networ! setup .plum-ing/ module li-raries .a tuall+C plum-ing modules are implemented as mem-er fun tions of the -ase simulator o-_e t/. %n other wordsC to use &SC +ou program in 'T l s ript language. To setup and run a simulation networ!C a user should write an 'T l s ript that initiates an event s hedulerC sets up the networ! topolog+ using the networ! o-_e ts and the plum-ing fun tions in the li-rar+C and tells traffi sour es when to start and stop transmitting pa !ets through the event s heduler. The term Gplum-ingG is used for a networ! setupC -e ause setting up a networ! is plum-ing possi-le data paths among networ! o-_e ts -+ setting the Gneigh-orG pointer of an o-_e t to the address of an appropriate o-_e t. <hen a user wants to ma!e a new networ! o-_e tC he or she an easil+ ma!e an o-_e t either -+ writing a new o-_e t or -+ ma!ing a ompound o-_e t from the o-_e t li-rar+C and plum- the data path through the o-_e t. This ma+ sound li!e ompli ated _o-C -ut the plum-ing 'T l modules a tuall+ ma!e the _o- ver+ eas+. The power of &S omes from this plum-ing. "nother ma_or omponent of &S -eside networ! o-_e ts is the event s heduler. "n event in &S is a pa !et %D that is uni1ue for a pa !et with s heduled time and the pointer to an o-_e t that handles the event. %n &SC an event s heduler !eeps tra ! of simulation time and fires all the events in the event 1ueue s heduled for the urrent time -+ invo!ing appropriate networ! omponentsC whi h usuall+ are the ones who issued the eventsC and let them do the appropriate a tion asso iated with pa !et pointed -+ the event. &etwor! omponents ommuni ate with one another passing pa !etsC however this does not onsume a tual simulation time. "ll the networ! omponents that need to spend some simulation time handling a pa !et .i.e. need a dela+/ use the event s heduler -+ issuing an event for the pa !et and waiting for the event to -e fired to itself -efore doing further a tion handling the pa !et. #or exampleC a networ! swit h omponent that simulates a swit h with 2= mi rose onds of swit hing dela+ issues an event for a pa !et to -e swit hed to the s heduler as an event 2= mi rose ond later. The s heduler after 2= mi rose onds de1ueues the event and fires it to the swit h omponentC whi h then passes the pa !et to an appropriate output lin! omponent. "nother use of an event s heduler is timer. &S is written not onl+ in 'T l -ut in CXX also. #or effi ien + reasonC &S separates the data path implementation from ontrol path implementations. %n order to

redu e pa !et and event pro essing time .not simulation time/C the event s heduler and the -asi networ! omponent o-_e ts in the data path are written and ompiled using CXX. These ompiled o-_e ts are made availa-le to the 'T l interpreter through an 'T l lin!age that reates a mat hing 'T l o-_e t for ea h of the CXX o-_e ts and ma!es the ontrol fun tions and the onfigura-le varia-les spe ified -+ the CXX o-_e t a t as mem-er fun tions and mem-er varia-les of the orresponding 'T l o-_e t. %n this wa+C the ontrols of the CXX o-_e ts are given to 'T l. %t is also possi-le to add mem-er fun tions and varia-les to a CXX lin!ed 'T l o-_e t. The o-_e ts in CXX that do not need to -e ontrolled in a simulation or internall+ used -+ another o-_e t do not need to -e lin!ed to 'T l. Yi!ewiseC an o-_e t .not in the data path/ an -e entirel+ implemented in 'T l. #igure 2 shows an o-_e t hierar h+ example in CXX and 'T l. 'ne thing to note in the figure is that for CXX o-_e ts that have an 'T l lin!age forming a hierar h+C there is a mat hing 'T l o-_e t hierar h+ ver+ similar to that of CXX. #igure 2. CXX and 'T l: The Dualit+ #igure ,. "r hite tural Ziew of &S #igure , shows the general ar hite ture of &S. %n this figure a general user .not an &S developer/ an -e thought of standing at the left -ottom ornerC designing and running simulations in T l using the simulator o-_e ts in the 'T l li-rar+. The event s hedulers and most of the networ! omponents are implemented in CXX and availa-le to 'T l through an 'T l lin!age that is implemented using t l l. The whole thing together ma!es &SC whi h is a '' extended T l interpreter with networ! simulator li-raries. This se tion -riefl+ examined the general stru ture and ar hite ture of &S. "t this pointC one might -e wondering a-out how to o-tain &S simulation results. "s shown in #igure 1C when a simulation is finishedC &S produ es one or more text--ased output files that ontain detailed simulation dataC if spe ified to do so in the input T l .or more spe ifi all+C 'T l/ s ript. The data an -e used for simulation anal+sis .two simulation result anal+sis examples are presented in later se tions/ or as an input to a graphi al simulation displa+ tool alled &etwor! "nimator .&"*/ that is developed as a part of Z%&T pro_e t. &"* has a ni e graphi al user interfa e similar to that of a CD pla+er .pla+C fast forwardC rewindC pause and so on/C and also has a displa+ speed ontroller. #urthermoreC it an graphi all+ present information su h as throughput and num-er of pa !et drops at ea h lin!C although the graphi al information annot -e used for a urate simulation anal+sis.

This se tion shows a simple &S simulation s ript and explains what ea h line does. Example , is an 'T l s ript that reates the simple networ! onfiguration and runs the simulation s enario in #igure 0. #igure 0. " Simple &etwor! Topolog+ and Simulation S enario This networ! onsists of 0 nodes .n=C n1C n2C n,/ as shown in a-ove figure. The duplex lin!s -etween n= and n2C and n1 and n2 have 2 *-ps of -andwidth and 1= ms of dela+. The duplex lin! -etween n2 and n, has 1.8 *-ps of -andwidth and 2= ms of dela+. Ea h node uses a DropTail 1ueueC of whi h the maximum siNe is 1=. " Gt pG agent is atta hed to n=C and a onne tion is esta-lished to a t p Gsin!G agent atta hed to n,. "s defaultC the maximum siNe of a pa !et that a Gt pG agent an generate is 1(6+te. " t p Gsin!G agent generates and sends "C( pa !ets to the sender .t p agent/ and frees the re eived pa !ets. " GudpG agent that is atta hed to n1 is onne ted to a GnullG agent atta hed to n,. " GnullG agent _ust frees the pa !ets re eived. Example ,. " Simple &S Simulation S ript The following is the explanation of the s ript a-ove. %n generalC an &S s ript starts with ma!ing a Simulator o-_e t instan e. set ns Enew SimulatorF: generates an &S simulator o-_e t instan eC and assigns it to varia-le ns .itali s is used for varia-les and values in this se tion/. o %nitialiNe the pa !et format .ignore this for now/ o Create a s heduler .default is alendar s heduler/ o Sele t the default address format .ignore this for now/ The GSimulatorG o-_e t has mem-er fun tions that do the following: aCreate ompound o-_e ts su h as nodes and lin!s .des ri-ed later/ aConne t networ! omponent o-_e ts reated .ex. atta h-agent/ aSet networ! omponent parameters .mostl+ for ompound o-_e ts/ aCreate onne tions -etween agents .ex. ma!e onne tion -etween a Gt pG and Gsin!G/ aSpe if+ &"* displa+ options

*ost of mem-er fun tions are for simulation setup and s hedulingC however some of them are for the &"* displa+. The GSimulatorG o-_e t mem-er fun tion implementations are lo ated in the Gns-2At lAli-Ans-li-.t lG file. Sns olor fid olor: is to set olor of the pa !ets for a flow spe ified -+ the flow id .fid/. This mem-er fun tion of GSimulatorG o-_e t is for the &"* displa+C and has no effe t on the a tual simulation. Sns namtra e-all file-des riptor: This mem-er fun tion tells the simulator to re ord simulation tra es in &"* input format. %t also gives the file name that the tra e will -e written to later -+ the ommand Sns flush-tra e. Similarl+C the mem-er fun tion tra e-all is for re ording the simulation tra e in a general format. pro finish BO: is alled after this simulation is over -+ the ommand Sns at 2.= GfinishG. %n this fun tionC post-simulation pro esses are spe ified. set n= ESns nodeF: The mem-er fun tion node reates a node. " node in &S is ompound o-_e t made of address and port lassifiers .des ri-ed in a later se tion/. Vsers an reate a node -+ separatel+ reating an address and a port lassifier o-_e ts and onne ting them together. UoweverC this mem-er fun tion of Simulator o-_e t ma!es the _o- easier. To see how a node is reatedC loo! at the files: Gns-2At lAli-sAns-li-.t lG and Gns-2At lAli-sAns-node.t lG. Sns duplex-lin! node1 node2 -andwidth dela+ 1ueue-t+pe: reates two simplex lin!s of spe ified -andwidth and dela+C and onne ts the two spe ified nodes. %n &SC the output 1ueue of a node is implemented as a part of a lin!C therefore users should spe if+ the 1ueue-t+pe when reating lin!s. %n the a-ove simulation s riptC DropTail 1ueue is used. %f the reader wants to use a )ED 1ueueC simpl+ repla e the word DropTail with )ED. The &S implementation of a lin! is shown in a later se tion. Yi!e a nodeC a lin! is a ompound o-_e tC and users an reate its su-- o-_e ts and onne t them and the nodes. Yin! sour e odes an -e found in Gns2At lAli-sAns-li-.t lG and Gns-2At lAli-sAns-lin!.t lG files. 'ne thing to note is that +ou an insert error modules in a lin! omponent to simulate a loss+ lin! .a tuall+ users an ma!e and insert an+ networ! o-_e ts/. )efer to the &S do umentation to find out how to do this. Sns 1ueue-limit node1 node2 num-er: This line sets the 1ueue limit of the two simplex lin!s that onne t node1 and node2 to the num-er spe ified. "t this pointC the authors do not !now how man+ of these !inds of mem-er fun tions of Simulator o-_e ts are availa-le and what the+ are. Please ta!e a loo! at Gns-

2At lAli-sAns-li-.t lG and Gns-2At lAli-sAns-lin!.t lGC or &S do umentation for more information. Sns duplex-lin!-op node1 node2 ...: The next ouple of lines are used for the &"* displa+. To see the effe ts of these linesC users an omment these lines out and tr+ the simulation. &ow that the -asi networ! setup is doneC the next thing to do is to setup traffi agents su h as TCP and VDPC traffi sour es su h as #TP and C6)C and atta h them to nodes and agents respe tivel+. set t p Enew "gentATCPF: This line shows how to reate a TCP agent. 6ut in generalC users an reate an+ agent or traffi sour es in this wa+. "gents and traffi sour es are in fa t -asi o-_e ts .not ompound o-_e ts/C mostl+ implemented in CXX and lin!ed to 'T l. ThereforeC there are no spe ifi Simulator o-_e t mem-er fun tions that reate these o-_e t instan es. To reate agents or traffi sour esC a user should !now the lass names these o-_e ts ."gentATCPC "gnetATCPSin!C "ppli ationA#TP and so on/. This information an -e found in the &S do umentation or partl+ in this do umentation. 6ut one short ut is to loo! at the Gns-2At lAli-sAns-default.t lG file. This file ontains the default onfigura-le parameter value settings for availa-le networ! o-_e ts. ThereforeC it wor!s as a good indi ator of what !ind of networ! o-_e ts are availa-le in &S and what are the onfigura-le parameters. Sns atta h-agent node agent: The atta h-agent mem-er fun tion atta hes an agent o-_e t reated to a node o-_e t. " tuall+C what this fun tion does is all the atta h mem-er fun tion of spe ified nodeC whi h atta hes the given agent to itself. ThereforeC a user an do the same thing -+C for exampleC Sn= atta h St p. Sns onne t agent1 agent2: "fter two agents that will ommuni ate with ea h other are reatedC the next thing is to esta-lish a logi al networ! onne tion -etween them. This line esta-lishes a networ! onne tion -+ setting the destination address to ea h othersK networ! and port address pair. "ssuming that all the networ! onfiguration is doneC the next thing to do is write a simulation s enario .i.e. simulation s heduling/. The Simulator o-_e t has man+ s heduling mem-er fun tions. UoweverC the one that is mostl+ used is the following: Sns at time GstringG: This mem-er fun tion of a Simulator o-_e t ma!es the s heduler .s heduler$ is the varia-le that points the s heduler o-_e t reated -+

Enew S hedulerF ommand at the -eginning of the s ript/ to s hedule the exe ution of the spe ified string at given simulation time. #or exampleC Sns at =.1 GS -r startG will ma!e the s heduler all a start mem-er fun tion of the C6) traffi sour e o-_e tC whi h starts the C6) to transmit data. %n &SC usuall+ a traffi sour e does not transmit a tual dataC -ut it notifies the underl+ing agent that it has some amount of data to transmitC and the agentC _ust !nowing how mu h of the data to transferC reates pa !ets and sends them. "fter all networ! onfigurationC s heduling and post-simulation pro edure spe ifi ations are doneC the onl+ thing left is to run the simulation. This is done -+ Sns run. &ET<')( C'*P'&E&TS: #igure 3. Class Uierar h+ .Partial/ The root of the hierar h+ is the T l'-_e t lass that is the super lass of all 'T l li-rar+ o-_e ts .s hedulerC networ! omponentsC timers and the other o-_e ts in luding &"* related ones/. "s an an estor lass of T l'-_e tC &s'-_e t lass is the super lass of all -asi networ! omponent o-_e ts that handle pa !etsC whi h ma+ ompose ompound networ! o-_e ts su h as nodes and lin!s. The -asi networ! omponents are further divided into two su- lassesC Conne tor and ClassifierC -ased on the num-er of the possi-le output data paths. The -asi networ! o-_e ts that have onl+ one output data path are under the Conne tor lassC and swit hing o-_e ts that have possi-le multiple output data paths are under the Classifier lass. &'DE "&D )'VT%&4: " node is a ompound o-_e t omposed of a node entr+ o-_e t and lassifiers as shown in #igure 8. There are two t+pes of nodes in &S. " uni ast node has an address lassifier that does uni ast routing and a port lassifier. " multi ast nodeC in additionC has a lassifier that lassif+ multi ast pa !ets from uni ast pa !ets and a multi ast lassifier that performs multi ast routing. #igure 8. &ode .Vni ast and *ulti ast/ %n &SC Vni ast nodes are the default nodes. To reate *ulti ast nodes the user must expli itl+ notif+ in the input 'T l s riptC right after reating a s heduler o-_e tC that all the nodes that will -e reated are multi ast nodes. "fter

spe if+ing the node t+peC the user an also sele t a spe ifi routing proto ol other than using a default one. Vni ast -Sns rtproto t+pe -t+pe: Stati C SessionC DZC ostC multi-path *ulti ast -Sns multi ast .right after set Sns Enew S hedulerF/ -Sns mrtproto t+pe -t+pe: Ctr* astC D*C STC 6ST Y%&(: " lin! is another ma_or ompound o-_e t in &S. <hen a user reates a lin! using a duplex-lin! mem-er fun tion of a Simulator o-_e tC two simplex lin!s in -oth dire tions are reated as shown in #igure 9. #igure 9. Yin! 'ne thing to note is that an output 1ueue of a node is a tuall+ implemented as a part of simplex lin! o-_e t. Pa !ets de1ueued from a 1ueue are passed to the Dela+ o-_e t that simulates the lin! dela+C and pa !ets dropped at a 1ueue are sent to a &ull "gent and are freed there. #inall+C the TTY o-_e t al ulates Time To Yive parameters for ea h pa !et re eived and updates the TTY field of the pa !et. Tra ing %n &SC networ! a tivities are tra ed around simplex lin!s. %f the simulator is dire ted to tra e networ! a tivities .spe ified using Sns tra e-all file or Sns namtra e-all file/C the lin!s reated after the ommand will have the following tra e o-_e ts inserted as shown in #igure :. Vsers an also spe ifi all+ reate a tra e o-_e t of t+pe t+pe -etween the given sr and dst nodes using the reatetra e Bt+pe file sr dstO ommand. #igure :. %nserting Tra e '-_e ts

<hen ea h inserted tra e o-_e t .i.e. En1TC De1TC DrpT and )e vT/ re eives a pa !etC it writes to the spe ified tra e file without onsuming an+ simulation timeC and passes the pa !et to the next networ! o-_e t. The tra e format will -e examined in the 4eneral "nal+sis Example se tion. `ueue *onitor 6asi all+C tra ing o-_e ts are designed to re ord pa !et arrival time at whi h the+ are lo ated. "lthough a user gets enough information from the tra eC he or she might -e interested in what is going on inside a spe ifi output 1ueue. #or exampleC a user interested in )ED 1ueue -ehavior ma+ want to measure the d+nami s of average 1ueue siNe and urrent 1ueue siNe of a spe ifi )ED 1ueue .i.e. need for 1ueue monitoring/. `ueue monitoring an -e a hieved using 1ueue monitor o-_e ts and snoop 1ueue o-_e ts as shown in #igure 1=. #igure 1=. *onitoring `ueue <hen a pa !et arrivesC a snoop 1ueue o-_e t notifies the 1ueue monitor o-_e t of this event. The 1ueue monitor using this information monitors the 1ueue. " )ED 1ueue monitoring example is shown in the )ED `ueue *onitor Example se tion. &ote that snoop 1ueue o-_e ts an -e used in parallel with tra ing o-_e ts even though it is not shown in the a-ove figure. P"C(ET #Y'< EW"*PYE: Vntil nowC the two most important networ! omponents .node and lin!/ were examined. #igure 11 shows internals of an example simulation networ! setup and pa !et flow. The networ! onsist of two nodes .n= and n1/ of whi h the networ! addresses are = and 1 respe tivel+. " TCP agent atta hed to n= using port = ommuni ates with a TCP sin! o-_e t atta hed to n1 port =. #inall+C an #TP appli ation .or traffi sour e/ is atta hed to the TCP agentC as!ing to send some amount of data. #igure 11. Pa !et #low Example &ote that the a-ove figure does not show the exa t -ehavior of a #TP over TCP. %t onl+ shows the detailed internals of simulation networ! setup and a pa !et flow. P"C(ET:

" &S pa !et is omposed of a sta ! of headersC and an optional data spa e .see #igure 12/. "s -riefl+ mentioned in the GSimple Simulation ExampleG se tionC a pa !et header format is initialiNed when a Simulator o-_e t is reatedC where a sta ! of all registered .or possi-l+ usea-le/ headersC su h as the ommon header that is ommonl+ used -+ an+ o-_e ts as neededC %P headerC TCP headerC )TP header .VDP uses )TP header/ and tra e headerC is definedC and the offset of ea h header in the sta ! is re orded. <hat this means is that whether or not a spe ifi header is usedC a sta ! omposed of all registered headers is reated when a pa !et is allo ated -+ an agentC and a networ! o-_e t an a ess an+ header in the sta ! of a pa !et it pro esses using the orresponding offset value. #igure 12. &S Pa !et #ormat Vsuall+C a pa !et onl+ has the header sta ! .and a data spa e pointer that is null/. "lthough a pa !et an arr+ a tual data .from an appli ation/ -+ allo ating a data spa eC ver+ few appli ation and agent implementations support this. This is -e ause it is meaningless to arr+ data around in a non-real-time simulation. UoweverC if +ou want to implement an appli ation that tal!s to another appli ation ross the networ!C +ou might want to use this feature with a little modifi ation in the underl+ing agent implementation. "nother possi-le approa h would -e reating a new header for the appli ation and modif+ing the underl+ing agent to write data re eived from the appli ation to the new header. The se ond approa h is shown as an example in a later se tion alled G"dd &ew "ppli ation and "gentG. )ESVYT: Thus the details a-out &S2.&etwor! Simulator 2/ has -een studied. Ex. &o. STVDL '# 'P&ET Date:

"%*:

To stud+ a-out 'P&ET - &etwor! Simulator %&T)'DVCT%'&: 'P&ET .'ptimiNed &etwor! Engineering Tools/ is a ommer ial tool from *%Y, %n . %t is -eing developed for almost 12 +ears. "s ever+one should guessC no mu h te hni al detail are availa-le a-out the internals. VSE: &etwor! with several hundreds of nodes an -e simulatedC -ut it would ta!e time for the omputation. 'P&ET is used -+ ompanies li!e Thomson-CS# or C&ET whi h use it to model "T* networ!s and validate various la+ers proto olsC pa !et swit hed radio networ!s. "n example of use of 'P&ET is 4eorge *ason Vniversit+ .`ualit+ of Servi e %P &etwor! Simulation/. TUE P"C("4E The software omprises several tools and is divided in several partsC 'P&ET *odeler and 'P&ET PlannerC the *odel Yi-rar+C and the "nal+sis tool. #eatures in luded in this generi simulator are an event-driven s heduled simulation !ernelC integrated anal+sis tools for interpreting and s+nthesiNing output dataC graphi al spe ifi ation of models and a hierar hi al o-_e t--ased modeling. 'P&ET *odeler is intended for modelingC simulating and anal+Ning the performan e of large ommuni ations networ!sC omputer s+stems and appli ations. Common uses are assessing and feasi-ilit+ of new designsC optimiNing alread+ developed ommuni ation s+stems and predi ting performan e. The modeling methodolog+ of 'P&ET is organiNed in a hierar hi al stru ture. "t the lowest levelC Pro ess models are stru tured as a finite state ma hine. State and transitions are spe ified graphi all+ using state-transition diagrams whereas onditions that spe if+ what happen within ea h state are programmed with a C-li!e language alled Proto-C. Those pro esses and -uilt-in modules in 'P&ET .sour e and destination modulesC traffi generatorsC 1ueuesC .../ are then onfigured with menus and organiNed into data flow diagrams that represent nodes using the graphi al &ode Editor. Vsing a graphi al &etwor! EditorC nodes and lin!s are sele ted to -uild up the topolog+ of a ommuni ation networ!.

The "nal+sis Tool provides a graphi al environment to view and manipulate data olle ted during simulation runs. )esults an -e anal+Ned for an+ networ! element. 'P&ET Planner is an appli ation that allows administrators to evaluate the performan e of ommuni ations networ!s and distri-uted s+stemsC without programming or ompiling. Planner anal+ses -ehavior and performan e -+ dis rete-event simulations. *odels are -uilt using a graphi al interfa e. The user onl+ hooses pre-defined models .from the ph+si al la+er to the appli ation/ from the li-rar+ and sets attri-utes. The user annot define new modelsC he should onta t *%Y,Ks modeling servi e. The modeling li-raries are in luded with 'P&ET *odeler and 'P&ET Planner and ontains proto ols and anal+sis environmentsC among them "T*C TCPC %PC #rame )ela+C #DD%C EthernetC lin! models su h as point-to-point or -usC 1ueueing servi e dis iplines su h as #irst-in-#irst-'ut .#%#'/C Yast-%n-#irst-'ut .Y%#'/C priorit+ non- preemptive 1ueueingC shortest first _o-C round-ro-in or preempt and resume. 'P&ET *odeler is the industr+Ks leading environment for networ! modeling and simulationC allowing +ou to design and stud+ ommuni ation networ!sC devi esC proto olsC and appli ations with unmat hed flexi-ilit+ and s ala-ilit+. *odeler is used -+ the worldKs largest networ! e1uipment manufa turers to a elerate the );D of networ! devi es and te hnologies su h as Zo%PC TCPC 'SP#v,C *PYSC %Pv3C and more. &etwor!ing te hnolog+ has -e ome too omplex for traditional anal+ti al methods or Grules of thum-G to +ield an a urate understanding of s+stem -ehavior. Sin e 1:93C 'P&ET Te hnologies %n .C has -een the leader in developing predi tive software solutions for networ!ing professionals. 'P&ET software ena-les its users to optimiNe the performan e and maximiNe the availa-ilit+ of ommuni ations networ!s and appli ations. 'P&ET is the state-of-art networ! simulation tool for modelingC simulating and anal+sing the performan e of i.Communi ation &etwor!sC Distri-uted S+stems ii.Computer s+stems and "ppli ations.

Produ t modules provide value-added apa-ilities to 'P&ETKs intelligent networ! management software. *odules span a wide range of appli ations and re eive regular updates under 'P&ETKs maintenan e program. 'P&ET *'DVYES: v*odeler vTerrain *odeling *odule .T**/ vUigh Yevel "r hite ture .UY"/ *'DEYE): 'P&ET *odeler is intended for modelingC simulating and anal+sing the performan e of large ommuni ations networ!sC omputer s+stems and appli ations. Common uses are assessing and feasi-ilit+ of new designsC optimiNing alread+ developed ommuni ation s+stems and predi ting performan e. The modeling methodolog+ of 'P&ET is organiNed in a hierar hi al stru ture. "t the lowest levelC Pro ess models are stru tured as a finite state ma hine. State and transitions are spe ified graphi all+ using state-transition diagrams whereas onditions that spe if+ what happen within ea h state are programmed with a C-li!e language alled Proto-C. Those pro essesC and -uilt-in modules in 'P&ET .sour e and destination modulesC traffi generatorsC 1ueuesC .../ are then onfigured with menus and organiNed into data flow diagrams that represent nodes using the graphi al &ode Editor. Vsing a graphi al &etwor! EditorC nodes and lin!s are sele ted to -uild up the topolog+ of a ommuni ation networ!. TE))"%& *'DEY%&4 *'DVYE .T**/ 6uilding on the apa-ilities of 'P&ETKs <ireless *oduleC the Terrain *odeling *odule provides the next level of a ura + and ontrol for wireless networ! design and planning. This module allows +ou to model environmental effe ts on wireless networ! ommuni ations an+where. #eaturing an open-sour e Yongle+-)i e modelC the Terrain *odeling *odule is read+ to repli ate an+ !nown atmospheri or topologi al onditions and their om-ined impa t on signal propagation. Create elevation mapsC line-of-sight profilesC and signal- power omparisons of mo-ile networ! models. %nterfa es to read DTED and VS4S DE* terrain data are provided. 'pen and flexi-leC the

Terrain *odeling *odule is supported -+ the standard )adio Trans eiver PipelineC whi h ena-les eas+ implementation of ustom propagation models U%4U YEZEY ")CU%TECTV)E .UY"/ The Uigh-Yevel "r hite ture .UY"/ *odule supports -uilding and running a federation of man+ simulatorsC ea h modeling some aspe t of a omposite s+stem. The 'P&ET UY" *odule ena-les 'P&ET simulations to model some portion .or the entiret+/ of the ommuni ations aspe ts of the UY" federation models. The 'P&ET- UY" interfa e provides the various simulators .federates/ the ne essar+ me hanisms to share a ommon o-_e t representation .for persistent elements/C to ex hange messages .intera tions/C and to maintain appropriate time s+n hroniNation. The module supports a large su-set of the UY" interfa eC in luding: vTime management su h that an 'P&ET simulation remains s+n hroniNed with overall UY" time v4eneration and re eption of )T% intera tions using 'P&ET pa !et vCreationC destru tionC or dis over+ of )T% o-_e ts during the simulation v4eneration of )T% o-_e t attri-ute updates -ased on hanges to 'P&ET attri-ute values v"utomati updates of 'P&ET attri-utes upon re eption of )T% o-_e t attri-ute updates v" user-defined mapping spe if+ing the relation -etween )T% and 'P&ET o-_e ts )ESVYT: Thus the &etwor! Simulator-'P&ET has -een studied.

You might also like