From 45ce29b87474e169f50d84528a880ef988cc7a1f Mon Sep 17 00:00:00 2001 From: yash Date: Thu, 31 Oct 2019 23:30:42 +0530 Subject: [PATCH 1/2] client side for go back N protocol in computer networks --- scripts/GobackClient.java | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 scripts/GobackClient.java diff --git a/scripts/GobackClient.java b/scripts/GobackClient.java new file mode 100644 index 00000000..bd4edd83 --- /dev/null +++ b/scripts/GobackClient.java @@ -0,0 +1,71 @@ +import java.util.*; +import java.net.*; +import java.io.*; +public class GobackClient { + + public static void main(String[] args) throws IOException { + // TODO Auto-generated method stub + Socket s=new Socket("localhost",4001); + DataInputStream in=new DataInputStream(s.getInputStream()); + DataOutputStream out=new DataOutputStream(s.getOutputStream()); + Scanner sc=new Scanner(System.in); + int frame_size=10,m,res,val=0; + double wind; + m=in.readInt(); + wind=(Math.pow(2,m))-1; + int []a=new int[frame_size]; + for(int i=0;i0) + { + System.out.println("Enter 1 if you've received all the frames:\n"); + res=sc.nextInt(); + out.writeInt(res); + if(res!=1) + { + int j; + System.out.println("Enter the frame that you didn't receive:\n"); + res=sc.nextInt(); + out.writeInt(res); + //System.out.println("lets retransmit it:\n"); + for(j=res-1;j Date: Thu, 31 Oct 2019 23:38:02 +0530 Subject: [PATCH 2/2] server side for go back N protocol in computer networks --- scripts/GobackServer.java | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 scripts/GobackServer.java diff --git a/scripts/GobackServer.java b/scripts/GobackServer.java new file mode 100644 index 00000000..867ea8a6 --- /dev/null +++ b/scripts/GobackServer.java @@ -0,0 +1,65 @@ +import java.util.*; +import java.net.*; +import java.io.*; +public class GobackServer { + public static void main(String args[]) throws IOException + { + ServerSocket ss=new ServerSocket(4001); + Socket s=ss.accept(); + DataInputStream in=new DataInputStream(s.getInputStream()); + DataOutputStream out=new DataOutputStream(s.getOutputStream()); + Scanner sc=new Scanner(System.in); + int frame_size=10,m,res,val=0; + double wind; + int []a=new int[frame_size]; + for(int i=0;i0) + { + res=in.readInt(); + if(res!=1) + { + int j; + res=in.readInt(); + System.out.println("lets retransmit it:\n"); + for(j=res-1;j