Professional Documents
Culture Documents
TCOA21 Anurag SomaniCNSL Assign 4
TCOA21 Anurag SomaniCNSL Assign 4
TCOA21 Anurag SomaniCNSL Assign 4
ASSigonmen 4
rerequisitei
Dak ink a Ralua, p shels
Java Jraming gn
WRe shaue Tool
Leasning Objechve
Shdents wil e able onduukand Co bacde N glechve
Repeat Modas Sudi windoo Akhcal
Theb
TApoil iplameta ior point-to-
Plos Conhol
Ne a data freme CLayu-2 data) S one oyt
asnethi ove nae Mduum red tthat
U
te Sendt Ond oe Ceive shoold tv_a Same
sgerd Ihak , Sende Senda
the Sgereo wid
receve Can pceAS and accnpt ke data
cIASSMAte
Date
Pags:
Su&ng indou
bot Stnd yreceiver aqnee a the no
dotaTames i He atensledgenaeunt should Ge
Sen ea sp wa Le condol
MehaniSM uwates
pstpeC nes to Malue
undeong rsle
Error onhrol
Whew dala rame ranenittd 1we u probailu y
data rame M bee Los in he ransit s
YeceavedLOYuped n bot Cae, the eives dbe nst
reeive the wrrek dat -fyame and endt does nst ktd
AMy tin oau t4ylees. n suh &caR bett Sendu
nd_ Yeceave Ae
Frome 0
STOP wAIT
ftome 1
AcK1
kcLO
frome STOP-AD-wA IT ARS
Prth
Frome
cIASSMALE
oate
Pago:
St and- uau AR Q
d s in tronsit
tht a rame T
i ac.
Reaven
imerdo O
S timer&r 1 Yome
set timer for 2
Ffome CLO
Fromt
Cloe hmer dor O serd 3 ACL
Cuye hmer for 1 sond ACUL
Selechve-Repeat
F rame 4
ARA
Ti Me-bu for 2
Send yorme 2- Ffame
Frame5
romeG NES
elASSMAte
Dite
Page:
Teahrg
Run Oiresha tel
Run gram
Caphre pach in We a u
Condsina
Hence have shdie&_Gooac NN Selechve keea
odes Sliding Winduo oh o capbrek pach I
Wirechok tool.
Server Side
import java.io.DatalnputStream;
import java.io.DataOutputStream;
import java.io.loException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
public class Server
static ServerSocket Serversocket;
static DatalnputStream dis;
static DataOutputStream dos;
try
int all = { 30, 40, 50, 60, 70, 80, 90, 100, 110
Serversocket = new ServerSocket(8011);
System.out.printin("waiting for connection");
Socket client =Serversocket.accept()i
dis = new DatalnputStream(client.getInputStream()):
dos = new DataOutputStream(client.getOutputStream());
System.out.printin("The number of packets sent is:" + a.length);
int y = a.length;
dos.write(y):
dos.flush():
for (inti = 0; i< a.length; it++) {
dos.write(ali]);
dos.flush(0:
int k = dis.read():
dos.write(a[k]);
dos.flush()
catch (10Exception e)
System.out.printin(e)
finally (
try
dis.close():
dos.close():
catch (1OException e)
e.printStackTrace();
Client Side
import java.lang.System;
import java.net.";
import java.io.";
v[5] = -I;
for (int i =0; i< p; i++)
System.out.println("Received frame is: " + v[i]);
if(v[il -1)f
==
out.write(n);
out.flush():
System.out.println():
v[n] = in.read);
System.out.println("Received frame is: " + v[n]);
System.out.printin("quiting");
catch (Exception e)
System.out.println(e);
File Edit Selection View Go Run Terminal Help Serverjava -Codes-Visual Studio Code X
68
100
116
Received frame is: 30
Received frame is: 48
Received frame is: 5e
Received trame 1s: bo
79
Received frame 1s:
Received frame is: -1
Received frame is: 90
frame is: 10e
Received
Received frame is:
110
Request to retransmit packet no 6 again!!