Course Hero Logo

IIT2019063_CN_3.docx - CN Lab Assignment - 3 Title:...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 4 pages.

CN Lab Assignment - 3Title:Implementation of sliding window protocol (Go back N and Selective Repeat)At client side:import java.lang.System;import java.net.*;import java.io.*;public class Client {static Socket connection;public static void main(String a[]) throws SocketException {try {int v[] = new int[9];//int g[] = 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());DataInputStream in = new DataInputStream(connection.getInputStream());int p = in.read();System.out.println("No of frame is:" + p);for (int i = 0; i < p; i++) {v[i] = in.read();System.out.println(v[i]);//g[i] = v[i];}v[5] = -1;for (int i = 0; i < p; i++){System.out.println("Received frame is: " + v[i]);}for (int i = 0; i < p; i++)if (v[i] == -1) {System.out.println("Request to retransmit packet no "+ (i+1) + " again!!");n = i;
out.write(n);out.flush();}System.out.println();v[n] = in.read();System.out.println("Received frame is: " + v[n]);System.out.println("quiting");} catch (Exception e) {System.out.println(e);}}}Output:Localhost/127.0.0.1

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 4 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
posma
Tags
Harshad number, Internet socket, Selective Repeat ARQ, Sliding Window Protocol, public class Client

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture