Sending from multiple clients to one server

835 views
Skip to first unread message

ns-3thesis

unread,
May 23, 2010, 9:14:42 PM5/23/10
to ns-3-users
I'm finding plenty of examples of sending multiple packets from one
client to one server. It seems pretty straight forward, using
Simulator::ScheduleWithContext with a function for sending the packets
(GenerateTraffic) from the client and setting up a callback for
receiving the packets on the server. I call Simulator::Run() and magic
happens.

I don't see a clean way to cycle through a set of clients and send a
packet from each. I need to simulate some number of adhoc nodes acting
as clients and one node acting as a server. I have the server (node 0)
set up with a recvSink, but am stuck on how to cycle through the
client nodes sending one packet at a time. From the examples it seemd
I can cycle through the nodes and use Simulator::ScheduleWithContext
on each node, and then use Simulator::Run to execute all the scheduled
packets, but I need to have a custom string in the data portion of
each packet sent by each client.

Thoughts?

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.

Quincy

unread,
May 23, 2010, 9:59:10 PM5/23/10
to ns-3-users
On May 24, 11:14 am, ns-3thesis <skdot...@gmail.com> wrote:
> but am stuck on how to cycle through the client nodes sending one
> packet at a time.

If packets are generated in your simulation by packet generating
application installed at each node, and the application generates
packets regularly, you can set each copy of the application to start
at different times:

client1 (start at t=0s) - send at 0s, 1s, 2s, ...
client2 (start at t=0.5s) - send at 0.5s, 1.5s, ...

Quincy

ns-3thesis

unread,
May 24, 2010, 3:34:24 PM5/24/10
to ns-3-users
I am probably not using NS-3 in the most traditional manner. I just
need to send one custom filled packet (i.e., I need to insert a custom
data string) from each client to the one server. So if I was doing it
w/out NS-3 I would just cycle through the nodes in a for loop, setting
up the connection->sending customer packet->closing connection from
each node. The way things are scheduled and then "run" is throwing me
off. I really need some way to 'send this packet now', or maybe
schedule a bunch of packets somehow and then hit run.

Bo Zhang

unread,
May 24, 2010, 8:49:11 PM5/24/10
to ns-3-users
Hi,


not sure which layer you are using to send. You could try setting-up a
sink at the server, and having sources on every client sending to the
same socket.

To customize packet, you could write some class, with specific fields,
and Serialize() and Deserialize() and GetSerializedSize() in it. I
suggest you have a look at src/routing/olsr since this is a routing
algorithm relying on point-point communications. My code after looked
through olsr, looked like this:
=====================================================================================
PacketHeader p_header;
p_header.SetPacketVersion();
p_header.SetPacketLength();
MessageHeader m_header;
m_header.SetMessageType();
m_header.SetTimeToLive(1);
m_header.SetMessageSequenceNumber();
m_header.SetOriginatorAddress(my_id);
MessageHeader::Beacon &beacon = m_header.GetBeacon();
beacon.SetBufferMap();
// construct beacon message
Ptr<Packet> beacon_msg = Create<Packet>();
beacon_msg->AddHeader(m_header);
// construct a packet containing p_header and beacon_msg
Ptr<Packet> beacon_pkt = Create<Packet>();
beacon_pkt->AddHeader(p_header);
beacon_pkt->AddAtEnd(beacon_msg);
socket->Send(beacon_pkt);
==============================================================


Hope this helps.

Zhang Bo
Reply all
Reply to author
Forward
Message has been deleted
0 new messages