I want to write a program which simulate the behaviour of CSMA/CD protocol over Ethernet.

Recommended Answers

All 8 Replies

I want CSMA/CD program in c or c++ language.please sent this pragram on my email SNIP

commented: wtf... -1
commented: boo -2

I want CSMA/CD program in c or c++ language.please sent this pragram on my email SNIP

I am confused. First you say you want to write the program. Then you say you want somebody to send the code for such a program to you.

I am confused. First you say you want to write the program. Then you say you want somebody to send the code for such a program to you.

those were two different people.

but as to that second guy, welcome to Daniweb. it's pretty much the reason why the long-term users here are often cynical and jaded towards noobs.

i want write implemment CSMA/CD protocol Can U help Me???
WHAT is equation

#include<stdio.h>
#include<stdlib.h>
#include<signal.h>
#include<sys/time.h>
int x=0;
void capture()
{
	exit(0);
	}
int get()
{
	return x;
	}
void put()
{
	x++;
	}
void node(char *p)
{
	int name;
	int seq1,seq2,i=0;
	long t;
	struct timeval tv;
	struct timezone tz;
	name=atoi(p);
while(1)
{
	seq1=get();
	seq2=get();
	if(seq1==seq2)
	{
		put();
		seq1=get();
		gettimeofday(&tv,&tz);
		printf("station %d transmitting frame %d at %ld \n",name,++i,tv,tz);
		usleep(10);
		seq2=get();
		if(seq1!=seq2)
		{
		printf("station %d collision occured %d \n",name,i--);
		usleep(100);
			}
		else
		{
		printf("station %d transmission of frame %d success \n",name,i);
			}
		}
	usleep(200);
	}
}
main()
{
	pthread_t t1,t2,t3;
	signal(SIGINT,capture);
	pthread_create(&t1,0,(void *)node,"1");
	pthread_create(&t2,0,(void *)node,"2");
	pthread_create(&t3,0,(void *)node,"3");
	while(1);
	}

the above code tested in linux ith gcc only... :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.