Bugzilla – Bug 942
ipv4-raw-socket-impl should listen more than one protocol
Last modified: 2011-03-16 10:25:50 UTC
As per current implementation in "src/internet-stack/ipv4-raw-socket-imple.cc" ********************** bool Ipv4RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<NetDevice> device) { NS_LOG_FUNCTION (this << *p << ipHeader << device); if (m_shutdownRecv) { return false; } NS_LOG_LOGIC ("src = " << m_src << " dst = " << m_dst); if ((m_src == Ipv4Address::GetAny () || ipHeader.GetDestination () == m_src) && (m_dst == Ipv4Address::GetAny () || ipHeader.GetSource () == m_dst) && ipHeader.GetProtocol () == m_protocol) ************************* When ForwardUp function is called during listening process of raw socket, it checks for a specific protocol received (ipHeader.GetProtocol () == m_protocol). Due to which raw socket cannot process ahead (or say cannot call NotifyDataRecv ();) for other packets received. Lets consider a scenario, Where a node is listening on raw socket, intended to listen and analyze network traffic. In this case node must be able to listen every type of packet.
Created attachment 920 [details] Required declaration in header file Following lines are added. void AddProtocol (uint16_t protocol); bool CheckProtocols(uint16_t protocol); std::vector<uint16_t> m_protocolList;
Created attachment 921 [details] To enable RawSocket to ForwardUp number of protocols Following functions are defined. void Ipv4RawSocketImpl::AddProtocol(uint16_t protocol).... bool Ipv4RawSocketImpl::CheckProtocols(uint16_t protocol)... Following changes in function ForwardUp() "CheckProtocols(ipHeader.GetProtocol())" and "ipHeader.GetProtocol () == 1" if ((m_src == Ipv4Address::GetAny () || ipHeader.GetDestination () == m_src) && (m_dst == Ipv4Address::GetAny () || ipHeader.GetSource () == m_dst) && CheckProtocols(ipHeader.GetProtocol()) ) //&& ipHeader.GetProtocol () == m_protocol) { Ptr<Packet> copy = p->Copy (); //if (m_protocol == 1) if (ipHeader.GetProtocol () == 1) {.....
Created attachment 925 [details] patch for Ipv4RawSocketImpl
Created attachment 926 [details] example to test if rawsocket is receiving more than one protocol
This one hasn't been pushed to ns-3-dev yet, right?
(In reply to comment #5) > This one hasn't been pushed to ns-3-dev yet, right? Patch had been submitted. I Marked it RESOLVED for verification by QA. (http://www.nsnam.org/bugzilla/page.cgi?id=fields.html#status)
(In reply to comment #6) > (In reply to comment #5) > > This one hasn't been pushed to ns-3-dev yet, right? > > Patch had been submitted. > I Marked it RESOLVED for verification by QA. > (http://www.nsnam.org/bugzilla/page.cgi?id=fields.html#status) I don't want to take this too far off track but Resolved/Fixed would mean that it's checked in. I think it is best to leave it open until then, so it will show up when I search for all open bugs.
(In reply to comment #4) > Created an attachment (id=926) [details] > example to test if rawsocket is receiving more than one protocol Could you instead create multiple raw sockets on a node and set their protocol numbers individually? Then, rather than passing a socket to your app, you could pass a list of sockets. Does this make sense? The reason I am thinking this way is because I don't understand how a protocol list will work in ipv4-raw-socket-impl, given that a single protocol (m_protocol) is used for things like Ipv4RawSocketImpl::Send/SendTo.
This is the socket type that this is trying to model: http://linux.die.net/man/7/raw Note: "Receiving of all IP protocols via IPPROTO_RAW is not possible using raw sockets. " Have a look at PacketSocket (src/node/packet-socket.h) which has a Bind(address) method that can be used to get all IP datagrams, I believe.
(In reply to comment #9) > This is the socket type that this is trying to model: > http://linux.die.net/man/7/raw > > Note: "Receiving of all IP protocols via IPPROTO_RAW is not possible using raw > sockets. " > > Have a look at PacketSocket (src/node/packet-socket.h) which has a > Bind(address) method that can be used to get all IP datagrams, I believe. Ok to mark resolved/invalid then?
(In reply to comment #10) > (In reply to comment #9) > > This is the socket type that this is trying to model: > > http://linux.die.net/man/7/raw > > > > Note: "Receiving of all IP protocols via IPPROTO_RAW is not possible using raw > > sockets. " > > > > Have a look at PacketSocket (src/node/packet-socket.h) which has a > > Bind(address) method that can be used to get all IP datagrams, I believe. > > Ok to mark resolved/invalid then? I believe so.