Results 1 to 6 of 6
|
Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
-
02-27-2010 #1
- Join Date
- Feb 2010
- Posts
- 4
Data transfer in V2V communication (Fedora11)
can anybody help me direct to the right forum for wireless vehicular communication. i am using NCTUns simulator and having problem while receiving message from an OBU. sending a message works properly but recving creates problem and fails. i am using exactly the same function as used by the developers in the demos but still no luck. i copy the code attch the screen shots to have a look please help me i have got only a few days left to submit my result and looking forward for your kind help.
sendto() and recvfrom() are used for message transfer. they both return >-1 if they are executed successfully. please have a look in the screenshots. agentClientReportStatus is the built in packet format which im using here whose fields i filled manually are in the code below.
agentClientReportStatus *message,*mssg;
int remainTime,n,n2,n3,i,sendingaddress,value;
sockaddr_in cli_addr;
timeval now;
sendingaddress=255;
sprintf(portNumStr, "%d", agentUDPportNum);
myUDPsockfd = passiveUDP(portNumStr);
printf("Agent(%d) created myUDPsockfd %d\n", mynid, myUDPsockfd);
if (myUDPsockfd < 0) {
printf("Agent(%d): Creating myUDPsockfd failed\n", mynid);
exit(0);
}
n = fcntl(myUDPsockfd, F_SETFL, O_NONBLOCK);
message = new agentClientReportStatus;
mssg = new agentClientReportStatus;
double lastTime = (double) now.tv_sec * 1000000 + (double) now.tv_usec;
while(1)
{
len = sizeof(cli_addr);
n2 = recvfrom(myUDPsockfd,(char *) &mssg, sizeof(struct agentClientReportStatus), 0, (struct sockaddr *) &cli_addr,&len);
if (n2 < 0) {
printf("Agent(%d) recvFrom() failed and n= %d\n", mynid, n2);
}else
{
printf("Message received from : %d and of Sequence Number: %d",mssg->nid,mssg->seqNum);
}
}
n = getCurrentPositionOfAGroupOfNode(myTCPsockfd, mynid, 1, &NPArray,
numNodeInThisGroup, 1);
if(n>-1)
{
for (i=0; i<numNodeInThisGroup; i++)
{
if (NPArray->nid == mynid)
{
// A mobile node should not send a message to itself.
NPArray++;
continue;
}
ax=NPArray->x;
ay=NPArray->y;
sprintf(hostname, "1.0.1.%d", sendingaddress);
//hostname="1.0.1.255";
value = 1;
setsockopt(myUDPsockfd , SOL_SOCKET , SO_BROADCAST , &value , sizeof(value));
len = sizeof(cli_addr);
memset( &cli_addr, 0, sizeof(cli_addr) );
cli_addr.sin_family = AF_INET;
cli_addr.sin_port = htons(agentUDPportNum);
cli_addr.sin_addr.s_addr = inet_addr( "1.0.1.255" );
message->x = 111.0000;
message->y = 333.0000;
message->type = AGENT_CLIENT_REPORT_STATUS;
message->nid = NPArray->nid;
message->moreMsgFollowing = 1;
message->acceleration = 5;
message->speed = 19;
message->direction = 90;
message->seqNum = 5;
message->timeStamp=lastTime;
message->TTL=3;
n3 = sendto(myUDPsockfd, message, sizeof(struct agentClientReportStatus), 0, (struct sockaddr *) &cli_addr, len);
if (n3 < 0) {
printf("Agent(%d) Sendto() failed\n", mynid);
//exit(0);
}
else
{
printf("Message sent from : %d and of sequence number: %d and n3= %d\n",message->nid,message->seqNum, n3);
}
NPArray++;
}
//free(message);
}Last edited by bilalkhanalizai; 02-27-2010 at 12:41 PM. Reason: missing important information
-
03-10-2010 #2
- Join Date
- Feb 2010
- Posts
- 4
linux recvfrom() fails
dear forum members,
can anybody suggest me what are the possible reasons of getting recvfrom() function failed in linux. i am simulating a VANET scenario in NCTUns-6.0 simulator using 802.11p based cars. sendto() function works but recvfrom() fails.
do you think it is because 802.11p is not using any ARP module in its stack or something??? please help me my submission is on this monday. i'll be thankful to you.
-
03-10-2010 #3
Before we proceed any further, can I ask that you read the forum rules. The people who help on LinuxForums are volunteers who give their time to help others. It helps enormously if you can respect the time of our volunteers by not repeating the same question all over the place.
I'm no expert on socket programming, but I'll chip in what I can. What happens here if you reconfigure the code to use recv(...) instead of recvfrom(...)? If you have a connection, then the 'from' address could be causing problems. What does errno contain after the error occurs?Linux user #126863 - see http://linuxcounter.net/
-
03-11-2010 #4
- Join Date
- Feb 2010
- Posts
- 4
Hi Roxoff,
apologies for posting multiple copies of a single post on different forums, i just read the forum rules and realised the mistake. i wont repeat this mistake again, i only did it because i thought this forum might not be relevant and i should try other forums and some one might reply but my mistake.
thank you for youe reply, i have checked it with recv() instead of recvfrom as you suggested but that way it gives me message timeout and message doesnt reach, errno in that case is always 0
while doing it with recvfrom() it fails and errno returns me value 11 (that means resource not available???). to be honest i dont have good idea why is this because the code i have written is not in very good condition still needs to be simplified.
any help about this errno=11 please??? thanks again.
-
03-01-2012 #5
- Join Date
- Feb 2012
- Posts
- 1
hi, bilalkhanalizai
i am also getting the same problem. are you able to solved it??
if yes, then please tell me. as i needed it in my simulation.
-
03-01-2012 #6
- Join Date
- May 2004
- Location
- arch linux
- Posts
- 18,732
Hello and welcome to the forums, shefali123!
This thread is over 2 years old so I'm going to lock it down, but please feel free to start a fresh thread of your own with the details of any Linux issues that you need help with.
Thanks.oz