TOPIC:TO IMPLEMENT SLIDING WINDOW PROTOCOL
SLIDING WINDOW
sliclient.java
*/
import java.io.*;
import java.net.*;
class sliclient
{
public static void main(String aafhbasgj[])throws Exception
{
Socket s=new Socket("localhost",6483);
String opmsg;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
DataInputStream in=new DataInputStream(s.getInputStream());
PrintStream dos=new PrintStream(s.getOutputStream());
int iterations=Integer.parseInt(in.readLine());
String msg=in.readLine();
int no=Integer.parseInt(msg);
int i=0,intr=0,iframe=0;
int framecounter=0;
while(intr<iterations)
{
msg=in.readLine();
System.out.println(msg);
i++;
framecounter++;
if(framecounter%no==0)
{
System.out.println("sending ack to server");
opmsg="ACK : FRAME "+iframe+" RECIEVED";
dos.println(opmsg);
iframe++;
}
if(i==8)
{
i=0;
intr++;
}
}
s.close();
}
}
/*
java slisender
Enter number of iterations
5
Enter window size
2
ACK : FRAME 0 RECIEVED
ACK : FRAME 1 RECIEVED
ACK : FRAME 2 RECIEVED
ACK : FRAME 3 RECIEVED
ACK : FRAME 4 RECIEVED
*/
/*
TOPIC:TO IMPLEMENT SLIDING WINDOW PROTOCOL
slisender.java
*/
import java.io.*;
import java.net.*;
class slisender
{
public static void main(String aafhbasgj[])throws Exception
{
ServerSocket ss=new ServerSocket(6483);
Socket s=ss.accept();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
DataInputStream in=new DataInputStream(s.getInputStream());
String str1;
System.out.println("Enter number of iterations");
int it=Integer.parseInt(br.readLine());
int intr=0;
int msg[]=new int[8];
for(int i=0;i<8;i++)
msg[i]=i;
PrintStream p;
int no;
p=new PrintStream(s.getOutputStream());
p.println(it);
System.out.println("Enter window size");
no=Integer.parseInt(br.readLine());
p.println(no);
int i=0;
while(intr<it)
{
p.println(msg[i]);
i++;
if(i==no)
{
str1=in.readLine();
System.out.println(str1);
}
if(i==8)
{
i=0;
intr++;
}
}
ss.close();
s.close();
}
}
/*
java sliclient
0
1
sending ack to server
2
3
sending ack to server
4
5
sending ack to server
6
7
sending ack to server
0
1
sending ack to server
2
3
sending ack to server
4
5
sending ack to server
6
7
sending ack to server
0
1
sending ack to server
2
3
sending ack to server
4
5
sending ack to server
6
7
sending ack to server
0
1
sending ack to server
2
3
sending ack to server
4
5
sending ack to server
6
7
sending ack to server
0
1
sending ack to server
2
3
sending ack to server
4
5
sending ack to server
6
7
sending ack to server
*/
Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
ReplyDeleteupvc sliding doors manufacturers hyderabad
upvc sliding doors dealers Hyderabad
upvc sliding door suppliers in hyderabad
upvc sliding door dealers
upvc sliding doors manufacturers hyderabad
upvc sliding doors in hyderabad
upvc windows and doors dealers
nice thank u you man
ReplyDelete