Bugzilla – Bug 1477
Click doesn't work with raw sockets
Last modified: 2012-07-26 09:59:43 UTC
As mentioned by Jörg Kaiser on click@pdos.csail.mit.edu. ===================== I'm using ns3 with the ns3click integration. When I try to use ns3's ping-application, it will noch work with a ClickInternetStack but only with a regular one. Other applications like a udp-server/client setup work fine with both. -------------------------------- this DOES NOT work V4PingHelper ping (Ipv4Address ("172.16.1.2")); ping.SetAttribute ("Verbose", BooleanValue (true)); ApplicationContainer p = ping.Install (wifiNodes.Get (0)); ERROR: assert failed. cond="socketFactory != 0", file=../src/network/model/socket.cc, line=62 this DOES work uint16_t port = 4000; UdpServerHelper server (port); ApplicationContainer apps = server.Install (wifiNodes.Get(0)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); ------------------------------ I could narrow down the problem a little bit: in V4ping.cc: m_socket = Socket::CreateSocket (GetNode (), TypeId::LookupByName ("ns3::Ipv4RawSocketFactory")); this fails as the node seems to be unable to create a IPv4RawSocket. in udp-server.cc: TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); m_socket = Socket::CreateSocket (GetNode (), tid); exactly the same, but he can create an UdpSocket.
Created attachment 1427 [details] test script which shows the problem
Created attachment 1428 [details] Fix Here's a first patch that fixes the problem. It basically fixes the Icmpv4 and raw socket code to only use Ipv4 type pointers instead of directly getting an Ipv4L3Protocol object. And within Ipv4L3ClickProtocol, we forward Ipv4 packets further up to any raw sockets before handing them to Click. Someday, I would really like to decouple Click from the L3 code, and have it use FromHost/ToHost elements to interact with the stack over real tun/tap devices. :\
(In reply to comment #2) > Created attachment 1428 [details] > Fix > > Here's a first patch that fixes the problem. It basically fixes the Icmpv4 and > raw socket code to only use Ipv4 type pointers instead of directly getting an > Ipv4L3Protocol object. And within Ipv4L3ClickProtocol, we forward Ipv4 packets > further up to any raw sockets before handing them to Click. > > Someday, I would really like to decouple Click from the L3 code, and have it > use FromHost/ToHost elements to interact with the stack over real tun/tap > devices. :\ Comments on the patch. I'm generally fine with it. Shouldn't it also make this change? --- a/src/internet/model/ipv4-raw-socket-factory-impl.cc Tue Jul 24 17:11:01 2012 -0700 +++ b/src/internet/model/ipv4-raw-socket-factory-impl.cc Thu Jul 26 06:06:31 2012 -0700 @@ -29,6 +29,7 @@ Ipv4RawSocketFactoryImpl::CreateSocket (void) { - Ptr<Ipv4L3Protocol> ipv4 = GetObject<Ipv4L3Protocol> (); + Ptr<Ipv4> ipv4 = GetObject<Ipv4> (); Ptr<Socket> socket = ipv4->CreateRawSocket (); return socket; also delete "ipv4-l3-protocol.h" from includes. The three new Ipv4 public methods need doxygen
(In reply to comment #3) > (In reply to comment #2) > > Created attachment 1428 [details] > > Fix > > > > Here's a first patch that fixes the problem. It basically fixes the Icmpv4 and > > raw socket code to only use Ipv4 type pointers instead of directly getting an > > Ipv4L3Protocol object. And within Ipv4L3ClickProtocol, we forward Ipv4 packets > > further up to any raw sockets before handing them to Click. > > > > Someday, I would really like to decouple Click from the L3 code, and have it > > use FromHost/ToHost elements to interact with the stack over real tun/tap > > devices. :\ > > Comments on the patch. I'm generally fine with it. Shouldn't it also make > this change? > > --- a/src/internet/model/ipv4-raw-socket-factory-impl.cc Tue Jul 24 17:11:01 > 2012 -0700 > +++ b/src/internet/model/ipv4-raw-socket-factory-impl.cc Thu Jul 26 06:06:31 > 2012 -0700 > @@ -29,6 +29,7 @@ > Ipv4RawSocketFactoryImpl::CreateSocket (void) > { > - Ptr<Ipv4L3Protocol> ipv4 = GetObject<Ipv4L3Protocol> (); > + Ptr<Ipv4> ipv4 = GetObject<Ipv4> (); > Ptr<Socket> socket = ipv4->CreateRawSocket (); > return socket; > It's already in the patchset. > also delete "ipv4-l3-protocol.h" from includes. > > The three new Ipv4 public methods need doxygen Yes, I'll do the cleaning up, doxygen, style-check and then commit.
Changeset 8922 922350836734