LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking
User Name
Password
Linux - Wireless Networking This forum is for the discussion of wireless networking in Linux.

Notices



Reply
 
Search this Thread
Old 03-08-2012, 01:50 PM   #1
shefali_jain
LQ Newbie
 
Registered: Feb 2012
Posts: 1

Rep: Reputation: Disabled
UDP broadcast packets are not received in V2V communication (NCTUns)


Hello,

i am working on Estinet (commercialized version of NCTUns ). ant their i am try to simulate VANET. here i am sending broadcast UDP packets but they are not received by any of the node.

i am using exactly same code as developer. but not able to receive any message.
please help me i have got only a few days left to submit my result.



this is function for sending message -
//agentClientReportStatus is the built in packet format.

void reportMyStatusToAGroupOfNode()
{
static int seqNum=0;
double lastTime = (double) now.tv_sec * 1000000 + (double) now.tv_usec;
int value;
socklen_t len;

agentClientReportStatus *msg;
msg = new agentClientReportStatus;

msg->x = CurrentPOS_x;
msg->y = CurrentPOS_y;
msg->type = AGENT_CLIENT_REPORT_STATUS;
msg->nid = mynid;
msg->moreMsgFollowing = 1;
msg->acceleration = CurrentAcceleration;
msg->speed = CurrentVelocity;
msg->direction = CurrentDirection;
msg->seqNum = seqNum;
msg->timeStamp=lastTime;
msg->TTL=3;
seqNum++;
sockaddr_in cli_addr;

//Broadcast start

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");
int n = sendto(myUDPsockfd, msg, sizeof(struct agentClientReportStatus), 0, (struct sockaddr *) &cli_addr, len);
if (n < 0) {
printf("Agent (%d) sendto failed\n", mynid);
}
else{
printf("Car Agent (%d) broadcast pkt, Size %d, seqNum %d, packet type==%d\n", mynid, sizeof(struct agentClientReportStatus), msg->seqNum, msg->type);
}
//Broadcast end
free(msg);
}

and in receiving section -

void receiveMsg()
{
socklen_t len;
int n = 1;
sockaddr_in cli_addr;
while(n > 0){
typeChecker p;
len = sizeof(cli_addr);
n = recvfrom(myUDPsockfd, (char *) &p, sizeof(struct typeChecker), MSG_PEEK, (struct sockaddr *) &cli_addr, &len);
if(n == 0){
//printf("Car Agent: %d UDP socket error\n", mynid);
return;
}
 
Old 10-26-2012, 12:33 PM   #2
giob12
LQ Newbie
 
Registered: Oct 2012
Posts: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by shefali_jain View Post
Hello,

i am working on Estinet (commercialized version of NCTUns ). ant their i am try to simulate VANET. here i am sending broadcast UDP packets but they are not received by any of the node.

i am using exactly same code as developer. but not able to receive any message.
please help me i have got only a few days left to submit my result.



this is function for sending message -
//agentClientReportStatus is the built in packet format.

void reportMyStatusToAGroupOfNode()
{
static int seqNum=0;
double lastTime = (double) now.tv_sec * 1000000 + (double) now.tv_usec;
int value;
socklen_t len;

agentClientReportStatus *msg;
msg = new agentClientReportStatus;

msg->x = CurrentPOS_x;
msg->y = CurrentPOS_y;
msg->type = AGENT_CLIENT_REPORT_STATUS;
msg->nid = mynid;
msg->moreMsgFollowing = 1;
msg->acceleration = CurrentAcceleration;
msg->speed = CurrentVelocity;
msg->direction = CurrentDirection;
msg->seqNum = seqNum;
msg->timeStamp=lastTime;
msg->TTL=3;
seqNum++;
sockaddr_in cli_addr;

//Broadcast start

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");
int n = sendto(myUDPsockfd, msg, sizeof(struct agentClientReportStatus), 0, (struct sockaddr *) &cli_addr, len);
if (n < 0) {
printf("Agent (%d) sendto failed\n", mynid);
}
else{
printf("Car Agent (%d) broadcast pkt, Size %d, seqNum %d, packet type==%d\n", mynid, sizeof(struct agentClientReportStatus), msg->seqNum, msg->type);
}
//Broadcast end
free(msg);
}

and in receiving section -

void receiveMsg()
{
socklen_t len;
int n = 1;
sockaddr_in cli_addr;
while(n > 0){
typeChecker p;
len = sizeof(cli_addr);
n = recvfrom(myUDPsockfd, (char *) &p, sizeof(struct typeChecker), MSG_PEEK, (struct sockaddr *) &cli_addr, &len);
if(n == 0){
//printf("Car Agent: %d UDP socket error\n", mynid);
return;
}
Has anyone solved this problem??
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
view received packets to specific UDP/TCP socket m4rtin Linux - Networking 2 10-10-2011 01:29 PM
broadcast using udp kingraja84 Programming 1 05-23-2007 06:59 AM
UDP: Short Packets: and UDP bad checksum: entries in dmesg minutes2memories Linux - Networking 2 02-26-2006 08:28 PM
encapsulating TCP packets in UDP packets... yoshi95 Programming 3 06-03-2004 03:53 PM
How to receive UDP and ICMP packets, by one UDP socket(PMTUD) myself_rajat Linux - Networking 0 05-28-2004 06:43 AM


All times are GMT -5. The time now is 05:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration