Urgent: Problem with receiving UDP packets

117 views
Skip to first unread message

Boubaker Idir

unread,
Jan 1, 2018, 9:29:09 AM1/1/18
to ns-3-users

Hello,

The final aim of my application is a communication between a client and a server using point-to-point. So I created two nodes: Node 1 sends an UDP packet to node 2 each 32ms, and Node 2 replies 16ms after the receive.
I have a problem with the reception part of my application:


The architecture of my application is:

*bitest.cc hosts the main function of my application
*app1.cc is the class sender
*app2.cc is the class receiver

You can find in the attached files my code.
The actual situation is that the sender sends a packet to node 2, but the node doesn't receive the message. Line 58 of app2.cc m_socket->SetRecvCallback (MakeCallback (&app2::RxMsg, this));
SetRecvCallback isn't called.
Normally I created two sockets in each class, a socket for the sender that is attached to node 1 and a socket for the receiver that is attached to node 2, based on discussions here it supposed to work so I guess there is a problem with the network definition( helperRouting...).

In line 94 of app1.cc I deactivated the schedule function to see better the log in the console.

Any comment/suggestion is welcome, so please don't hesitate to contact me.

Thank you so much
Best regards
Bob


app1.cc
app1.h
app2.cc
app2.h
bitest.cc
bitest.h

Boubaker Idir

unread,
Jan 2, 2018, 5:48:14 PM1/2/18
to ns-3-users
Hello,
 
 My code works well for CSMA but I still have a problem with PointToPoint. It works in local for each node but not between the two nodes.
 PointToPoint doesn't work because the two nodes cannot communicate when their addresses are assigned using a PointToPointHelper.
The error is in app1.cc, m_socket->send(p) 
A configuration is missing to attach the both nodes. 
For the two nodes:

For node 1:


For the node 2:


I need your help, don't hesitate to correct me.

bitest (1).h
bitest (1).cc
app2 (1).h
app2 (1).cc
app1 (1).h
app1 (1).cc

Tommaso Pecorella

unread,
Jan 3, 2018, 6:48:05 PM1/3/18
to ns-3-users
Hi,

I hate to repeat myself. Do not start sending packets before the simulation start.
Your mistake is in these lines:
  // lancement de l'application app1 pour attente des messages puis réponse après 16ms --- voir définition de app2
  receiver
.StartApplication();
 
 
// lancement de l'application app1 pour envoi des messages --- voir définition de app1
  sender
.StartApplication();

You're not using the application model in the right way, simple as that. Study the examples and learn how to properly write and use an Application.
The fact that Wi-Fi works and PointToPoint doesn't is because PointToPoint is more sensible to these kind of programming errors. PointToPoint fully builds its stack only after the Simulator::Run () call.

T.


On Tuesday, January 2, 2018 at 11:48:14 PM UTC+1, Boubaker Idir wrote:
Hello,
 
 My code works well for CSMA but I still have a problem with PointToPoint. It works in local for each node but not between the two nodes.
 PointToPoint doesn't work because the two nodes cannot communicate when their addresses are assigned using a PointToPointHelper.
The error is in app1.cc, m_socket->send(p) 
A configuration is missing to attach the both nodes. 
For the two nodes:


For node 1:



For the node 2:

Reply all
Reply to author
Forward
0 new messages