Bug 1477 - Click doesn't work with raw sockets
Click doesn't work with raw sockets
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: click
pre-release
All All
: P3 normal
Assigned To: Lalith Suresh
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-25 15:38 UTC by Lalith Suresh
Modified: 2012-07-26 09:59 UTC (History)
2 users (show)

See Also:


Attachments
test script which shows the problem (6.85 KB, text/x-c++src)
2012-07-25 16:11 UTC, Jörg Kaiser
Details
Fix (6.96 KB, patch)
2012-07-26 07:06 UTC, Lalith Suresh
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lalith Suresh 2012-07-25 15:38:18 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.
Comment 1 Jörg Kaiser 2012-07-25 16:11:17 UTC
Created attachment 1427 [details]
test script which shows the problem
Comment 2 Lalith Suresh 2012-07-26 07:06:37 UTC
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. :\
Comment 3 Tom Henderson 2012-07-26 09:11:25 UTC
(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
Comment 4 Lalith Suresh 2012-07-26 09:18:45 UTC
(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.
Comment 5 Lalith Suresh 2012-07-26 09:59:43 UTC
Changeset 8922 922350836734