Question
(sending and receiving transport-level code for implementing a simple reliable data transfer protocol) ONLY want the GBN version, protocol should be NAK free The protocol
(sending and receiving transport-level code for implementing a simple reliable data transfer protocol) ONLY want the GBN version, protocol should be NAK free The protocol should be able to handle an arbitrary number of packet transmissions from the sender. And the code should run with TRACE=1,2,3. Skeleton code is provided below.
#include
#include
/* ******************************************************************
ALTERNATING BIT AND GO-BACK-N NETWORK EMULATOR: VERSION 1.1 J.F.Kurose
This code should be used for PA2, unidirectional or bidirectional
data transfer protocols (from A to B. Bidirectional transfer of data
is for extra credit and is not required). Network properties:
- one way network delay averages five time units (longer if there
are other messages in the channel for GBN), but can be larger
- packets can be corrupted (either the header or the data portion)
or lost, according to user-defined probabilities
- packets will be delivered in the order in which they were sent
(although some can be lost).
**********************************************************************/
#define BIDIRECTIONAL 0 /* change to 1 if you're doing extra credit */
/* and write a routine called B_output */
/* a "msg" is the data unit passed from layer 5 (teachers code) to layer */
/* 4 (students' code). It contains the data (characters) to be delivered */
/* to layer 5 via the students transport level protocol entities. */
struct msg {
char data[20];
};
/* a packet is the data unit passed from layer 4 (students code) to layer */
/* 3 (teachers code). Note the pre-defined packet structure, which all */
/* students must follow. */
struct pkt {
int seqnum;
int acknum;
int checksum;
char payload[20];
};
/********* STUDENTS WRITE THE NEXT SEVEN ROUTINES *********/
//set the maximum size of
#define BUFFER_SIZE 50
int seqnum = 0;
int acknum = 0;
int intransit = 0;
struct pkt prevpkt;
int expectedseqnum = 0;
/* called from layer 5, passed the data to be sent to other side */
A_output(message)
struct msg message;
{
}
B_output(message) /* need be completed only for extra credit */
struct msg message;
{
}
/* called from layer 3, when a packet arrives for layer 4 */
A_input(packet)
struct pkt packet;
{
}
/* called when A's timer goes off */
A_timerinterrupt()
{
}
/* the following routine will be called once (only) before any other */
/* entity A routines are called. You can use it to do any initialization */
A_init()
{
}
/* Note that with simplex transfer from a-to-B, there is no B_output() */
/* called from layer 3, when a packet arrives for layer 4 at B*/
B_input(packet)
struct pkt packet;
{
}
/* called when B's timer goes off */
B_timerinterrupt()
{
}
/* the following routine will be called once (only) before any other */
/* entity B routines are called. You can use it to do any initialization */
B_init()
{
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started