Stop And Wait Protocol Using Socket Programming In C



importjava.net.*;
Socketsender;
ObjectInputStreamin;

I am implementing stop&wait with c and udp socket programming. To simulate this protocol, I wrote two codes. This is my server.c file: #include #include <stdlib.h> #incl. 0 - Stop receiving data for this socket. If further data arrives, reject it. 1 - Stop trying to transmit data from this socket. Discard any data waiting. Stop looking for acknowledgement of data already sent; don't retransmit it if it is lost. 2 - Stop both reception and transmission. The return value is 0 on success and -1 on failure.

intn,i=0,sequence=0;

Implementation of ping command using sockets (1) implementation of remote command execution using sockets (1) implementation of reverse address resolution protocol (rarp) using sockets (1) implementation of address conversion for logical address into physical address (1) implementation of address resolution protocol (arp) using sockets (1). //connection if he ready to receive else wait // till he does not ready or timeout fails. /.server.c and client.c - implementation of go-back-n ARQ in C Server.c implements a reliable data transfer over UDP in C client.c implements a reliable data transfer client over UDP in C Both of these programs use the go-back-n ARQ, that is lost data is. To create a stream socket in the Internet domain, you could use the following call: s = socket(AFINET, SOCKSTREAM, 0); This call would result in a stream socket being created with the TCP protocol providing the underlying communication support. The default protocol, which is chosen when the protocol argument to the socket call is 0, should be.

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<n){
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<n+1);
}catch(Exceptione){}
try{
out.close();
Stop And Wait Protocol Using Socket Programming In C
}
}
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){
Stop And Wait Protocol Using Socket Programming In C
}
out.writeObject(String.valueOf((sequence+1)%2));
}
Stop
catch(Exceptione){}
System.out.println('Datarecived='+data);
}
finally{
in.close();
reciever.close();
catch(Exceptione){}
}
Recievers=new Reciever();
s.run();
}
}

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.....
data sent>1e
receiver > packet recieved

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


Aim: Program to display system time using DOS/BIOS interrupt.

.MODEL SMALL

.STACK 100H

.DATA

PROMPT DB ‘Current System Time is : $’

TIME DB ’00:00:00$’

.CODE

MAIN PROC

MOV AX, @DATA

MOV DS, AX

LEA BX, TIME

CALL GET_TIME

LEA DX, PROMPT

MOV AH, 09H

INT 21H

LEA DX, TIME

MOV AH, 09H

INT 21H

MOV AH, 4CH

INT 21H

MAIN ENDP

GET_TIME PROC

PUSH AX

PUSH CX

MOV AH, 2CH

INT 21H

MOV AL, CH

Stop and wait protocol using socket programming in c#

CALL CONVERT

MOV [BX], AX

MOV AL, CL

CALL CONVERT

Stop and wait protocol using socket programming in c++

MOV [BX+3], AX

MOV AL, DH

CALL CONVERT

MOV [BX+6], AX

POP CX

POP AX

RET

GET_TIME ENDP

CONVERT PROC

PUSH DX

MOV AH, 0

MOV DL, 10

DIV DL

OR AX, 3030H

POP DX

RET

CONVERT ENDP

END MAIN

Stop And Wait Protocol Using Socket Programming In Cpp

Download Here :Display Time