Return to site

Sliding Window Protocol Using Socket Programming

broken image


Sliding Windows for Lossy FIFO Ch lChannels Sufficiencyyy can only be Interesting special cases demonstrated by using a formal method to prove that the protocol gp SW = RW = 1 alternating-bit that the protocol l provides reliable in-order delivery. See Sh k d L ACM protoco SW = 7, RW = 1 Shankar and Lam, out of order arrivals. See full list on geeksforgeeks.org. Program to find prime nos in c; program to find prime nos in shell script; to calculate the characters,words and line in a se. Program to display table of number; program to display screen handling; display the sum and reverse of a number using whil. Surah rahman text download. To demonstrate nested if else using shell scripting. To find if nos are equal or not. See full list on github.com.



import java.io.*;
public class slidsender
public static void main(String a[])throws Exception
ServerSocket ser=new ServerSocket(10);
DataInputStream in=new DataInputStream(System.in);
DataInputStream in1=new DataInputStream(s.getInputStream());
PrintStream p;
String ch;
{
System.out.print('Enter the no. of frames : ');
p.println(nf);
{

System.out.println('Enter '+nf+' Messages to be sendn');
{
p.println(sbuff[sptr]);
}
Tool
System.out.print('Acknowledgment received');
System.out.println(' for '+ano+'frames');
}
{
System.out.println('The no. of frames exceeds windowsize');
}
System.out.print('nDo you wants to send some moreframes : ');
}
s.close();
}
//RECEIVER PROGRAM
import java.net.*;
class slidreceiver
public static void main(String a[])throws Exception
Socket s=new Socket(InetAddress.getLocalHost(),10);
DataInputStreamin=new DataInputStream(s.getInputStream());
PrintStream p=new PrintStream(s.getOutputStream());
String rbuf[]=new String[8];
do
nf=Integer.parseInt(in.readLine());
{
{
rbuf[rptr]=in.readLine();
System.out.println('The received Frame '+rptr+' is : '+rbuf[rptr]);
rws-=nf;
p.println(rptr+1); rws+=nf; }
break;
}
}

Enter the no. of frames : 4

how r u
how is evryone


The received Frame 0 is : hiii
The received Frame 2 is : i am fine




importjava.net.*;
Socketsender;
ObjectInputStreamin;
intn,i=0,sequence=0;
public voidrun(){
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
sender= new Socket('localhost',2004);

out=newObjectOutputStream(sender.getOutputStream());
in=newObjectInputStream(sender.getInputStream());
System.out.println('reciver > '+str);
packet=br.readLine();
do{
if(i
msg=msg.concat(packet.substring(i,i+1));
elseif(in){
}
sequence=(sequence0)?1:0;
System.out.println('datasent>'+msg);
System.out.println('waitingfor ack...nn');
i++;
System.out.println('receiver > '+' packet recievednn');
else{
System.out.println('Timeout resending data..nn');
}
}while(i
}catch(Exceptione){}
try{
out.close();
}
}
publicstatic void main(String args[]){
s.run();
}
//RECEIVER PROGRAM
import java.io.*;
public class Reciever{
Socketconnection=null;
ObjectInputStreamin;
inti=0,sequence=0;
public voidrun(){
Sliding Window Protocol Using Socket Programming
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
System.out.println('waitingfor connection..');
sequence=0;
out=newObjectOutputStream(connection.getOutputStream());
in=newObjectInputStream(connection.getInputStream());
do{
packet=(String)in.readObject();
Sliding
System.out.print('Acknowledgment received');
System.out.println(' for '+ano+'frames');
}
{
System.out.println('The no. of frames exceeds windowsize');
}
System.out.print('nDo you wants to send some moreframes : ');
}
s.close();
}
//RECEIVER PROGRAM
import java.net.*;
class slidreceiver
public static void main(String a[])throws Exception
Socket s=new Socket(InetAddress.getLocalHost(),10);
DataInputStreamin=new DataInputStream(s.getInputStream());
PrintStream p=new PrintStream(s.getOutputStream());
String rbuf[]=new String[8];
do
nf=Integer.parseInt(in.readLine());
{
{
rbuf[rptr]=in.readLine();
System.out.println('The received Frame '+rptr+' is : '+rbuf[rptr]);
rws-=nf;
p.println(rptr+1); rws+=nf; }
break;
}
}

Enter the no. of frames : 4

how r u
how is evryone


The received Frame 0 is : hiii
The received Frame 2 is : i am fine




importjava.net.*;
Socketsender;
ObjectInputStreamin;
intn,i=0,sequence=0;
public voidrun(){
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
sender= new Socket('localhost',2004);

out=newObjectOutputStream(sender.getOutputStream());
in=newObjectInputStream(sender.getInputStream());
System.out.println('reciver > '+str);
packet=br.readLine();
do{
if(i
msg=msg.concat(packet.substring(i,i+1));
elseif(in){
}
sequence=(sequence0)?1:0;
System.out.println('datasent>'+msg);
System.out.println('waitingfor ack...nn');
i++;
System.out.println('receiver > '+' packet recievednn');
else{
System.out.println('Timeout resending data..nn');
}
}while(i
}catch(Exceptione){}
try{
out.close();
}
}
publicstatic void main(String args[]){
s.run();
}
//RECEIVER PROGRAM
import java.io.*;
public class Reciever{
Socketconnection=null;
ObjectInputStreamin;
inti=0,sequence=0;
public voidrun(){
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
System.out.println('waitingfor connection..');
sequence=0;
out=newObjectOutputStream(connection.getOutputStream());
in=newObjectInputStream(connection.getInputStream());
do{
packet=(String)in.readObject();
if(Integer.valueOf(packet.substring(0,1))sequence){
sequence=(sequence0)?1:0;
}
{
System.out.println('nnreceiver >'+packet +' duplicate data');
if(i<3){
}
out.writeObject(String.valueOf((sequence+1)%2));
}
catch(Exceptione){}
System.out.println('Datarecived='+data);
}
finally{
in.close();
reciever.close();
catch(Exceptione){}
}
Recievers=new Reciever();
s.run();

Sliding Window Protocol Using Socket Programming Tools

}
}

OUTPUT:
Waiting for Connection..
Enter the data to send..
data sent>0m
receiver > packet recieved
waiting for ack...
data sent>0n
receiver > packet recieved
waiting for ack...
data sent>1a
receiver > packet recieved
waiting for ack...

C++ Socket Programming Windows

data sent>1e
receiver > packet recieved

waiting for connection..
receiver >0m
receiver >0n
receiver >1a duplicate data
receiver >1e
waiting for connection..

Sliding Window Protocol Using Socket Programming Tool


Sliding Window Protocol | Set 1 (Sender Side) - GeeksforGeeks






broken image