You are on page 1of 47

SELECTIVE REPEAT ARQ PROTOCOL

CHAPTER 1
INTRODUCTION

Computer graphics is concerned with all aspects of producing pictures or images using a
computer. Computer Graphics become a powerful tool for the rapid and economical production of
pictures. There is virtually no area in which Graphical displays cannot be used to some advantage,
so it is not surprising to find the use of CG so widespread. Here we use a particular graphics
software system, OpenGL; which has become a widely accepted standard for developing graphics
applications.
The various applications of computer graphics include:

 Display of information
 Design
 Simulation and animation
 User interface

As a software interface for the graphics hardware, OpenGL’s main purpose is render two and three
dimensional objects into a frame buffer. These objects are described as sequences of vertices (which
define geometric objects) or pixels (which define images). OpenGL performs several processing
steps on this data to convert it to pixels of form the final desired images in the frame buffer.
It deals with generating images with the aid of computers. Today, computer graphics is a core
technology in digital photography, film, video games, cell phone and computer displays, and many
specialized applications. A great deal of specialized hardware and software has been developed, with
the displays of most devices being driven by computer graphics hardware. It is a vast and recently
developed area of computer science. Computer graphics is responsible for displaying art and image
data effectively and meaningfully to the consumer. It is also used for processing image data received
from the physical world, such as photo and video content.

Dept. Of CSE, RIT, Hassan 2020-2021 Page 1


SELECTIVE REPEAT ARQ PROTOCOL

1.1 Introduction to OpenGL

Fig 1.1: OpenGL

OpenGL provides a set of commands to render a three dimensional scene. That means you
provide the data in an OpenGL-useable form and OpenGL will show this data on the screen
(render it).It is developed by many companies and it is free to use. You can develop OpenGL-
applications without licensing.
OpenGL is a hardware and system-independent interface. An OpenGL application will
work on every platform, as long as there is an installed implementation. Because it is system
independent, there are no functions to create windows etc., but there are helper functions for each
platforms. A very useful thing is GLUT.
OpenGL is an actively developed API. New versions of the OpenGL specifications are
regularly released by the Khronos Group, each of which extends the API to support various new
features. The details of each version are decided by consensus between the Group's members,
including graphics card manufacturers, operating system designers, and general technology
companies such as Mozilla and Google.In addition to the features required by the core API, graphics
processing unit (GPU) vendors may provide additional functionality in the form of extensions.
Extensions may introduce new functions and new constants, and may relax or remove restrictions on
existingOpenGLfunctions.

Dept. Of CSE, RIT, Hassan 2020-2021 Page 2


SELECTIVE REPEAT ARQ PROTOCOL

Features of OpenGL:
The main features of OpenGL are

 It provides 3D geometric objects such as lines, polygons, triangles, meshes, spheres, cubes,
curved surfaces.

 It provides 3D modeling transformations and viewing functions to create views of 3D


scenes using the idea of virtual camera.

 It supports high quality rendering of scenes, including hidden surface removal, multiple
light sources, material types, transparency etc.

 It provides display lists for creating graphics caches and hierarchical models.

 It supports manipulation of images as pixels, enabling frame-buffer effects such as anti-


aliasing, motion blur, depth of field and soft shadows.

1.2 CODE BLOCKS

Fig 1.1: Code Blocks


After releasing two release candidate versions, 1.0rc1 on July 25, 2005 and 1.0rc2 on October
25, 2005, instead of making a final release, the project developers started adding many new
features, with the final release being repeatedly postponed. Instead, there were nightly builds of the
latest SVN version made available on a daily basis.[citation needed]. The first stable release was on
February 28, 2008, with the version number changed to 8.02. The versioning scheme was changed
to that of Ubuntu, with the major and minor number representing the year and month of the release.
however for the most up-to-date version the user can download the relatively stable nightly build or
download the source code from SVN

Dept. Of CSE, RIT, Hassan 2020-2021 Page 3


SELECTIVE REPEAT ARQ PROTOCOL

1.3 Support Libraries:


 OpenGL provides a powerful but primitive set of rendering command, and all higher level
drawing must be done in terms of these commands. There are several libraries that allow
you to simplify your programming tasks, including the following:

 GL provides lower level functions for drawing points, lines and polygons. All GL function
name starts with “gl”.

 OpenGL Utility Library (GLU) contains several routines that use lower level OpenGL
commands to perform such tasks as setting up matrices for specific viewing orientations

and projections and rendering surfaces.

 OpenGL Utility Toolkit (GLUT) is a window-system-independent toolkit, written by Mark


Kilgard, to hide the complexities of differing window APIs.

Dept. Of CSE, RIT, Hassan 2020-2021 Page 4


SELECTIVE REPEAT ARQ PROTOCOL

Chapter 2
LITERATURE SURVEY
A literature review or narrative review is a type of review article. A literature review is a
scholarly paper, which includes the current knowledge including substantive findings, as well as
theoretical and methodological contributions to a particular topic. Literature reviews are
secondary sources, and do not report new or original experimental work. Most often associated
with academic-oriented literature, such reviews are found in academic journals, and are not to be
confused with book reviews that may also appear in the same publication. Literature reviews are a
basis for research in nearly every academic field.[1] A narrow-scope literature review may be
included as part of a peer-reviewed journal article presenting new research, serving to situate the
current study within the body of the relevant literature and to provide context for the reader. In
such a case, the review usually precedes the methodology and results sections of the work.

2.1 The OpenGL Programming Guide –The Redbook

 The OpenGL Programming Guide 5th Edition. The Official Guide to


