1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2008 University of Washington
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "emu-net-device.h"
20 #include "emu-encode-decode.h"
23 #include "ns3/queue.h"
24 #include "ns3/simulator.h"
25 #include "ns3/realtime-simulator-impl.h"
26 #include "ns3/mac48-address.h"
27 #include "ns3/ethernet-header.h"
28 #include "ns3/ethernet-trailer.h"
29 #include "ns3/llc-snap-header.h"
30 #include "ns3/trace-source-accessor.h"
31 #include "ns3/pointer.h"
32 #include "ns3/channel.h"
33 #include "ns3/system-thread.h"
34 #include "ns3/string.h"
35 #include "ns3/boolean.h"
39 #include <sys/socket.h>
41 #include <sys/ioctl.h>
42 #include <net/ethernet.h>
44 #include <netinet/in.h>
45 #include <netpacket/packet.h>
46 #include <arpa/inet.h>
49 NS_LOG_COMPONENT_DEFINE ("EmuNetDevice");
53 NS_OBJECT_ENSURE_REGISTERED (EmuNetDevice);
55 #define EMU_MAGIC 65867
58 EmuNetDevice::GetTypeId (void)
60 static TypeId tid = TypeId ("ns3::EmuNetDevice")
61 .SetParent<NetDevice> ()
62 .AddConstructor<EmuNetDevice> ()
63 .AddAttribute ("Address",
64 "The ns-3 MAC address of this (virtual) device.",
65 Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
66 MakeMac48AddressAccessor (&EmuNetDevice::m_address),
67 MakeMac48AddressChecker ())
68 .AddAttribute ("DeviceName",
69 "The name of the underlying real device (e.g. eth1).",
71 MakeStringAccessor (&EmuNetDevice::m_deviceName),
73 .AddAttribute ("Start",
74 "The simulation time at which to spin up the device thread.",
75 TimeValue (Seconds (0.)),
76 MakeTimeAccessor (&EmuNetDevice::m_tStart),
78 .AddAttribute ("Stop",
79 "The simulation time at which to tear down the device thread.",
80 TimeValue (Seconds (0.)),
81 MakeTimeAccessor (&EmuNetDevice::m_tStop),
83 .AddAttribute ("TxQueue",
84 "A queue to use as the transmit queue in the device.",
86 MakePointerAccessor (&EmuNetDevice::m_queue),
87 MakePointerChecker<Queue> ())
88 .AddTraceSource ("Rx",
89 "Trace source to fire on reception of a MAC packet.",
90 MakeTraceSourceAccessor (&EmuNetDevice::m_rxTrace))
91 .AddTraceSource ("Drop",
92 "Trace source to fire on when a MAC packet is dropped.",
93 MakeTraceSourceAccessor (&EmuNetDevice::m_dropTrace))
99 EmuNetDevice::EmuNetDevice ()
107 m_name ("Emu NetDevice")
109 NS_LOG_FUNCTION (this);
113 EmuNetDevice::~EmuNetDevice ()
118 EmuNetDevice::DoDispose()
120 NS_LOG_FUNCTION_NOARGS ();
122 NetDevice::DoDispose ();
126 EmuNetDevice::Start (Time tStart)
128 NS_LOG_FUNCTION (tStart);
131 // Cancel any pending start event and schedule a new one at some relative time in the future.
133 Simulator::Cancel (m_startEvent);
134 m_startEvent = Simulator::Schedule (tStart, &EmuNetDevice::StartDevice, this);
138 EmuNetDevice::Stop (Time tStop)
140 NS_LOG_FUNCTION (tStop);
142 // Cancel any pending stop event and schedule a new one at some relative time in the future.
144 Simulator::Cancel (m_stopEvent);
145 m_startEvent = Simulator::Schedule (tStop, &EmuNetDevice::StopDevice, this);
149 EmuNetDevice::StartDevice (void)
151 NS_LOG_FUNCTION_NOARGS ();
154 // Spin up the emu net device and start receiving packets.
156 NS_ASSERT_MSG (m_sock == -1, "EmuNetDevice::StartDevice(): Device is already started");
158 NS_LOG_LOGIC ("Creating socket");
160 // Call out to a separate process running as suid root in order to get a raw
161 // socket. We do this to avoid having the entire simulation running as root.
162 // If this method returns, we'll have a raw socket waiting for us in m_sock.
167 // Figure out which interface index corresponds to the device name in the corresponding attribute.
170 bzero (&ifr, sizeof(ifr));
171 strncpy ((char *)ifr.ifr_name, m_deviceName.c_str (), IFNAMSIZ);
173 NS_LOG_LOGIC ("Getting interface index");
174 int32_t rc = ioctl (m_sock, SIOCGIFINDEX, &ifr);
175 NS_ASSERT_MSG (rc != -1, "EmuNetDevice::StartDevice(): Can't get interface index");
178 // Save the real interface index for later calls to sendto
180 m_sll_ifindex = ifr.ifr_ifindex;
183 // Bind the socket to the interface we just found.
185 struct sockaddr_ll ll;
186 bzero (&ll, sizeof(ll));
188 ll.sll_family = AF_PACKET;
189 ll.sll_ifindex = m_sll_ifindex;
190 ll.sll_protocol = htons(ETH_P_ALL);
192 NS_LOG_LOGIC ("Binding socket to interface");
194 rc = bind (m_sock, (struct sockaddr *)&ll, sizeof (ll));
195 NS_ASSERT_MSG (rc != -1, "EmuNetDevice::StartDevice(): Can't bind to specified interface");
197 rc = ioctl(m_sock, SIOCGIFFLAGS, &ifr);
198 NS_ASSERT_MSG (rc != -1, "EmuNetDevice::StartDevice(): Can't get interface flags");
201 // This device only works if the underlying interface is up in promiscuous
202 // mode. We could have turned it on in the socket creator, but the situation
203 // is that we expect these devices to be used in conjunction with virtual
204 // machines with connected host-only (simulated) networks, or in a testbed.
205 // There is a lot of setup and configuration happening outside of this one
206 // issue, and we expect that configuration to include choosing a valid
207 // interface (e.g, "ath1"), ensuring that the device supports promiscuous
208 // mode, and placing it in promiscuous mode. We just make sure of the
211 if ((ifr.ifr_flags & IFF_PROMISC) == 0)
213 NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): " << m_deviceName << " is not in promiscuous mode");
217 // Now spin up a read thread to read packets.
219 NS_ASSERT_MSG (m_readThread == 0, "EmuNetDevice::StartDevice(): Receive thread is already running");
221 NS_LOG_LOGIC ("Spinning up read thread");
223 m_readThread = Create<SystemThread> (MakeCallback (&EmuNetDevice::ReadThread, this));
224 m_readThread->Start ();
230 EmuNetDevice::CreateSocket (void)
232 NS_LOG_FUNCTION_NOARGS ();
234 // We want to create a raw socket for our net device. Unfortunately for us
235 // you have to have root privileges to do that. Instead of running the
236 // entire simulation as root, we decided to make a small program who's whole
237 // reason for being is to run as suid root and create a raw socket. We're
238 // going to fork and exec that program soon, but we need to have a socket
239 // to talk to it with. So we create a local interprocess (Unix) socket
242 int sock = socket (PF_UNIX, SOCK_DGRAM, 0);
245 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Unix socket creation error, errno = " << strerror (errno));
249 // Bind to that socket and let the kernel allocate an endpoint
251 struct sockaddr_un un;
252 memset (&un, 0, sizeof (un));
253 un.sun_family = AF_UNIX;
254 int status = bind (sock, (struct sockaddr*)&un, sizeof (sa_family_t));
257 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Could not bind(): errno = " << strerror (errno));
260 NS_LOG_INFO ("Created Unix socket");
261 NS_LOG_INFO ("sun_family = " << un.sun_family);
262 NS_LOG_INFO ("sun_path = " << un.sun_path);
265 // We have a socket here, but we want to get it there -- to the program we're
266 // going to exec. What we'll do is to do a getsockname and then encode the
267 // resulting address information as a string, and then send the string to the
268 // program as an argument. So we need to get the sock name.
270 socklen_t len = sizeof (un);
271 status = getsockname (sock, (struct sockaddr*)&un, &len);
274 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Could not getsockname(): errno = " << strerror (errno));
278 // Now encode that socket name (family and path) as a string of hex digits
280 std::string path = EmuBufferToString((uint8_t *)&un, len);
281 NS_LOG_INFO ("Encoded Unix socket as \"" << path << "\"");
283 // Fork and exec the process to create our socket. If we're us (the parent)
284 // we wait for the child (the socket creator) to complete and read the
285 // socket it created using the ancillary data mechanism.
287 pid_t pid = ::fork ();
290 NS_LOG_DEBUG ("Child process");
293 // build a command line argument from the encoded endpoint string that
294 // the socket creation process will use to figure out how to respond to
295 // the (now) parent process.
297 std::ostringstream oss;
299 NS_LOG_INFO ("Parameters set to \"" << oss.str () << "\"");
302 // Execute the socket creation process image.
304 status = ::execl (FindCreator ().c_str (), "emu-sock-creator", oss.str ().c_str (), (char *)NULL);
307 // If the execl successfully completes, it never returns. If it returns it failed or the OS is
308 // broken. In either case, we bail.
310 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Back from execl(), errno = " << ::strerror (errno));
314 NS_LOG_DEBUG ("Parent process");
316 // We're the process running the emu net device. We need to wait for the
317 // socket creator process to finish its job.
320 pid_t waited = waitpid (pid, &st, 0);
323 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): waitpid() fails, errno = " << strerror (errno));
325 NS_ASSERT_MSG (pid == waited, "EmuNetDevice::CreateSocket(): pid mismatch");
328 // Check to see if the socket creator exited normally and then take a
329 // look at the exit code. If it bailed, so should we. If it didn't
330 // even exit normally, we bail too.
334 int exitStatus = WEXITSTATUS (st);
337 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): socket creator exited normally with status " << exitStatus);
342 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): socket creator exited abnormally");
346 // At this point, the socket creator has run successfully and should
347 // have created our raw socket and sent it back to the socket address
348 // we provided. Our socket should be waiting on the Unix socket. We've
349 // got to do a bunch of grunto work to get at it, though.
351 // The struct iovec below is part of a scatter-gather list. It describes a
352 // buffer. In this case, it describes a buffer (an integer) that will
353 // get the data that comes back from the socket creator process. It will
354 // be a magic number that we use as a consistency/sanity check.
358 iov.iov_base = &magic;
359 iov.iov_len = sizeof(magic);
362 // The CMSG macros you'll see below are used to create and access control
363 // messages (which is another name for ancillary data). The ancillary
364 // data is made up of pairs of struct cmsghdr structures and associated
367 // First, we're going to allocate a buffer on the stack to receive our
368 // data array (that contains the socket). Sometimes you'll see this called
369 // an "ancillary element" but the msghdr uses the control message termimology
370 // so we call it "control."
372 size_t msg_size = sizeof(int);
373 char control[CMSG_SPACE(msg_size)];
376 // There is a msghdr that is used to minimize the number of parameters
377 // passed to recvmsg (which we will use to receive our ancillary data).
378 // This structure uses terminology corresponding to control messages, so
379 // you'll see msg_control, which is the pointer to the ancillary data and
380 // controllen which is the size of the ancillary data array.
382 // So, initialize the message header that describes the ancillary/control
383 // data we expect to receive and point it to buffer.
390 msg.msg_control = control;
391 msg.msg_controllen = sizeof (control);
395 // Now we can actually receive the interesting bits from the socket
398 ssize_t bytesRead = recvmsg (sock, &msg, 0);
399 if (bytesRead != sizeof(int))
401 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Wrong byte count from socket creator");
405 // There may be a number of message headers/ancillary data arrays coming in.
406 // Let's look for the one with a type SCM_RIGHTS which indicates it' the
407 // one we're interested in.
409 struct cmsghdr *cmsg;
410 for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg))
412 if (cmsg->cmsg_level == SOL_SOCKET &&
413 cmsg->cmsg_type == SCM_RIGHTS)
416 // This is the type of message we want. Check to see if the magic
417 // number is correct and then pull out the socket we care about if
420 if (magic == EMU_MAGIC)
422 NS_LOG_INFO ("Got SCM_RIGHTS with correct magic " << magic);
423 int *rawSocket = (int*)CMSG_DATA (cmsg);
424 NS_LOG_INFO ("Got the socket from the socket creator = " << *rawSocket);
430 NS_LOG_INFO ("Got SCM_RIGHTS, but with bad magic " << magic);
434 NS_FATAL_ERROR ("Did not get the raw socket from the socket creator");
439 EmuNetDevice::FindCreator (void)
442 std::string debug = "./build/debug/src/devices/emu/emu-sock-creator";
443 std::string optimized = "./build/optimized/src/devices/emu/emu-sock-creator";
445 if (::stat (debug.c_str (), &st) == 0)
450 if (::stat (optimized.c_str (), &st) == 0)
455 NS_FATAL_ERROR ("EmuNetDevice::FindCreator(): Couldn't find creator");
456 return ""; // quiet compiler
460 EmuNetDevice::StopDevice (void)
462 NS_LOG_FUNCTION_NOARGS ();
467 NS_ASSERT_MSG (m_readThread != 0, "EmuNetDevice::StopDevice(): Receive thread is not running");
469 NS_LOG_LOGIC ("Joining read thread");
470 m_readThread->Join ();
475 EmuNetDevice::ForwardUp (uint8_t *buf, uint32_t len)
477 NS_LOG_FUNCTION (buf << len);
480 // Create a packet out of the buffer we received and free that buffer.
482 Ptr<Packet> packet = Create<Packet> (reinterpret_cast<const uint8_t *> (buf), len);
487 // Trace sinks will expect complete packets, not packets without some of the
490 Ptr<Packet> originalPacket = packet->Copy ();
493 // Checksum the packet
495 EthernetTrailer trailer;
496 packet->RemoveTrailer (trailer);
497 trailer.CheckFcs (packet);
499 EthernetHeader header (false);
500 packet->RemoveHeader (header);
502 NS_LOG_LOGIC ("Pkt source is " << header.GetSource ());
503 NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ());
506 packet->RemoveHeader (llc);
507 uint16_t protocol = llc.GetType ();
509 PacketType packetType;
511 if (header.GetDestination ().IsBroadcast ())
513 NS_LOG_LOGIC ("Pkt destination is PACKET_BROADCAST");
514 packetType = NS3_PACKET_BROADCAST;
516 else if (header.GetDestination ().IsMulticast ())
518 NS_LOG_LOGIC ("Pkt destination is PACKET_MULTICAST");
519 packetType = NS3_PACKET_MULTICAST;
521 else if (header.GetDestination () == m_address)
523 NS_LOG_LOGIC ("Pkt destination is PACKET_HOST");
524 packetType = NS3_PACKET_HOST;
528 NS_LOG_LOGIC ("Pkt destination is PACKET_OTHERHOST");
529 packetType = NS3_PACKET_OTHERHOST;
532 if (!m_promiscRxCallback.IsNull ())
534 NS_LOG_LOGIC ("calling m_promiscRxCallback");
535 m_promiscRxCallback (this, packet->Copy (), protocol, header.GetSource (), header.GetDestination (), packetType);
538 if (packetType != NS3_PACKET_OTHERHOST)
540 m_rxTrace (originalPacket);
541 NS_LOG_LOGIC ("calling m_rxCallback");
542 m_rxCallback (this, packet, protocol, header.GetSource ());
547 EmuNetDevice::ReadThread (void)
549 NS_LOG_FUNCTION_NOARGS ();
552 // It's important to remember that we're in a completely different thread than the simulator is running in. We
553 // need to synchronize with that other thread to get the packet up into ns-3. What we will need to do is to schedule
554 // a method to forward up the packet using the multithreaded simulator we are most certainly running. However, I just
555 // said it -- we are talking about two threads here, so it is very, very dangerous to do any kind of reference couning
556 // on a shared object. Just don't do it. So what we're going to do is to allocate a buffer on the heap and pass that
557 // buffer into the ns-3 context thread where it will create the packet.
561 struct sockaddr_ll addr;
562 socklen_t addrSize = sizeof (addr);
566 uint32_t bufferSize = 65536;
567 uint8_t *buf = (uint8_t *)malloc (bufferSize);
568 NS_ASSERT_MSG (buf, "EmuNetDevice::ReadThread(): malloc packet buffer failed");
569 NS_LOG_LOGIC ("Calling recvfrom");
570 len = recvfrom (m_sock, buf, bufferSize, 0, (struct sockaddr *)&addr, &addrSize);
579 NS_LOG_INFO ("EmuNetDevice::ReadThread(): Received packet");
580 NS_LOG_INFO ("EmuNetDevice::ReadThread(): Scheduling handler");
581 DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow (
582 MakeEvent (&EmuNetDevice::ForwardUp, this, buf, len));
588 EmuNetDevice::Send (Ptr<Packet> packet, const Address &dest, uint16_t protocolNumber)
590 NS_LOG_FUNCTION (packet << dest << protocolNumber);
592 // The immediate questions here are how are we going to encapsulate packets and what do we use as the MAC source and
593 // destination (hardware) addresses?
595 // If we return false from EmuNetDevice::NeedsArp, the ArpIpv4Interface will pass the broadcast address as the
596 // hardware (Ethernet) destination by default. If we return true from EmuNetDevice::NeedsArp, then the hardware
597 // destination is actually meaningful, but we'll have an ns-3 ARP running on this device. There can also be an ARP
598 // running on the underlying OS so we have to be very careful, both about multiple ARPs and also about TCP, UDP, etc.
600 // We are operating in promiscuous mode on the receive side (all ns-3 net devices are required to implement the
601 // promiscuous callback in a meaningful way), so we have an option regarding the hardware addresses. We don't actually have
602 // to use the real hardware addresses and IP addresses of the underlying system. We can completely use MAC-spoofing to
603 // fake out the OS by using the ns-3 assigned MAC address (and also the ns-3 assigned IP addresses). Ns-3 starts its
604 // MAC address allocation using the OUI (vendor-code) 00:00:00 which is unassigned to any organization and is a globally
605 // administered address, so there shouldn't be any collisions with real hardware.
607 // So what we do is we return true from EmuNetDevice::NeedsArp which tells ns-3 to use its own ARP. We spoof the
608 // MAC address of the device and use promiscuous mode to receive traffic destined to that address.
610 return SendFrom (packet, m_address, dest, protocolNumber);
614 EmuNetDevice::SendFrom (Ptr<Packet> packet, const Address &src, const Address &dest, uint16_t protocolNumber)
616 NS_LOG_FUNCTION (packet << src << dest << protocolNumber);
618 if (IsLinkUp () == false)
620 NS_LOG_LOGIC ("Link is down, returning");
624 Mac48Address destination = Mac48Address::ConvertFrom (dest);
625 Mac48Address source = Mac48Address::ConvertFrom (src);
627 NS_LOG_LOGIC ("Transmit packet with UID " << packet->GetUid ());
628 NS_LOG_LOGIC ("Transmit packet from " << source);
629 NS_LOG_LOGIC ("Transmit packet to " << destination);
634 bzero (&ifr, sizeof(ifr));
635 strncpy ((char *)ifr.ifr_name, m_deviceName.c_str (), IFNAMSIZ);
637 NS_LOG_LOGIC ("Getting MAC address");
638 int32_t rc = ioctl (m_sock, SIOCGIFHWADDR, &ifr);
639 NS_ASSERT_MSG (rc != -1, "EmuNetDevice::SendFrom(): Can't get MAC address");
641 std::ostringstream oss;
643 (ifr.ifr_hwaddr.sa_data[0] & 0xff) << ":" <<
644 (ifr.ifr_hwaddr.sa_data[1] & 0xff) << ":" <<
645 (ifr.ifr_hwaddr.sa_data[2] & 0xff) << ":" <<
646 (ifr.ifr_hwaddr.sa_data[3] & 0xff) << ":" <<
647 (ifr.ifr_hwaddr.sa_data[4] & 0xff) << ":" <<
648 (ifr.ifr_hwaddr.sa_data[5] & 0xff) << std::dec;
650 NS_LOG_LOGIC ("Fixup source to HW MAC " << oss.str ());
651 source = Mac48Address (oss.str ().c_str ());
652 NS_LOG_LOGIC ("source now " << source);
657 llc.SetType (protocolNumber);
658 packet->AddHeader (llc);
660 EthernetHeader header (false);
661 header.SetSource (source);
662 header.SetDestination (destination);
663 header.SetLengthType (packet->GetSize ());
664 packet->AddHeader (header);
666 EthernetTrailer trailer;
667 trailer.CalcFcs (packet);
668 packet->AddTrailer (trailer);
671 // Enqueue and dequeue the packet to hit the tracing hooks.
673 m_queue->Enqueue (packet);
674 packet = m_queue->Dequeue ();
676 struct sockaddr_ll ll;
677 bzero (&ll, sizeof (ll));
679 ll.sll_family = AF_PACKET;
680 ll.sll_ifindex = m_sll_ifindex;
681 ll.sll_protocol = htons(ETH_P_ALL);
683 NS_LOG_LOGIC ("calling sendto");
686 rc = sendto (m_sock, packet->PeekData (), packet->GetSize (), 0, reinterpret_cast<struct sockaddr *> (&ll), sizeof (ll));
688 NS_LOG_LOGIC ("sendto returns " << rc);
690 return rc == -1 ? false : true;
694 EmuNetDevice::SetDataRate(DataRate bps)
696 NS_LOG_FUNCTION (this << bps);
697 NS_ASSERT_MSG (false, "EmuNetDevice::SetDataRate(): Unable.");
701 EmuNetDevice::SetQueue (Ptr<Queue> q)
703 NS_LOG_FUNCTION (this << q);
708 EmuNetDevice::GetQueue(void) const
710 NS_LOG_FUNCTION_NOARGS ();
715 EmuNetDevice::NotifyLinkUp (void)
718 if (!m_linkChangeCallback.IsNull ())
720 m_linkChangeCallback ();
725 EmuNetDevice::SetName(const std::string name)
731 EmuNetDevice::GetName(void) const
737 EmuNetDevice::SetIfIndex(const uint32_t index)
743 EmuNetDevice::GetIfIndex(void) const
749 EmuNetDevice::GetChannel (void) const
751 NS_ASSERT_MSG (false, "EmuNetDevice::GetChannel(): Unable.");
756 EmuNetDevice::SetAddress (Mac48Address addr)
758 NS_LOG_FUNCTION (addr);
763 EmuNetDevice::GetAddress (void) const
765 NS_LOG_FUNCTION_NOARGS ();
770 EmuNetDevice::SetMtu (const uint16_t mtu)
772 NS_ASSERT_MSG (false, "EmuNetDevice::SetMtu(): Unable.");
777 EmuNetDevice::GetMtu (void) const
780 bzero (&ifr, sizeof (ifr));
781 strcpy(ifr.ifr_name, m_deviceName.c_str ());
783 int32_t fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
785 int32_t rc = ioctl(fd, SIOCGIFMTU, &ifr);
786 NS_ASSERT_MSG (rc != -1, "EmuNetDevice::GetMtu(): Can't ioctl SIOCGIFMTU");
794 EmuNetDevice::IsLinkUp (void) const
800 EmuNetDevice::SetLinkChangeCallback (Callback<void> callback)
802 m_linkChangeCallback = callback;
806 EmuNetDevice::IsBroadcast (void) const
812 EmuNetDevice::GetBroadcast (void) const
814 return Mac48Address ("ff:ff:ff:ff:ff:ff");
818 EmuNetDevice::IsMulticast (void) const
824 EmuNetDevice::GetMulticast (Ipv4Address multicastGroup) const
826 NS_LOG_FUNCTION (multicastGroup);
828 Mac48Address ad = Mac48Address::GetMulticast (multicastGroup);
831 // Implicit conversion (operator Address ()) is defined for Mac48Address, so
832 // use it by just returning the EUI-48 address which is automagically converted
835 NS_LOG_LOGIC ("multicast address is " << ad);
841 EmuNetDevice::IsPointToPoint (void) const
847 EmuNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
849 NS_ASSERT_MSG (false, "EmuNetDevice::SetPromiscReceiveCallback(): Not implemented");
853 EmuNetDevice::SupportsSendFrom () const
855 NS_LOG_FUNCTION_NOARGS ();
861 EmuNetDevice::GetNode (void) const
867 EmuNetDevice::SetNode (Ptr<Node> node)
873 EmuNetDevice::NeedsArp (void) const
879 EmuNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)