TO IMPLEMENT SELECTIVE REPEAT ARQ PROTOCOL
import
java.applet.*;
import
java.awt.*;
public class
SELECTIVE_REPEAT extends Applet {
public void init()
{
}
public void
paint(Graphics g)
{
g.drawString("Sender",50,40);
g.drawString("Receiver",325,40);
g.drawRect(40,20,60,30);//seder
g.drawLine(70,50,70,200);//sender line
g.drawRect(320,20,60,30);//Receiver
g.drawLine(350,50,350,200);//receiver line
/*Line for Frame 0*/
g.drawLine(70,60,350,60 );
g.drawLine(350,60,70,100);
/*Line for Frame
1*/
g.drawLine(70,100,350,100 );
g.drawLine(350,100,70,140);
/*Line for Frame
2*/
g.drawLine(70,140,350,140 );
g.drawLine(350,140,70,180);
/*Line for Frame
3*/
g.drawLine(70,180,350,180 );
g.drawString("Frame 0",190,60);
g.drawString("Frame 1",190,100);
g.drawString("Frame 2",190,140);
g.drawString("Frame 3",190,180);
g.drawString("ACK 0",100,90);
g.drawString("ACK 1",100,130);
g.drawString("ACK 2",100,170);
// sender frames
g.drawRect(5,55,15,15);
g.drawRect(20,55,15,15);
g.drawRect(35,55,15,15);
g.drawRect(50,55,15,15);
g.drawRect(5,95,15,15);
g.drawRect(20,95,15,15);
g.drawRect(35,95,15,15);
g.drawRect(50,95,15,15);
g.drawRect(5,135,15,15);
g.drawRect(20,135,15,15);
g.drawRect(35,135,15,15);
g.drawRect(50,135,15,15);
g.drawRect(5,175,15,15);
g.drawRect(20,175,15,15);
g.drawRect(35,175,15,15);
g.drawRect(50,175,15,15);
//Receiver Frames
g.drawRect(355,55,15,15);
g.drawRect(370,55,15,15);
g.drawRect(385,55,15,15);
g.drawRect(400,55,15,15);
g.drawRect(355,95,15,15);
g.drawRect(370,95,15,15);
g.drawRect(385,95,15,15);
g.drawRect(400,95,15,15);
g.drawRect(355,135,15,15);
g.drawRect(370,135,15,15);
g.drawRect(385,135,15,15);
g.drawRect(400,135,15,15);
g.drawRect(355,175,15,15);
g.drawRect(370,175,15,15);
g.drawRect(385,175,15,15);
g.drawRect(400,175,15,15);
g.drawString("0",9,67);
g.drawString("1",24,67);
g.drawString("2",39,67);
g.drawString("3",54,67);
g.drawString("0",9,107);
g.drawString("1",24,107);
g.drawString("2",39,107);
g.drawString("3",54,107);
g.drawString("0",9,147);
g.drawString("1",24,147);
g.drawString("2",39,147);
g.drawString("3",54,147);
g.drawString("0",9,187);
g.drawString("1",24,187);
g.drawString("2",39,187);
g.drawString("3",54,187);
//Receiver Entry
g.drawString("0",359,67);
g.drawString("1",374,67);
g.drawString("2",389,67);
g.drawString("3",404,67);
g.drawString("0",359,107);
g.drawString("1",374,107);
g.drawString("2",389,107);
g.drawString("3",404,107);
g.drawString("0",359,147);
g.drawString("1",374,147);
g.drawString("2",389,147);
g.drawString("3",404,147);
g.drawString("0",359,187);
g.drawString("1",374,187);
g.drawString("2",389,187);
g.drawString("3",404,187);
g.drawString("S,Sf",5,45);
g.drawString("Sl",20,85);
g.drawString("Rf,Rl",404,205);
}
}
--------------------------OUTPUT-------------------------
Assuming Size of
the Frame is 2
No comments:
Post a Comment