Learning OpenGL Version 2.1
The OpenGL Programming Guide, Fifth Edition, provides definitive and comprehensive
information on OpenGL Utility Library. The previous edition covered OpenGL through Version
1.3 and 1.4. This fifth edition of the best-selling “red-book” description the latest features of
OpenGL Version 1.5 and 2.0, including the introduction of the OpenGL Shading language. You
will find clear explanation of OpenGL functionality and many basic computer graphics techniques,
such as building and rendering 3D models; interactively viewing texture mapping, antialiasing, fog
and atmosphere effects, NURBS, image processing, and more.
The page which you are watching has to written by someone in some language. That part
is called Front end and it will be written by HTML, CSS, JavaScript, JQuery are some of them.
And the server part called as Back end it may be in PHP, C#, Java, Perl are few to mention. And
all the data will present in the Database.

Dept. Of CSE, RIT, Hassan 2020-2021 Page 5


SELECTIVE REPEAT ARQ PROTOCOL

2.2 OpenGL Resources

 Pervisim offers consulting and software development for visualization


leveraging OpenGL
Pervisim is a new software development firm located in carry, NC that specializes in 3D
visualization application. Recently completed and revived project include mash up visualization
that create terrain visualization in 3D pdf and molecular modelling using OpenGL.

 VSFL-Very Simple Font Library


Text rendering is very useful to display information on top of 3D world. VSFL aims at providing
users with the ability to render bitmapped text in an OpenGL application using the core profile.
With immediate mode gone in core OpenGL version, so are the vast majority of font libs that
worked with OpenGL. Immediate mode was terribly slow, a code was very extensive. Vertex
Buffer are clearly the way to go. This lib uses VAOs and vertex buffer to render text.
The basic functions like glColor3f (…); glRotatef (...), glTranslatef (...) etc that are most
commonly used in the code are taken from the prescribed VTU Text book “INTERACTIVE
COMPUTER GRAPHICS” 5th edition by Edward Angel.
The lab programs in the syllabus also serve as a basic template for creating a project. The usage of
colours and specifications are taken from the various programs that were taught in the lab.
The VTU prescribed text book serves as a huge database of functions and they are used in the
project.

Dept. Of CSE, RIT, Hassan 2020-2021 Page 6


SELECTIVE REPEAT ARQ PROTOCOL

CHAPTER 3

REQUIREMENTS & SPECIFICATION

System Specifications

This is mainly the specification of the problem and how the solution is to be brought
about. Since the requirements of this package are widely known, only the requirements and
specification are started without elaborating each of its functionality.

Hardware Requirements

Disk Space : 40 GB

PC Used : IBM Compatible

Processor : Intel® Pentium®

Memory : 1 GB RAM
File System : 64 Bit

Software Requirements
Operating System (Server Side) : Windows 10, 7 and above
Operating System (Client Side) : Windows 10, 7 and above
IDE : Code Blocks
Programing language : c++

Dept. Of CSE, RIT, Hassan 2020-2021 Page 7


SELECTIVE REPEAT ARQ PROTOCOL

CHAPTER 4

SOFTWARE DESIGN

4.1 Project description

Selective Repeat Selective Repeat is part of the automatic repeat-request (ARQ). An ARQ
is an efficient scheme to obtain a reliable data transmission when the channel does not satisfy &e
required quality of service . Several different schemes modified by the basic ARQ strategies have
been proposed in order to improve the throughput efficiency . The key idea of this protocol is that
the sender transmits new frames continuously as long as no error occurs. When the frame error
occurs, the sender stops transmitting new frames. The transmitter numbers the packets to be
transmitted sequentially (using numbers from a finite set) and maintains a timer for each packet it
transmits. The receiver accepts each error-free block and positively acknowledges it by sending an
ACK message. On receipt of an erroneous block, the receiver negatively acknowledges the block
by sending a NAK. The acknowledgments follow a Selective Repeat style of approach such that
they include a bitmap denoting the reception status of all the packets transmitted since the last
ACK. The base station therefore only retransmits the incorrectly received packets. Among ARQ
schemes, the selective repeat (SR) is preferable than go-back-N since radio resource is very scarce
and SR gives higher channel efficiency.
The different functions performed in this project are - Packet Sending: Demo the sending of
packet from source to destination. ACK Receival: Send the ACK message, once the packets are
received. Packet Crashing: The loss and crashing of packets is demoed. NAK Receive: Send the
NAK message, once the packets are not received. Frame Resending: Sending the frame again due to
NAK receival.

Dept. Of CSE, RIT, Hassan 2020-2021 Page 8


SELECTIVE REPEAT ARQ PROTOCOL

Flow Chart

Fig 4.1: Flow chart of selective repeat ARQ protocol

Dept. Of CSE, RIT, Hassan 2020-2021 Page 9


SELECTIVE REPEAT ARQ PROTOCOL

CHAPTER 5

IMPLEMENTATION

5.1 Function in OpenGL


 glClearColor: This function call sets the present RGBA clear color used when clearing the
color buffer. The RGB stands for Red, Green and Blue.
 glFlush: This function call forces any buffered OpenGL command to execute.
 glutCreateWindow: This function call creates a window on the display the string title can be
used to label the window.
 glutInitDisplayMode: This function call request a display with the properties that are
specified in m mode. The value of mode is determined by the logical OR operation of options
including the color model.
 glutDisplayFunc: This function call registers the display function *funci.e executed when the
window needs to be redrawn.
 glutPostRedisplay: This function call request the display call back be executed after the
current call back returns.

 glutMainLoop: This function call causes the program to enter an event processing loop.It
should be the last statement in main.

 glLoadIdentity: This function call sets current transformation matrix to an identity matrix.

 glPushMatrix and glPopMatrix: These function call pushes to and pop from the matrix stack
corresponding to the current matrix mode..

 glRotate: This function call alter the current matrix by a rotation of angle degrees about the
