TCOA21 Anurag SomaniCNSL Assign 4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

clASSMAte

ASSigonmen 4

Pablen Dekini hiom:


Wsue_0 para to sinmuuloe GO bak N
Selechve Repea- Modes Sung Windeus Pttco&
pee pee Mode and dermbnshrok &e packe aptvred
bace Using Wiresauk Padek hnalu Tosl p
Re Dele

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:

O ha e geel haudwnre lsttuare) te


SEnder Te ceiveL btndt
as te
stndina
cveloadec, (suoamed)
data lest

lo typea Mecanisus Co be deplyd tcahl


ae

Strp andd Wodt


This Cenuhel MecuausMS frces he sendle a
trauns ith claka ame shap and waut vwh
the Acunosladgemeu t e doda fronme sen M
9e Ceived

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

wlps em drke ct bransil eLSSvd as Loss


Cnde KeceiveA

Frome 0
STOP wAIT

ftome 1
AcK1

Sendt Rece ive

kcLO
frome STOP-AD-wA IT ARS
Prth

Frome
cIASSMALE
oate
Pago:

data- rame. Hene, eithe sendes re-ransn its he dak-


ronme yece ive Ievest o Tesend he previas
data-rame
NeqeAe errar- conho Me dhanisi
Excox detchm sender Yeceve bQta cu an
ten

MUst aceukaun tha hue soMe Crray in hansat


oah ve Ace- Whe receive ecesvoo a coe rame ishDld
adunculedge it
Negohv Ad- W receiue yecei ves a damaed Yame

O dupliol ane o NtcL bade o


Senda
the sendeN _snd retransimnit Cae rae
Rehransnmí-si The sendu nany a doc s e h
bmeou peaiod a ach
&doa -fraMe previou ly
tranS mitkd does ngt air IVe tue boneout he
seneler rehransmib the
frome hinkingth Hue fromme
is lost in transSnait

hese avoailable wid Det -Gik


Mgdep loy Loynhrel he crroYS Aut mahe
KepeatRezpes (ARG)*

St and- uau AR Q

he lptung ran sib m Ma 0CeON in Stop-ad-wast ARQ


The send Mainauns a me out countta
wh YomR Sent, tHhe Sendi chavste hme out
Co UnA

acle aMes Leca i ime, sendec ronsnait the nexE


IASSMAte
Oata
Pago

acde does not LoMein oe, e sendw

d s in tronsit
tht a rame T
i ac.

Sendu retyansmis The JraMe and star he ne ooE


Coonte
gaive ack. eve thesender sekransmits H
ranne

Go- bac - N ARa,


Stp-apnd-wait ARa Metonucm does noE uhlize +he
YeOUrCEs a ei bhest Wen the acde. eceivtd
e Se nder siks i noThing- n Go bad -N
Aba metuod be H erde Te ceive Mainan a eíndow

The sending -windouo Sie ena les the sende to no


Mulhpk Tameswlo receiing the
he eceivingwindo o nables he eei ten oYeceivc Mulhpe
amea ace hem he eceive Leeps ta
1Lomng ameo n@ no
When The Sender Sends all je Tane in wndp, it
he d vp t wwa Seqyence no it as receaved_pocabve
adka al fa me are posah rely acl'd ine enden
Sendls next set
ramea ende findsHaet it
has ece ved NAC OT_no RCL L ebransnMs all Hhe
aMes e wid AoES_ not recgAv anY pohve
A

3.Selechve Repeat ADO


dn Go-loac- N RRR_, it w AAU Med tha He recevea
does not have an buA space- window
and haA oCeg eau rame i k Lemmea
Scnde ReceaveA
Se tinver
Frame OD
Set lme d
hramt
seb imer fr 2
tYame Go-Bad N ARDa
close ve rdr Ot Eframe'5 h u h L

clost imer jor 1serd


Tame
Thme-ov
Strd a
fameA ETO me 3 pl
Erme4

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:

Tw enlorces he sende to etranamit all tue rrmes


net a ' e d

dn Selechve- Repeat M@, he Teceave wule eepina track e


Leqyence numbe k he rames in MemorY ends
NACC M nq T dovogeo
Tae stndu In_
Lae ends on pace
oui NAC Teceived

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;

public static void main(String[] args) throws SocketException (

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.";

public class Client (


static Socket connection;

public static void main(String al) throws SocketException (


ry
int v[] = new int[9]:

Iint gll = new int[8]:


int n = 0;
InetAddress addr = InetAddress.getByName("Localhost");
System.out.println(addr):
connection = new Socket(addr, 8011);
DataOutputStream out = new DataOutputStream(
connection.getOutputStream();
DatalnputStream in = new DatalnputStream(
connection.getlnputStream():
int p = in.read();
System.out.println("No of frame is:" + p);

for (int i = 0; i< p; i++)t


v[il = in.read();
System.out.printin(v[il):
/g[il = vlil:

v[5] = -I;
for (int i =0; i< p; i++)
System.out.println("Received frame is: " + v[i]);

for (int i = 0; i<p; i++)

if(v[il -1)f
==

System.out.printin("Request to retransmit packet no"


+(i+)+ " again!l");
n=i

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

PROBLEMS OUTPUT TERMINAL DEBUG CONSOLE + X

PS D:1SSD\Codes cd "d: \SSD\Codes" if ($?) { javac Client.java } i Code


PS D:1SSD\Codes>
f ($?) t
cd
"d:\SsD\Codes\"; if ($?) { javac Server.java } i
f
($?) { java Client }
java server LCode
waiting for connection
The number of packets sent is:9
Locaihost/127.8.8.1
No of frame is:9
PS D:\SSD\Codes> U

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!!

Received frame is: 80


quiting
PS D:\SSD\Codes>

0A0 Ln50, Col 6 Tab Size: 4 UTF-8 CRLF Java A

You might also like