ethernet packet

152 views
Skip to first unread message

Marco Cruz

unread,
Jun 13, 2012, 7:16:30 AM6/13/12
to ns-3-...@googlegroups.com
Hello to all,

I'm trying to build a ethernet packet, can someone tell or give me an example of how can I do this?

Regards,
Marco

Marco Cruz

unread,
Jun 13, 2012, 11:04:38 AM6/13/12
to ns-3-...@googlegroups.com
Hi,

Or maybe add data to a packet and send the packet between nodes.
Can someone give some tip on how to do this.

Regards,
Marco

Shane Tuohy

unread,
Jun 14, 2012, 6:58:26 AM6/14/12
to ns-3-...@googlegroups.com
Hello Marco, 

To add data to a node you can add a tag to the packets and read them at the other end.


If you wanted to change the Ethernet header implementation, you would have to edit the source code of ns3, the Ethernet header implementation is contained at ns-3-dev/src/network/utils/ethernet-header.cc 

Regards,
Shane

Marco Cruz

unread,
Jun 18, 2012, 9:13:35 AM6/18/12
to ns-3-...@googlegroups.com
Hello to all,

I have created a function, based on given in ns-3 repository, where I create a packet and send the packet by a socket.

SendPacket (void)
{
stringstream msg;
msg << "my payload";
Ptr<ns3::Packet> packet = Create<Packet> ((uint8_t*) msg.str().c_str(), msg.str().length());
std::cout << packet;
m_socket->Send (packet);

if (++m_packetsSent < m_nPackets)
{
  ScheduleTx ();
}
}

If I want to put some bits in the payload of an ethernet packet, for example only 000 in the firts 3 bits of the payload, the rest of the content I do not care, can someone tell me if this is possible to do in ns-3, and if possible give me some guide.

Thanks,
Best Regards,
Marco

Marco Cruz

unread,
Jun 19, 2012, 5:25:11 AM6/19/12
to ns-3-...@googlegroups.com

I have created the stringstream msg to put a message in the packet. In a ethernet frame like the picture - https://learningnetwork.cisco.com/servlet/JiveServlet/showImage/2-235887-109833/Capture.JPG - we have the data field also called payload field where we can send the data that we want

SendPacket (void)
{
 stringstream msg;
 msg << "my payload"; 
 Ptr packet = Create ((uint8_t*) msg.str().c_str(), msg.str().length()); 

 m_socket->Send (packet);
 if (++m_packetsSent < m_nPackets)
 {
 ScheduleTx ();
 }
} .

So if I want to put some bits in the Data/payload field of an ethernet packet, for example only 000 in the firts 3 bits, the rest of the content I do not care, can someone tell me if this is possible to do in ns-3, and if possible give me some guide.

My doubt is How can I put 000 in the first bits of the data/payload field of the packet?

Can someone please advise me, all comment will be very appreciated

Best Regards,
Marco Cruz

On Wednesday, June 13, 2012 12:16:30 PM UTC+1, Marco Cruz wrote:
On Wednesday, June 13, 2012 12:16:30 PM UTC+1, Marco Cruz wrote:
On Wednesday, June 13, 2012 12:16:30 PM UTC+1, Marco Cruz wrote:
On Wednesday, June 13, 2012 12:16:30 PM UTC+1, Marco Cruz wrote:
Reply all
Reply to author
Forward
0 new messages