Discussion:
Sending Custom Packets using sockets
srinivas poram
2012-10-30 10:29:37 UTC
Permalink
Hi,
I want to send my custom packet like hello among the simulated nodes. for
this i have created a packet like below

Ptr<Packet>pkt=Create<Packet>(reinterpret_cast<uint8_t *>("hello"),5);
i can able to check the payload by
cout<<*pkt<<endl; and contents of the packet by
cout<<pkt->PeekData()<<endl;
I came to know that i can able to send these packets among simulated nodes
by using sockets.So i created socket by
Ptr<Socket>socket;
why is it giving error when i use
socket->Bind(InetSocketAddress(80));

and error is being displayed when i'm using udpFactory if i want to create
a socket as below

Ptr<Socket>socket=udpFactory->CreateSocket();

any help ..please
--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/tGQdVp5BjB4J.
To post to this group, send email to ns-3-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to ns-3-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.
srinivas poram
2012-11-07 07:46:18 UTC
Permalink
Hi,
I could able tomake a packet and socket also. And i couldable to send the
packet the packet particular destination node by using
socket->SendTo(pkt,0,InetSocketAddress("Destination Address",destination
port). But when i'm reading the pcap file generated by simulator it is
showing that packet is sent only once. How can i make my simulator to take
my packet(created by me) and send it regularly with some interval. also how
can i send it in multicast and broadcast mode.
Post by srinivas poram
Hi,
I want to send my custom packet like hello among the simulated nodes. for
this i have created a packet like below
Ptr<Packet>pkt=Create<Packet>(reinterpret_cast<uint8_t *>("hello"),5);
i can able to check the payload by
cout<<*pkt<<endl; and contents of the packet by
cout<<pkt->PeekData()<<endl;
I came to know that i can able to send these packets among simulated nodes
by using sockets.So i created socket by
Ptr<Socket>socket;
why is it giving error when i use
socket->Bind(InetSocketAddress(80));
and error is being displayed when i'm using udpFactory if i want to create
a socket as below
Ptr<Socket>socket=udpFactory->CreateSocket();
any help ..please
--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/QbxlV7VQqrYJ.
To post to this group, send email to ns-3-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to ns-3-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.
William Bellia
2012-11-07 07:51:27 UTC
Permalink
Hey,

In order to schedule re transmission of packets, you can use the following
code:
if (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double>
(m_dataRate.GetBitRate ())));
m_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
}

where the variant on how fast the transmission takes place is the bit rate.

This code was taken from the example section in ns3 source.

Will
Post by srinivas poram
Hi,
I could able tomake a packet and socket also. And i couldable to send the
packet the packet particular destination node by using
socket->SendTo(pkt,0,InetSocketAddress("Destination Address",destination
port). But when i'm reading the pcap file generated by simulator it is
showing that packet is sent only once. How can i make my simulator to take
my packet(created by me) and send it regularly with some interval. also how
can i send it in multicast and broadcast mode.
Post by srinivas poram
Hi,
I want to send my custom packet like hello among the simulated nodes. for
this i have created a packet like below
Ptr<Packet>pkt=Create<Packet>(**reinterpret_cast<uint8_t *>("hello"),5);
i can able to check the payload by
cout<<*pkt<<endl; and contents of the packet by
cout<<pkt->PeekData()<<endl;
I came to know that i can able to send these packets among simulated
nodes by using sockets.So i created socket by
Ptr<Socket>socket;
why is it giving error when i use
socket->Bind(**InetSocketAddress(80));
and error is being displayed when i'm using udpFactory if i want to
create a socket as below
Ptr<Socket>socket=udpFactory->**CreateSocket();
any help ..please
--
You received this message because you are subscribed to the Google Groups
"ns-3-users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/ns-3-users/-/QbxlV7VQqrYJ.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/ns-3-users?hl=en.
--
William Bellia
--
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-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to ns-3-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.
srinivas poram
2012-11-08 11:41:08 UTC
Permalink
How can i make simulator to consider my packet/custom packet instead of
generalized packets created by:

OnOffHelper
onoff("ns3::UdpSocketFactory",Address(InetSocketAddress(Ipv4Address("10. .
."),port)));


Thanks
Post by srinivas poram
Hi,
I want to send my custom packet like hello among the simulated nodes. for
this i have created a packet like below
Ptr<Packet>pkt=Create<Packet>(reinterpret_cast<uint8_t *>("hello"),5);
i can able to check the payload by
cout<<*pkt<<endl; and contents of the packet by
cout<<pkt->PeekData()<<endl;
I came to know that i can able to send these packets among simulated nodes
by using sockets.So i created socket by
Ptr<Socket>socket;
why is it giving error when i use
socket->Bind(InetSocketAddress(80));
and error is being displayed when i'm using udpFactory if i want to create
a socket as below
Ptr<Socket>socket=udpFactory->CreateSocket();
any help ..please
--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/JcXZDG710bsJ.
To post to this group, send email to ns-3-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to ns-3-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.
Munde Pravin
2018-02-03 13:12:06 UTC
Permalink
Greetings Sir,
I tried :




*Ptr<Packet>pkt=Create<Packet>(reinterpret_cast<uint8_t
*>("hello"),5);socket->SendTo(pkt,0,InetSocketAddress(Ipv4Address
("10.1.1.1"), 80));*and ended up with following error :



*error: reinterpret_cast from type ‘const char*’ to type ‘uint8_t* {aka
unsigned char*}’ casts away qualifiers*for the first line.
How to resolve this ?
HOW to send any kind of data such as int ,char,string,variable
value,array,list etc. ?
please help.Thank you
--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+***@googlegroups.com.
To post to this group, send email to ns-3-***@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
Munde Pravin
2018-02-03 13:12:57 UTC
Permalink
Greetings Sir,
I tried :




*Ptr<Packet>pkt=Create<Packet>(reinterpret_cast<uint8_t
*>("hello"),5);socket->SendTo(pkt,0,InetSocketAddress(Ipv4Address
("10.1.1.1"), 80));*and ended up with following error :



*error: reinterpret_cast from type ‘const char*’ to type ‘uint8_t* {aka
unsigned char*}’ casts away qualifiers*for the first line.
How to resolve this ?
HOW to send any kind of data such as int ,char,string,variable
value,array,list etc. ?
please help.Thank you
--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+***@googlegroups.com.
To post to this group, send email to ns-3-***@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
Tommaso Pecorella
2018-02-04 06:14:05 UTC
Permalink
Hi,

please read the posting guidelines.

T
Post by Munde Pravin
Greetings Sir,
*Ptr<Packet>pkt=Create<Packet>(reinterpret_cast<uint8_t
*>("hello"),5);socket->SendTo(pkt,0,InetSocketAddress(Ipv4Address
*error: reinterpret_cast from type ‘const char*’ to type ‘uint8_t* {aka
unsigned char*}’ casts away qualifiers*for the first line.
How to resolve this ?
HOW to send any kind of data such as int ,char,string,variable
value,array,list etc. ?
please help.Thank you
--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+***@googlegroups.com.
To post to this group, send email to ns-3-***@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...