segmentation fault due to byte tag

72 views
Skip to first unread message

Suraj Kota

unread,
Jun 3, 2014, 3:35:29 AM6/3/14
to ns-3-...@googlegroups.com
HI,
Am using onoffapplication with tcpsocket factory. and inserting a byte tag in packet in onoffapplication's send function.
void OnOffApplication::SendPacket (){
...
Ptr<Packet> packet = Create<Packet> (m_pktSize+2);
m_pktSize+=2;
MyFlowTag1 tag;
tag.SetSimpleValue ((uint16_t)22);
packet->AddByteTag (tag);
...
}
When am inserting following code in ipv4-nix-vetor-routing route output function :
Ptr<Ipv4Route> 
Ipv4NixVectorRouting::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr){
...

MyFlowTag1 tagCopy;

bool found = p->FindFirstMatchingByteTag (tagCopy);
if (found)
  std::cout << (int)tagCopy.GetSimpleValue () << "hho"<<std::endl;
else
 std::cout << "tag not found" << std::endl;

...}  

For udpsocketfactoy the code runs for some time and then it aborts and for tcpsocket factory in gives segmentation fault error in the beginng itself.

I have attached gdb's backtrace output.
Can you get an idea what is the problem ?

gdb tcp on off.png
gdb udponoff.png
gdb backtrace full for udp.png
tag.cc
tag.h

Tommaso Pecorella

unread,
Jun 3, 2014, 3:54:29 AM6/3/14
to ns-3-...@googlegroups.com
In RouteOutput you should check if the packet is there.

I.e.:

MyFlowTag1 tagCopy;
if (p)
{

 
bool found = p->FindFirstMatchingByteTag (tagCopy);
 
if (found)
    std
::cout << (int)tagCopy.GetSimpleValue () << "hho"<<std::endl;
 
else
   std
::cout << "tag not found" << std::endl;
}


As a side note, your packets are growing in size. They'll reach the point to be cut, discarded or worse.
m_pktSize+=2;

Are you sure that this is your intended behaviour ?

T.

Suraj K

unread,
Jun 3, 2014, 7:25:35 AM6/3/14
to ns-3-...@googlegroups.com
Hie Sir,

+=2 I was doing to see what is the outcome :P

(1) I have put many debug lines in the onoffhelper,cc and onoffapllication.cc but am not able to get the program flow, Can you give an idea about how it reaches send () in onoffapplication.cc and when is Onoffapplication's object created ?
InstallPriv installs a application then how is send() function called after that

like for example ,

OnOffHelper oo = OnOffHelper("ns3::TcpSocketFactory",Address(InetSocketAddress(Ipv4Address(add), port))); // ip address of server
               oo.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]"));
                oo.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));

                oo.SetAttribute("PacketSize",UintegerValue (packetSize));
                oo.SetAttribute("DataRate",StringValue (dataRate_OnOff));      
                oo.SetAttribute("MaxBytes",StringValue (maxBytes));

rand1=1;
rand2=0;
rand3=0;

                while (rand1== podRand && swRand == rand2 && (rand3+2) == hostRand){
                        rand1 = rand() % num_pod + 0;
                        rand2 = rand() % num_edge + 0;
                        rand3 = rand() % num_host + 0;
                } // to make sure that client and server are different

        // Install On/Off Application to the client
                NodeContainer onoff;
                onoff.Add(host[rand1][rand2].Get(rand3));
                app[i] = oo.Install (onoff);
How to insert a tag when tcp acknowledge comes back ? and make client work on my desired port no. ?

(2) I have made a traffic generator which will give a TCP traffic (plz see attachment), But I want to create client socket on my desired port no. Can this be done ?

and also, How to insert a tag when tcp acknowledge comes back ?

Am still trying to create a flow classifier only.

K SURAJ
Information Technology
NIT Raipur


--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/0xPWXzUEaVA/unsubscribe.
To unsubscribe from this group and all its topics, 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 http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Apptest.cc
Reply all
Reply to author
Forward
0 new messages