go back n arq

it is an automatic repeat request network protocol

Page 1 of 1

2 Replies - 23332 Views - Last Post: 28 May 2009 - 12:29 AM Rate Topic: -----

#1 keshav1124  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-May 09

go back n arq

Posted 13 May 2009 - 04:03 PM

 #include<stdio.h>
#include<GL/glut.h>
void send();
void ack();
int i,n,m;
void drawrect()
{
	int x1=100,x2=200,x3=300,x4=400,y1=200,y2=300,y3=400,y4=500;
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glColor3f(1.0,0.0,0.0);
	for(i=0;i<(3*100);i+=100)
	{
		 glBegin(GL_POLYGON);
		 glVertex2d(x1,y1+i);
		 glVertex2d(x2,y2+i);
		 glVertex2d(x2,y3+i);
		 glVertex2d(x1,y4+i);
	  glEnd();
	}
	for(i=0;i<(3*100);i+=100)
	{
		 glBegin(GL_POLYGON);
		 glVertex2d(x3,y1+i);
		 glVertex2d(x4,y2+i);
		 glVertex2d(x4,y3+i);
		 glVertex2d(x3,y4+i);
	  glEnd();
	}
 glFlush();
 glutSwapBuffers();
}
static void (*draw)(void) = send;
void init()
{
	glClearColor(1.0,1.0,1.0,1.0);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0.0,599.0,0.0,599.0);
}
void display()
{
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glColor3f(1.0,0.0,0.0);
	glBegin(GL_LINES);
	  glVertex2d(150,100);
	  glVertex2d(150,400);
	glEnd();
	glBegin(GL_LINES);
	  glVertex2d(400,100);
	  glVertex2d(400,400);
	glEnd();
 	glRasterPos(75,450);
	glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'S');
	send();
	ack();
	if(m=n)
		printf("data delivered succesfully\n");
	glFlush();
 glutSwapBuffers();
}
void send()
{
	int x1=150,y1=375,x2=400,y2=325;
	glColor3f(0.0,0.0,0.0);
	for(i=0;i<(n*20);i+=20)
	{
		glBegin(GL_LINES);
		 glVertex2i(x1,y1-i);
		 glVertex2i(x2,y2-i);
		glEnd();
	
	
	}
printf("DATA SENT\n");
}
void ack()
{
	int x3=150,y3=275,x4=400,y4=325;
	glColor3f(0.0,1.0,0.0);
	for(i=0;i<(m * 20);i+=20)
	{
		glBegin(GL_LINES);
		 glVertex2i(x3,y3-i);
		 glVertex2i(x4,y4-i);
		glEnd();
	

	}
printf("ACKNOWLEDGEMENT RECIEVED\n");
}
void main(int argc,char **argv)
{
	printf("enter the no of data to be sent\n");
	scanf_s("%d",&n);
	printf("enter the no of acknowledgements to be recieved\n");
	scanf_s("%d",&m);
	 glutInit(&argc,argv);
	 glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
	 glutCreateWindow("GO BACK N ARQ");
	 glutInitWindowSize(600,600);
	 glutDisplayFunc(display);
	 
	 glutCreateWindow("ARQ DIAGRAM");
	 glutInitWindowSize(500,500);
	 glutDisplayFunc(drawrect);

	 init();
	 glutMainLoop();
}



here i m simulating the protocol in openGL
i m only able to take values frm keyboard and not able to interface mouse or menus...
also give ideas how can i go about this project

Is This A Good Question/Topic? 0
  • +

Replies To: go back n arq

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5413
  • View blog
  • Posts: 27,430
  • Joined: 10-May 07

Re: go back n arq

Posted 20 May 2009 - 03:01 AM

** Moved to C/C++ **
Was This Post Helpful? 0
  • +
  • -

#3 forhi4u  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 24-May 09

Re: go back n arq

Posted 28 May 2009 - 12:29 AM

I see you did good in this code,
and I'm looking for cose in c++ to simulate stop_and_wait ARQ potocol
but I still not find it.

I posted my code here in this web site , but still I didnt get any update for it, because my code not the solution that is required.

if you have the code in c++ please post it here , with all my thanks in advanced.

Ahmad
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1