axis (dx,dy,dz).

 glScale: This function call alter the current matrix by specified scaling factor along the axis
(x,y,d).

Dept. Of CSE, RIT, Hassan 2020-2021 Page 10


SELECTIVE REPEAT ARQ PROTOCOL
 glTranslate: This function call alters the current matrix by a displacement of(x,y,z).

 glClear: This function is used to clear the window. As the algorithm stores information depth
buffer, so it necessary to clear the buffer whenever we wish to redraw the display.

 Setfont(): It is used to tell the renderer which font is current

 Drawstring(): It contains four arguments-x,y,z coordinates and a string,while the coordinate


assumed to be the space where string to be placed and the string is the value to be display.

 glutBitmapCharacter: Automatically sets the OpenGL unpack pixel storage modes it needs
appropriately and saves and restores the previous modes before returning. The generated call
to glBitmap will adjust the current raster position based on the width of the character.

 glRasterPos: Specify the raster position for pixel operations

 glutKeyboardFunc: Sets the keyboard callback for the current window.

 glutMouseFunc:Sets the mouse callback for current window.

 glBegin: Delimit the vertices of a primitive or a group of like primitives.


 glVertex: Specify a vertex.
 glColor: Set the current color.

5.2 Source code

#include<GL/glut.h>
#include<stdio.h>
#include<stdlib.h>
#include<GL/gl.h>
#define dx 15
#define dy 25
Dept. Of CSE, RIT, Hassan 2020-2021 Page 11
SELECTIVE REPEAT ARQ PROTOCOL

void *currentfont;
int window;

GLfloat x[25];
GLfloat y[20];
GLint i,j,k;
int w,h;
void setFont(void *font)
{
currentfont=font;
}
void drawstring(float x,float y,float z,char *string)
{
char *c;
glRasterPos3f(x,y,z);

for(c=string;*c!='\0';c++)
{ glColor3f(0.0,0.0,0.0);
glutBitmapCharacter(currentfont,*c);
}
}

void text(void) // to draw


the text in menu screen
{
setFont(GLUT_BITMAP_HELVETICA_18);
glColor3f(1.0,1.0,1.0);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 12


SELECTIVE REPEAT ARQ PROTOCOL

drawstring(95.0,455.0,1.0,(char*)"* * * * * * * * * S E L E C T I V E REPEAT
A R Q * * * * * * * * *");

glColor3f(1.0,1.0,1.0);
drawstring(210.0,405.0,1.0,(char*)"SEND WINDOW");

glColor3f(1.0,1.0,1.0);
drawstring(200.0,350.0,1.0,(char*)" RECEIVE WINDOW");

glColor3f(1.0,1.0,1.0);
drawstring(210.0,295.0,1.0,(char*)"SAFE SENDING");

glColor3f(1.0,1.0,1.0);
drawstring(200.0,240.0,1.0,(char*)"PACKET CRASHING");

glColor3f(1.0,1.0,1.0);

glColor3f(1.0,1.0,1.0);
drawstring(200.0,350.0,1.0,(char*)" RECEIVE WINDOW");

glColor3f(1.0,1.0,1.0);
drawstring(210.0,295.0,1.0,(char*)"SAFE SENDING");

glColor3f(1.0,1.0,1.0);
drawstring(200.0,240.0,1.0,(char*)"PACKET CRASHING");

glColor3f(1.0,1.0,1.0);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 13


SELECTIVE REPEAT ARQ PROTOCOL

drawstring(215.0,185.0,1.0,(char*)" TIME OUT");

glColor3f(1.0,1.0,1.0);
drawstring(225.0,130.0,1.0,(char*)" EXIT");
glFlush();
}

void draw() // TO DRAW POLYGON FOR DISPLAY MENUS


{

glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON); // send window
glColor3f(0.7f,0.2f,0.2f);
glVertex2i(305,425);
glVertex2i(180,425);
glVertex2i(180,395);
glVertex2i(305,395);
glEnd();
glFlush();

glBegin(GL_POLYGON); // recieve window


glColor3f(0.7f,0.2f,0.2f);
glVertex2i(305,370);
glVertex2i(180,370);
glVertex2i(180,340);
glVertex2i(305,340);
glEnd();
glFlush();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 14


SELECTIVE REPEAT ARQ PROTOCOL

glBegin(GL_POLYGON); // safe sending


glColor3f(0.7f,0.2f,0.2f);
glVertex2i(305,315);
glVertex2i(180,315);
glVertex2i(180,285);
glVertex2i(305,285);
glEnd();
glFlush();

glBegin(GL_POLYGON); // packet crashing


glColor3f(0.7f,0.2f,0.2f);
glVertex2i(305,260);
glVertex2i(180,260);
glVertex2i(180,230);
glVertex2i(305,230);
glEnd();
glFlush();

glBegin(GL_POLYGON); // time out


glColor3f(0.7f,0.2f,0.2f);
glVertex2i(305,205);
glVertex2i(180,205);
glVertex2i(180,175);
glVertex2i(305,175);
glEnd();
glFlush();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 15


SELECTIVE REPEAT ARQ PROTOCOL
glBegin(GL_POLYGON); // exit
glColor3f(0.7f,0.2f,0.2f);
glVertex2i(305,150);
glVertex2i(180,150);
glVertex2i(180,120);
glVertex2i(305,120);
glEnd();
glFlush();

}
void myInit()
{
glClearColor(0.0,0.0,0.0,0.0);
glColor3f(0.0f,0.0f,0.0f);
glPointSize(5.0);
gluOrtho2D(0.0,500.0,0.0,500.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
setFont(GLUT_BITMAP_HELVETICA_18);

void computer() // to draw the


sender and receiver computers
{
glColor3f(1.0f,1.0f,1.0f);
setFont(GLUT_BITMAP_HELVETICA_12);
drawstring(95.0,420.0,1.0,(char*)"SENDER");

glColor3f(1.0f,1.0f,1.0f);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 16


SELECTIVE REPEAT ARQ PROTOCOL

drawstring(345.0,420.0,1.0,(char*)"RECEIVER");

glColor3f(0.7,0.2,0.0);//monitor
glBegin(GL_LINE_LOOP);
glVertex2f(85,380);
glVertex2f(85,440);
glVertex2f(150,440);
glVertex2f(150,380);
glEnd();
glFlush();

glColor3f(0.7,0.2,0.0);//monitor
glBegin(GL_LINE_LOOP);
glVertex2f(87,382);
glVertex2f(87,438);
glVertex2f(148,438);
glVertex2f(148,382);
glEnd();
glFlush();

glColor3f(0.7,0.0,0.2);//vertical stand
glBegin(GL_LINES);
glVertex2f(105,380);
glVertex2f(105,375);
glVertex2f(129,380);
glVertex2f(129,375);
glEnd();
glFlush();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 17


SELECTIVE REPEAT ARQ PROTOCOL

glColor3f(0.7,0.3,0.2); //horizontal stand


glBegin(GL_QUADS);
glVertex2f(98,370);
glVertex2f(98,375);
glVertex2f(138,375);
glVertex2f(138,370);
glEnd();
glFlush();

glColor3f(0.7,0.2,0.2); //CPU
glBegin(GL_LINE_LOOP);
glVertex2f(80,350);
glVertex2f(80,370);
glVertex2f(155,370);
glVertex2f(155,350);
glEnd();
glFlush();

glColor3f(0.7,0.8,0.2); //CPU
glBegin(GL_QUADS);
glVertex2f(95,360);
glVertex2f(95,365);
glVertex2f(115,365);
glVertex2f(115,360);
glEnd();
glFlush();
glColor3f(0.7,0.2,0.8); //CPU
glBegin(GL_QUADS);
glVertex2f(132,358);
glVertex2f(132,361);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 18


SELECTIVE REPEAT ARQ PROTOCOL

glVertex2f(140,361);
glVertex2f(140,358);
glEnd();
glFlush();
glColor3f(0.7,0.2,0.2);//keyboard outline
glBegin(GL_LINE_LOOP);
glVertex2f(77,325);
glVertex2f(87,350);
glVertex2f(148,350);
glVertex2f(158,325);
glEnd();
glFlush();
glColor3f(0.7,0.2,0.2);//keyboard outline
glBegin(GL_POLYGON);
glVertex2f(77,325);
glVertex2f(158,325);
glVertex2f(158,322);
glVertex2f(77,322);
glEnd();
glFlush();

glColor3f(0.7,0.0,0.2); //horizontal lines of keyboard


glBegin(GL_LINES);
glVertex2f(85,345);
glVertex2f(150,345);
glVertex2f(83,340);
glVertex2f(152,340);
glVertex2f(81,335);
glVertex2f(154,335);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 19


SELECTIVE REPEAT ARQ PROTOCOL

glVertex2f(79,330);
glVertex2f(156,330);
glVertex2f(77,325);
glVertex2f(158,325);
glEnd();
glFlush();

glColor3f(0.7,0.0,0.2); //vertical lines of keyboard


glBegin(GL_LINES);
glVertex2f(89,322);
glVertex2f(97,350);
glVertex2f(103,322);
glVertex2f(107,350);
glVertex2f(117,322);
glVertex2f(117,350);
glVertex2f(131,322);
glVertex2f(127,350);
glVertex2f(145,322);
glVertex2f(137,350);
glEnd();
glFlush();

// COMPUTER AT RECEIVER

glColor3f(0.7,0.2,0.0);//monitior
glBegin(GL_LINE_LOOP);
glVertex2f(335,380);
glVertex2f(335,440);
glVertex2f(400,440);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 20


SELECTIVE REPEAT ARQ PROTOCOL

glVertex2f(400,380);
glEnd();
glFlush();

glColor3f(0.7,0.2,0.0);//monitior
glBegin(GL_LINE_LOOP);
glVertex2f(337,382);
glVertex2f(337,438);
glVertex2f(398,438);
glVertex2f(398,382);
glEnd();
glFlush();
glColor3f(0.7,0.0,0.2);//ver
glBegin(GL_LINES);
glVertex2f(355,380);
glVertex2f(355,375);
glVertex2f(379,380);
glVertex2f(379,375);
glEnd();
glFlush();

glColor3f(0.7,0.3,0.2);//hor
glBegin(GL_QUADS);
glVertex2f(348,370);
glVertex2f(348,375);
glVertex2f(388,375);
glVertex2f(388,370);
glEnd();
glFlush();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 21


SELECTIVE REPEAT ARQ PROTOCOL

glColor3f(0.7,0.2,0.2);//CPU
glBegin(GL_LINE_LOOP);
glVertex2f(330,350);
glVertex2f(330,370);
glVertex2f(405,370);
glVertex2f(405,350);
glEnd();
glFlush();

glColor3f(0.7,0.8,0.2); //CPU
glBegin(GL_QUADS);
glVertex2f(345,360);
glVertex2f(345,365);
glVertex2f(365,365);
glVertex2f(365,360);
glEnd();
glFlush()

glColor3f(0.7,0.2,0.8); //CPU
glBegin(GL_QUADS);
glVertex2f(382,358);
glVertex2f(382,361);
glVertex2f(390,361);
glVertex2f(390,358);
glEnd();
glFlush();

glColor3f(0.7,0.2,0.2);//keyboard
glBegin(GL_LINE_LOOP);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 22


SELECTIVE REPEAT ARQ PROTOCOL

glVertex2f(327,322);
glVertex2f(337,350);
glVertex2f(398,350);
glVertex2f(408,322);
glEnd();
glFlush();

glColor3f(0.7,0.2,0.2);//keyboard
glBegin(GL_POLYGON);
glVertex2f(327,325);
glVertex2f(408,325);
glVertex2f(408,322);
glVertex2f(327,322);
glEnd();
glFlush();

glColor3f(0.7,0.0,0.2); //horizontal lines of keyboard


glBegin(GL_LINES);
glVertex2f(335,345);
glVertex2f(400,345);
glVertex2f(333,340);
glVertex2f(402,340);
glVertex2f(331,335);
glVertex2f(404,335);
glVertex2f(329,330);
glVertex2f(406,330);
glVertex2f(327,325);
glVertex2f(408,325);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 23


SELECTIVE REPEAT ARQ PROTOCOL

glEnd();
glFlush();

glColor3f(0.7,0.0,0.2); //vertical lines of keyboard


glBegin(GL_LINES);
glVertex2f(339,322);
glVertex2f(347,350);
glVertex2f(353,322);
glVertex2f(357,350);
glVertex2f(367,322);
glVertex2f(367,350);
glVertex2f(381,322);
glVertex2f(377,350);
glVertex2f(395,322);
glVertex2f(387,350);
glEnd();
glFlush();

glColor3f(0.3,0.6,0.8);//connectin wire
glBegin(GL_LINES);
glVertex2f(155,360);
glVertex2f(330,360);
glEnd();
glFlush();
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(410,425);
glVertex2f(410,430);
glVertex2f(425,430);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 24


SELECTIVE REPEAT ARQ PROTOCOL

glVertex2f(425,425);
glEnd();
glFlush();

setFont(GLUT_BITMAP_HELVETICA_12);
glColor3f(1.0,1.0,1.0);
drawstring(432.0,425.5,1.0,(char*)"DATA FRAMES");
glFlush();

glColor3f(0.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2f(410,410);
glVertex2f(410,415);
glVertex2f(420,415);
glVertex2f(420,410);
glEnd();
glFlush();

glColor3f(1.0,1.0,1.0);
drawstring(432.0,410.5,1.0,(char*)"ACK ");
glFlush();

glColor3f(1.0,1.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(410,395);
glVertex2f(410,400);
glVertex2f(420,400);
glVertex2f(420,395);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 25


SELECTIVE REPEAT ARQ PROTOCOL

glEnd();
glFlush();

glColor3f(1.0,1.0,1.0);
drawstring(432.0,395.5,1.0,(char*)"NAK");
glFlush();

void slide(GLint maxx,GLint maxy,GLfloat x0,GLfloat y0) // TO DRAW WINDOWS (Rectangular


Mesh)
{
for(i=0;i<maxx;i++)
x[i]=x0+i*dx;

for(j=0;j<maxy;j++)
y[j]=y0+j*dy;

for(i=0;i<maxx-1;i++)
for(j=0;j<maxy-1;j++)
{

glBegin(GL_LINE_LOOP);
glVertex2f(x[i],y[j]);
glVertex2f(x[i],y[j+1]);
glVertex2f(x[i+1],y[j+1]);
glVertex2f(x[i+1],y[j]);
glEnd();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 26


SELECTIVE REPEAT ARQ PROTOCOL

glFlush();

void delay()
{
j=28000;
while(j!=0)
{
j--;
i=28000;
while(i!=0)
{

void timer0()
{
glColor3f(1.4,1.9,0.78);
glBegin(GL_LINE_LOOP); // timer for frame 0
glVertex2f(100,120);
glVertex2f(100,130);
glVertex2f(225,130);
glVertex2f(225,120);
glEnd();
glFlush();
}

void timer1()
{

glColor3f(1.4,1.9,0.78);
glBegin(GL_LINE_LOOP); // timer for frame 1

Dept. Of CSE, RIT, Hassan 2020-2021 Page 27


SELECTIVE REPEAT ARQ PROTOCOL

glVertex2f(100,100);
glVertex2f(100,110);
glVertex2f(225,110);
glVertex2f(225,100);
glEnd();
glFlush();

void timer2()
{
glColor3f(1.4,1.9,0.78);
glBegin(GL_LINE_LOOP); // timer for frame 2
glVertex2f(100,80);
glVertex2f(100,90);
glVertex2f(225,90);
glVertex2f(225,80);
glEnd();
glFlush();
}

void timer3()
{
glColor3f(1.4,1.9,0.78);
glBegin(GL_LINE_LOOP); // timer for frame 3
glVertex2f(360,120);
glVertex2f(360,130);
glVertex2f(485,130);
glVertex2f(485,120);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 28


SELECTIVE REPEAT ARQ PROTOCOL

glEnd();
glFlush();
}

void timer4()
{
glColor3f(1.4,1.9,0.78);
glBegin(GL_LINE_LOOP); // timer for frame 4
glVertex2f(360,100);
glVertex2f(360,110);
glVertex2f(485,110);
glVertex2f(485,100);
glEnd();
glFlush();
}

void timer(float k,float l,float m,float n)


{
glColor3f(1.4,1.9,0.78);
glBegin(GL_POLYGON); // to call timer functions
glVertex2f(l,m);
glVertex2f(l,n);
glVertex2f(l+k,n);
glVertex2f(l+k,m);
glEnd();
glFlush();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 29


SELECTIVE REPEAT ARQ PROTOCOL

void title() // to
draw the starting screen
{

setFont(GLUT_BITMAP_HELVETICA_18);

glColor3f(1.0,1.0,1.0);
drawstring(20.0,435.0,1.0,(char*)"* * G R A P H I C A L I L L U S T R A T I O N OF S
E LECT IVE REPE AT A R Q P R O T O C O L * *");

glColor3f(1.0,1.0,1.0);
drawstring(210.0,365.0,1.0,(char*)"SUBMITTED BY");

glColor3f(0.0,1.0,1.0);
drawstring(180.0,340.0,1.0,(char*)" Name:Criston Mascarenhas USN:4VP16CS024");

glColor3f(0.0,1.0,1.0);
drawstring(180.0,320.0,1.0,(char*)" Name:Hanishraj B Rao USN:4VP16CS034");

glColor3f(1.0,1.0,1.0);
drawstring(190.0,260.0,1.0,(char*)"UNDER THE GUIDANCE OF");

glColor3f(0.0,1.0,1.0);
drawstring(70.0,230.0,1.0,(char*)" Guide:Ms. Bharathi K");

setFont(GLUT_BITMAP_HELVETICA_12);

//glColor3f(0.0,1.0,1.0);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 30


SELECTIVE REPEAT ARQ PROTOCOL

//drawstring(190.0,230.0,1.0,(char*)" Guide Degrees .");

glColor3f(0.0,1.0,1.0);
drawstring(70.0,215.0,1.0,(char*)" Assistant Professor, Dept of CSE");

glColor3f(0.0,1.0,1.0);
drawstring(70.0,200.0,1.0,(char*)" Vivekananda College Of Engineering and Technology");

//setFont(GLUT_BITMAP_HELVETICA_18);

//glColor3f(0.0,1.0,1.0);
//drawstring(280.0,230.0,1.0,(char*)" same");
//setFont(GLUT_BITMAP_HELVETICA_12);

//glColor3f(0.0,1.0,1.0);
//drawstring(360.0,230.0,1.0,(char*)" same,");

//glColor3f(0.0,1.0,1.0);
//drawstring(285.0,215.0,1.0,(char*)" same");

//glColor3f(0.0,1.0,1.0);
//drawstring(285.0,200.0,1.0,(char*)" same above");

glFlush();
}

Dept. Of CSE, RIT, Hassan 2020-2021 Page 31


SELECTIVE REPEAT ARQ PROTOCOL

void move1() //MOVEMENT OF FRAME 0 (in safe sending)


{

float i,j,temp=0.3;

glColor3f(1.0,0.8,0.4);
setFont(GLUT_BITMAP_HELVETICA_18);
drawstring(30.0,125.0,1.0,(char*)" Timer 0");

timer0();
float k=0;

setFont(GLUT_BITMAP_HELVETICA_12);
glColor3f(1.0f,1.0f,0.0f);
drawstring(160.0,370.0,1.0,(char*)"FRAME 0 sending ...........");

for(j=0;j<4;j=j+temp) //movement of data packet within the frame


{ glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex2i(55,265-j);glVertex2i(55,280-j);glVertex2i(60,280-j);glVertex2i(60,265-j);
glEnd();
glFlush();

glColor3f(0,0,0); // to remove traces create movement of frame in black


glBegin(GL_QUADS);
glVertex2i(55,265-j);glVertex2i(55,280-j);glVertex2i(60,280-j);glVertex2i(60,265-j);
glEnd();
glFlush();
}

Dept. Of CSE, RIT, Hassan 2020-2021 Page 32


SELECTIVE REPEAT ARQ PROTOCOL

for(j=0;j<60;j=j+temp) //movement of data packet from top to down


{ glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex2i(55,238-j);glVertex2i(55,253-j);glVertex2i(60,253-j);glVertex2i(60,238-j);
glEnd();
glFlush();

k+=0.05;
timer(k,102.5,122,128);

glColor3f(0,0,0);
glBegin(GL_QUADS);
glVertex2i(55,238-j);glVertex2i(55,253-j);glVertex2i(60,253-j);glVertex2i(60,238-j);
glEnd();
glFlush();
}

for(i=0;i<231;i=i+temp) //movement of data packet sidewise


{ glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex2i(60+i,178);glVertex2i(60+i,183);glVertex2i(75+i,183);glVertex2i(75+i,178);
glEnd();
glFlush();

k+=0.05;
timer(k,102.5,122,128);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 33


SELECTIVE REPEAT ARQ PROTOCOL

glColor3f(0,0,0);
glBegin(GL_QUADS);
glVertex2i(60+i,178);glVertex2i(60+i,183);glVertex2i(75+i,183);glVertex2i(75+i,178);
glEnd();
glFlush();
}

for(j=0;j<60;j=j+temp) //to move the packet from bottom to top


{
glColor3f(1,0,0);
glBegin(GL_QUADS);

glVertex2i(305,178+j);glVertex2i(305,193+j);glVertex2i(310,193+j);glVertex2i(310,178+j);
glEnd();
glFlush();

k+=0.05;
timer(k,102.5,122,128);

glColor3f(0,0,0);
glBegin(GL_QUADS);

glVertex2i(305,178+j);glVertex2i(305,193+j);glVertex2i(310,193+j);glVertex2i(310,178+j);
glEnd();
glFlush();

setFont(GLUT_BITMAP_HELVETICA_12);
glColor3f(0.0f,0.0f,0.0f);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 34


SELECTIVE REPEAT ARQ PROTOCOL

glColor3f(1.0,1.0,0.0);
drawstring(160.0,370.0,1.0,(char*)"FRAME 0 sent");

// delay();

setFont(GLUT_BITMAP_HELVETICA_12);
glColor3f(0.0,0.0,0.0);
drawstring(160.0,370.0,1.0,(char*)"FRAME 0 sent");

}
void move2() // SIMULTANEOUS MOVEMENT OF ACK 1 AND FRAME 1(in safe sending)
{
float i,j,temp=0.3;

setFont(GLUT_BITMAP_HELVETICA_18);

glColor3f(1.0,0.8,0.4);
drawstring(30.0,105.0,1.0,(char*)" Timer 1");

setFont(GLUT_BITMAP_HELVETICA_12);

glColor3f(1.0f,1.0f,0.0f);
drawstring(160.0,370.0,1.0,(char*)"FRAME 1 sending ...........");

glColor3f(1.0f,1.0f,0.0f);
drawstring(230.0,345.0,1.0,(char*)"........... sending ACK1 ");

Dept. Of CSE, RIT, Hassan 2020-2021 Page 35


SELECTIVE REPEAT ARQ PROTOCOL

timer1();

float k=0;

for(j=0;j<4;j=j+temp) //movement of data packet within the frame


{ glColor3f(0,1,1);
glBegin(GL_QUADS);
glVertex2i(320,265-j);glVertex2i(320,275-j);glVertex2i(325,275-j);glVertex2i(325,265-j);
glEnd();
glFlush();

glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex2i(70,265-j);glVertex2i(70,280-j);glVertex2i(75,280-j);glVertex2i(75,265-j);
glEnd();
glFlush();

glColor3f(0,0,0);
glBegin(GL_QUADS);
glVertex2i(70,265-j);glVertex2i(70,280-j);glVertex2i(75,280-j);glVertex2i(75,265-j);
glEnd();
glFlush();

glColor3f(0,0,0); // to remove traces create movement of frame in black


glBegin(GL_QUADS);
glVertex2i(320,265-j);glVertex2i(320,275-j);glVertex2i(325,275-j);glVertex2i(325,265-j);
glEnd();
glFlush();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 36


SELECTIVE REPEAT ARQ PROTOCOL

for(j=0;j<60;j=j+temp) //movement of data packet from top to down


{ glColor3f(0,1,1);
glBegin(GL_QUADS);
glVertex2i(320,228-j);glVertex2i(320,238-j);glVertex2i(325,238-j);glVertex2i(325,228-j);
glEnd();
glFlush();

glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex2i(70,238-j);glVertex2i(70,253-j);glVertex2i(75,253-j);glVertex2i(75,238-j);
glEnd();
glFlush();

k+=0.05;
timer(k,156.5,122,128);
timer(k,102.5,102,108);

glColor3f(0,0,0);
glBegin(GL_QUADS);
glVertex2i(320,228-j);glVertex2i(320,238-j);glVertex2i(325,238-j);glVertex2i(325,228-j);
glEnd();
glFlush();

glColor3f(0,0,0);
glBegin(GL_QUADS);
glVertex2i(70,238-j);glVertex2i(70,253-j);glVertex2i(75,253-j);glVertex2i(75,238-j);
glEnd();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 37


SELECTIVE REPEAT ARQ PROTOCOL

for(i=0;i<235;i=i+temp) //movement of data packet sidewise


{ glColor3f(0,1,1);
glBegin(GL_QUADS);
glVertex2i(310-i,168);glVertex2i(310-i,173);glVertex2i(320-i,173);glVertex2i(320-i,168);
glEnd();
glFlush();

glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex2i(70+i,178);glVertex2i(70+i,183);glVertex2i(85+i,183);glVertex2i(85+i,178);
glEnd();
glFlush();

k+=0.05;
timer(k,156.5,122,128);
timer(k,102.5,102,108);

glColor3f(0,0,0);
glBegin(GL_QUADS);
glVertex2i(310-i,168);glVertex2i(310-i,173);glVertex2i(320-i,173);glVertex2i(320-i,168);
glEnd();
glFlush();

glColor3f(0,0,0);
glBegin(GL_QUADS);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 38


SELECTIVE REPEAT ARQ PROTOCOL

glVertex2i(70+i,178);glVertex2i(70+i,183);glVertex2i(85+i,183);glVertex2i(85+i,178);
glEnd();
glFlush();

for(j=0;j<63;j=j+temp) //to move the packet from bottom to top


{
glColor3f(0,1,1);
glBegin(GL_QUADS);
glVertex2i(70,168+j);glVertex2i(70,178+j);glVertex2i(75,178+j);glVertex2i(75,168+j);
glEnd();
glFlush();

glColor3f(1,0,0);
glBegin(GL_QUADS);

glVertex2i(320,178+j);glVertex2i(320,193+j);glVertex2i(325,193+j);glVertex2i(325,178+j);
glEnd();
glFlush();

k+=0.05;
timer(k,156.5,122,128);
timer(k,102.5,102,108);

glColor3f(0,0,0);
glBegin(GL_QUADS);
glVertex2i(70,168+j);glVertex2i(70,178+j);glVertex2i(75,178+j);glVertex2i(75,168+j);
glEnd();
glFlush();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 39


SELECTIVE REPEAT ARQ PROTOCOL

glColor3f(0,0,0);
glBegin(GL_QUADS);

glVertex2i(320,178+j);glVertex2i(320,193+j);glVertex2i(325,193+j);glVertex2i(325,178+j);
glEnd();
glFlush();

setFont(GLUT_BITMAP_HELVETICA_12);

glColor3f(0.0f,0.0f,0.0f);
drawstring(160.0,370.0,1.0,(char*)"FRAME 1 sending ...........");

glColor3f(0.0f,0.0f,0.0f);
drawstring(230.0,345.0,1.0,(char*)"........... sending ACK1 ");

glColor3f(1.0,1.0,0.0);
drawstring(160.0,370.0,1.0,(char*)"FRAME 1 sent ");

glColor3f(1.0f,1.0f,0.0f);
drawstring(230.0,345.0,1.0,(char*)"ACK1 Recieved ");

glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(10,115);
glVertex2f(10,135);
glVertex2f(230,135);
glVertex2f(230,115);
glEnd();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 40


SELECTIVE REPEAT ARQ PROTOCOL

glFlush();

setFont(GLUT_BITMAP_HELVETICA_18);
glColor3f(1.0,0.8,0.4);
drawstring(80.0,125.0,1.0,(char*)" Frame 0 sent successfully");

// delay();

setFont(GLUT_BITMAP_HELVETICA_12);

glColor3f(0.0,0.0,0.0);
drawstring(160.0,370.0,1.0,(char*)"FRAME 1 sent ");

glColor3f(0.0f,0.0f,0.0f);
drawstring(230.0,345.0,1.0,(char*)"ACK1 Recieved ");

void move3() // MOVEMENT OF FRAME 2 ( FRAME 2 lost in packet crashing)


{

float i,j,temp=0.3;
float k=0;
timer2();

glColor3f(1.0,0.8,0.4);
setFont(GLUT_BITMAP_HELVETICA_18);
drawstring(30.0,85.0,1.0,(char*)"Timer 2");

setFont(GLUT_BITMAP_HELVETICA_12);

Dept. Of CSE, RIT, Hassan 2020-2021 Page 41


SELECTIVE REPEAT ARQ PROTOCOL

glColor3f(1.0f,1.0f,0.0f);
drawstring(160.0,370.0,1.0,(char*)"FRAME 2 sending ...........");

for(j=0;j<4;j=j+temp) //movement of data packet within the frame


{
glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex2i(85,265-j);glVertex2i(85,280-j);glVertex2i(90,280-j);glVertex2i(90,265-j);
glEnd();
glFlush();

k+=0.05;
timer(k,102.5,82,88);

glColor3f(0,0,0);
glBegin(GL_QUADS);
glVertex2i(85,265-j);glVertex2i(85,280-j);glVertex2i(90,280-j);glVertex2i(90,265-j);
glEnd();
glFlush();

for(j=0;j<60;j=j+temp) //movement of data packet from top to down


{ glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex2i(85,238-j);glVertex2i(85,253-j);glVertex2i(90,253-j);glVertex2i(90,238-j);
glEnd();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 42


SELECTIVE REPEAT ARQ PROTOCOL

glFlush();

k+=0.05;
timer(k,102.5,82,88);

glColor3f(0,0,0);
glBegin(GL_QUADS);
glVertex2i(85,238-j);glVertex2i(85,253-j);glVertex2i(90,253-j);glVertex2i(90,238-j);
glEnd();
glFlush();
}

for(i=0;i<167;i=i+temp) //movement of data packet sidewise


{ glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex2i(85+i,178);glVertex2i(85+i,183);glVertex2i(100+i,183);glVertex2i(100+i,178);
glEnd();
glFlush();

k+=0.05;
timer(k,102.5,82,88);

glColor3f(0,0,0);
glBegin(GL_QUADS);
glVertex2i(85+i,178);glVertex2i(85+i,183);glVertex2i(100+i,183);glVertex2i(100+i,178);
glEnd();
glFlush();

Dept. Of CSE, RIT, Hassan 2020-2021 Page 43


SELECTIVE REPEAT ARQ PROTOCOL

Chapter 6
SCREENSHOTS

Fig 6.1: Frame 0,1 sent

Fig 6.2: ACK to sender

Dept. Of CSE, RIT, Hassan 2020-2021 Page 44


SELECTIVE REPEAT ARQ PROTOCOL

Fig 6.2: Heap sort algorithm

Fig 6.3: NAK2 sender

Dept. Of CSE, RIT, Hassan 2020-2021 Page 45


SELECTIVE REPEAT ARQ PROTOCOL

CONCLUSION
Selective repeat is combination of advantages of GO back-N and stop N wait protocol,
Selective repeat is somewhat superior to other protocols. The use of packet fragmentation and
selective repeat ARQ was considered for random access underwater networks are Throughput
efficiency, reducing end to end latency and Energy per bit consumption. Finally, the transmission of
frames between sender and receiver takes place simultaneously without the intervention at some
stages and later the retransmission of frames occurs at later stages. Using graphical representation for
stimulation of Selective Repeat protocol is done which depicts the transmission of frames from one
point to another point with the required ACK and NAK.

Dept. Of CSE, RIT, Hassan 2020-2021 Page 46


SELECTIVE REPEAT ARQ PROTOCOL

REFERENCES

1. Yukuo Hayashida, Chikako Baba, amdl Masaharu Komatsu, “Stop and-


Selective Repeat ARQ Scheme for A High-speed Transport Protocol”, IEEE
Catalogue No.95TH8061.

2. Imrich Chlamtac, Chiara Petriolib, Jason Redic,”Energy-conserving Selective


Repeat ARQ Protocols for Wireless Data Networks”, Ninth IEEE International
Symposium on Personal, Indoor and Mobile Radio Communications (Cat.
No.98TH8361)

3. Chen Jin and Wang Jinlong, “A Novel Selective Repeat Stop-Wait ARQ for
Half-Duplex Channels”, 2002 IEEE Region 10 Conference on Computers,
Communications, Control and Power Engineering.TENCOM '02. Proceedings.

4. http://www.opengl.org/
5. http://www.codecolony.de/opengl
6. http://www.wikipedia.org/opengl
7. https://www.upgrad.com/blog/heap-sort-in-data-structures/
8. https://www.softwaretestinghelp.com/heap-sort/
9. https://www.coursera.org/
10. https://www.graphicsworld.org/

Dept. Of CSE, RIT, Hassan 2020-2021 Page 47

You might also like