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>
51 NS_LOG_COMPONENT_DEFINE ("EmuNetDevice");
55 NS_OBJECT_ENSURE_REGISTERED (EmuNetDevice);
57 #define EMU_MAGIC 65867
60 EmuNetDevice::GetTypeId (void)
62 static TypeId tid = TypeId ("ns3::EmuNetDevice")
63 .SetParent<NetDevice> ()
64 .AddConstructor<EmuNetDevice> ()
65 .AddAttribute ("Address",
66 "The ns-3 MAC address of this (virtual) device.",
67 Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
68 MakeMac48AddressAccessor (&EmuNetDevice::m_address),
69 MakeMac48AddressChecker ())
70 .AddAttribute ("DeviceName",
71 "The name of the underlying real device (e.g. eth1).",
73 MakeStringAccessor (&EmuNetDevice::m_deviceName),
75 .AddAttribute ("Start",
76 "The simulation time at which to spin up the device thread.",
77 TimeValue (Seconds (0.)),
78 MakeTimeAccessor (&EmuNetDevice::m_tStart),
80 .AddAttribute ("Stop",
81 "The simulation time at which to tear down the device thread.",
82 TimeValue (Seconds (0.)),
83 MakeTimeAccessor (&EmuNetDevice::m_tStop),
85 .AddAttribute ("TxQueue",
86 "A queue to use as the transmit queue in the device.",
88 MakePointerAccessor (&EmuNetDevice::m_queue),
89 MakePointerChecker<Queue> ())
90 .AddTraceSource ("Rx",
91 "Trace source to fire on reception of a MAC packet.",
92 MakeTraceSourceAccessor (&EmuNetDevice::m_rxTrace))
93 .AddTraceSource ("Drop",
94 "Trace source to fire on when a MAC packet is dropped.",
95 MakeTraceSourceAccessor (&EmuNetDevice::m_dropTrace))
101 EmuNetDevice::EmuNetDevice ()
107 m_ifIndex (std::numeric_limits<uint32_t>::max ()), // absurdly large value
109 m_name ("Emu NetDevice")
111 NS_LOG_FUNCTION (this);
115 EmuNetDevice::~EmuNetDevice ()
120 EmuNetDevice::DoDispose()
122 NS_LOG_FUNCTION_NOARGS ();
124 NetDevice::DoDispose ();
128 EmuNetDevice::Start (Time tStart)
130 NS_LOG_FUNCTION (tStart);
133 // Cancel any pending start event and schedule a new one at some relative time in the future.
135 Simulator::Cancel (m_startEvent);
136 m_startEvent = Simulator::Schedule (tStart, &EmuNetDevice::StartDevice, this);
140 EmuNetDevice::Stop (Time tStop)
142 NS_LOG_FUNCTION (tStop);
144 // Cancel any pending stop event and schedule a new one at some relative time in the future.
146 Simulator::Cancel (m_stopEvent);
147 m_startEvent = Simulator::Schedule (tStop, &EmuNetDevice::StopDevice, this);
151 EmuNetDevice::StartDevice (void)
153 NS_LOG_FUNCTION_NOARGS ();
156 // Spin up the emu net device and start receiving packets.
160 NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Device is already started");
163 NS_LOG_LOGIC ("Creating socket");
165 // Call out to a separate process running as suid root in order to get a raw
166 // socket. We do this to avoid having the entire simulation running as root.
167 // If this method returns, we'll have a raw socket waiting for us in m_sock.
172 // Figure out which interface index corresponds to the device name in the corresponding attribute.
175 bzero (&ifr, sizeof(ifr));
176 strncpy ((char *)ifr.ifr_name, m_deviceName.c_str (), IFNAMSIZ);
178 NS_LOG_LOGIC ("Getting interface index");
179 int32_t rc = ioctl (m_sock, SIOCGIFINDEX, &ifr);
182 NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Can't get interface index");
186 // Save the real interface index for later calls to sendto
188 m_sll_ifindex = ifr.ifr_ifindex;
191 // Bind the socket to the interface we just found.
193 struct sockaddr_ll ll;
194 bzero (&ll, sizeof(ll));
196 ll.sll_family = AF_PACKET;
197 ll.sll_ifindex = m_sll_ifindex;
198 ll.sll_protocol = htons(ETH_P_ALL);
200 NS_LOG_LOGIC ("Binding socket to interface");
202 rc = bind (m_sock, (struct sockaddr *)&ll, sizeof (ll));
205 NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Can't bind to specified interface");
208 rc = ioctl(m_sock, SIOCGIFFLAGS, &ifr);
211 NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Can't get interface flags");
215 // This device only works if the underlying interface is up in promiscuous
216 // mode. We could have turned it on in the socket creator, but the situation
217 // is that we expect these devices to be used in conjunction with virtual
218 // machines with connected host-only (simulated) networks, or in a testbed.
219 // There is a lot of setup and configuration happening outside of this one
220 // issue, and we expect that configuration to include choosing a valid
221 // interface (e.g, "ath1"), ensuring that the device supports promiscuous
222 // mode, and placing it in promiscuous mode. We just make sure of the
225 if ((ifr.ifr_flags & IFF_PROMISC) == 0)
227 NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): " << m_deviceName << " is not in promiscuous mode");
231 // Now spin up a read thread to read packets.
233 if (m_readThread != 0)
235 NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Receive thread is already running");
238 NS_LOG_LOGIC ("Spinning up read thread");
240 m_readThread = Create<SystemThread> (MakeCallback (&EmuNetDevice::ReadThread, this));
241 m_readThread->Start ();
247 EmuNetDevice::CreateSocket (void)
249 NS_LOG_FUNCTION_NOARGS ();
251 // We want to create a raw socket for our net device. Unfortunately for us
252 // you have to have root privileges to do that. Instead of running the
253 // entire simulation as root, we decided to make a small program who's whole
254 // reason for being is to run as suid root and create a raw socket. We're
255 // going to fork and exec that program soon, but we need to have a socket
256 // to talk to it with. So we create a local interprocess (Unix) socket
259 int sock = socket (PF_UNIX, SOCK_DGRAM, 0);
262 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Unix socket creation error, errno = " << strerror (errno));
266 // Bind to that socket and let the kernel allocate an endpoint
268 struct sockaddr_un un;
269 memset (&un, 0, sizeof (un));
270 un.sun_family = AF_UNIX;
271 int status = bind (sock, (struct sockaddr*)&un, sizeof (sa_family_t));
274 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Could not bind(): errno = " << strerror (errno));
277 NS_LOG_INFO ("Created Unix socket");
278 NS_LOG_INFO ("sun_family = " << un.sun_family);
279 NS_LOG_INFO ("sun_path = " << un.sun_path);
282 // We have a socket here, but we want to get it there -- to the program we're
283 // going to exec. What we'll do is to do a getsockname and then encode the
284 // resulting address information as a string, and then send the string to the
285 // program as an argument. So we need to get the sock name.
287 socklen_t len = sizeof (un);
288 status = getsockname (sock, (struct sockaddr*)&un, &len);
291 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Could not getsockname(): errno = " << strerror (errno));
295 // Now encode that socket name (family and path) as a string of hex digits
297 std::string path = EmuBufferToString((uint8_t *)&un, len);
298 NS_LOG_INFO ("Encoded Unix socket as \"" << path << "\"");
300 // Fork and exec the process to create our socket. If we're us (the parent)
301 // we wait for the child (the socket creator) to complete and read the
302 // socket it created using the ancillary data mechanism.
304 pid_t pid = ::fork ();
307 NS_LOG_DEBUG ("Child process");
310 // build a command line argument from the encoded endpoint string that
311 // the socket creation process will use to figure out how to respond to
312 // the (now) parent process.
314 std::ostringstream oss;
316 NS_LOG_INFO ("Parameters set to \"" << oss.str () << "\"");
319 // Execute the socket creation process image.
321 status = ::execl (FindCreator ().c_str (), "emu-sock-creator", oss.str ().c_str (), (char *)NULL);
324 // If the execl successfully completes, it never returns. If it returns it failed or the OS is
325 // broken. In either case, we bail.
327 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Back from execl(), errno = " << ::strerror (errno));
331 NS_LOG_DEBUG ("Parent process");
333 // We're the process running the emu net device. We need to wait for the
334 // socket creator process to finish its job.
337 pid_t waited = waitpid (pid, &st, 0);
340 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): waitpid() fails, errno = " << strerror (errno));
342 NS_ASSERT_MSG (pid == waited, "EmuNetDevice::CreateSocket(): pid mismatch");
345 // Check to see if the socket creator exited normally and then take a
346 // look at the exit code. If it bailed, so should we. If it didn't
347 // even exit normally, we bail too.
351 int exitStatus = WEXITSTATUS (st);
354 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): socket creator exited normally with status " << exitStatus);
359 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): socket creator exited abnormally");
363 // At this point, the socket creator has run successfully and should
364 // have created our raw socket and sent it back to the socket address
365 // we provided. Our socket should be waiting on the Unix socket. We've
366 // got to do a bunch of grunto work to get at it, though.
368 // The struct iovec below is part of a scatter-gather list. It describes a
369 // buffer. In this case, it describes a buffer (an integer) that will
370 // get the data that comes back from the socket creator process. It will
371 // be a magic number that we use as a consistency/sanity check.
375 iov.iov_base = &magic;
376 iov.iov_len = sizeof(magic);
379 // The CMSG macros you'll see below are used to create and access control
380 // messages (which is another name for ancillary data). The ancillary
381 // data is made up of pairs of struct cmsghdr structures and associated
384 // First, we're going to allocate a buffer on the stack to receive our
385 // data array (that contains the socket). Sometimes you'll see this called
386 // an "ancillary element" but the msghdr uses the control message termimology
387 // so we call it "control."
389 size_t msg_size = sizeof(int);
390 char control[CMSG_SPACE(msg_size)];
393 // There is a msghdr that is used to minimize the number of parameters
394 // passed to recvmsg (which we will use to receive our ancillary data).
395 // This structure uses terminology corresponding to control messages, so
396 // you'll see msg_control, which is the pointer to the ancillary data and
397 // controllen which is the size of the ancillary data array.
399 // So, initialize the message header that describes the ancillary/control
400 // data we expect to receive and point it to buffer.
407 msg.msg_control = control;
408 msg.msg_controllen = sizeof (control);
412 // Now we can actually receive the interesting bits from the socket
415 ssize_t bytesRead = recvmsg (sock, &msg, 0);
416 if (bytesRead != sizeof(int))
418 NS_FATAL_ERROR ("EmuNetDevice::CreateSocket(): Wrong byte count from socket creator");
422 // There may be a number of message headers/ancillary data arrays coming in.
423 // Let's look for the one with a type SCM_RIGHTS which indicates it' the
424 // one we're interested in.
426 struct cmsghdr *cmsg;
427 for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg))
429 if (cmsg->cmsg_level == SOL_SOCKET &&
430 cmsg->cmsg_type == SCM_RIGHTS)
433 // This is the type of message we want. Check to see if the magic
434 // number is correct and then pull out the socket we care about if
437 if (magic == EMU_MAGIC)
439 NS_LOG_INFO ("Got SCM_RIGHTS with correct magic " << magic);
440 int *rawSocket = (int*)CMSG_DATA (cmsg);
441 NS_LOG_INFO ("Got the socket from the socket creator = " << *rawSocket);
447 NS_LOG_INFO ("Got SCM_RIGHTS, but with bad magic " << magic);
451 NS_FATAL_ERROR ("Did not get the raw socket from the socket creator");
456 EmuNetDevice::FindCreator (void)
459 std::string debug = "./build/debug/src/devices/emu/emu-sock-creator";
460 std::string optimized = "./build/optimized/src/devices/emu/emu-sock-creator";
462 if (::stat (debug.c_str (), &st) == 0)
467 if (::stat (optimized.c_str (), &st) == 0)
472 NS_FATAL_ERROR ("EmuNetDevice::FindCreator(): Couldn't find creator");
473 return ""; // quiet compiler
477 EmuNetDevice::StopDevice (void)
479 NS_LOG_FUNCTION_NOARGS ();
484 NS_ASSERT_MSG (m_readThread != 0, "EmuNetDevice::StopDevice(): Receive thread is not running");
486 NS_LOG_LOGIC ("Joining read thread");
487 m_readThread->Join ();
492 EmuNetDevice::ForwardUp (uint8_t *buf, uint32_t len)
494 NS_LOG_FUNCTION (buf << len);
497 // Create a packet out of the buffer we received and free that buffer.
499 Ptr<Packet> packet = Create<Packet> (reinterpret_cast<const uint8_t *> (buf), len);
504 // Trace sinks will expect complete packets, not packets without some of the
507 Ptr<Packet> originalPacket = packet->Copy ();
510 // Checksum the packet
512 EthernetTrailer trailer;
513 packet->RemoveTrailer (trailer);
514 trailer.CheckFcs (packet);
516 EthernetHeader header (false);
517 packet->RemoveHeader (header);
519 NS_LOG_LOGIC ("Pkt source is " << header.GetSource ());
520 NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ());
523 packet->RemoveHeader (llc);
524 uint16_t protocol = llc.GetType ();
526 PacketType packetType;
528 if (header.GetDestination ().IsBroadcast ())
530 NS_LOG_LOGIC ("Pkt destination is PACKET_BROADCAST");
531 packetType = NS3_PACKET_BROADCAST;
533 else if (header.GetDestination ().IsMulticast ())
535 NS_LOG_LOGIC ("Pkt destination is PACKET_MULTICAST");
536 packetType = NS3_PACKET_MULTICAST;
538 else if (header.GetDestination () == m_address)
540 NS_LOG_LOGIC ("Pkt destination is PACKET_HOST");
541 packetType = NS3_PACKET_HOST;
545 NS_LOG_LOGIC ("Pkt destination is PACKET_OTHERHOST");
546 packetType = NS3_PACKET_OTHERHOST;
549 if (!m_promiscRxCallback.IsNull ())
551 NS_LOG_LOGIC ("calling m_promiscRxCallback");
552 m_promiscRxCallback (this, packet->Copy (), protocol, header.GetSource (), header.GetDestination (), packetType);
555 if (packetType != NS3_PACKET_OTHERHOST)
557 m_rxTrace (originalPacket);
558 NS_LOG_LOGIC ("calling m_rxCallback");
559 m_rxCallback (this, packet, protocol, header.GetSource ());
564 EmuNetDevice::ReadThread (void)
566 NS_LOG_FUNCTION_NOARGS ();
569 // It's important to remember that we're in a completely different thread than the simulator is running in. We
570 // need to synchronize with that other thread to get the packet up into ns-3. What we will need to do is to schedule
571 // a method to forward up the packet using the multithreaded simulator we are most certainly running. However, I just
572 // said it -- we are talking about two threads here, so it is very, very dangerous to do any kind of reference couning
573 // 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
574 // buffer into the ns-3 context thread where it will create the packet.
578 struct sockaddr_ll addr;
579 socklen_t addrSize = sizeof (addr);
583 uint32_t bufferSize = 65536;
584 uint8_t *buf = (uint8_t *)malloc (bufferSize);
587 NS_FATAL_ERROR ("EmuNetDevice::ReadThread(): malloc packet buffer failed");
590 NS_LOG_LOGIC ("Calling recvfrom");
591 len = recvfrom (m_sock, buf, bufferSize, 0, (struct sockaddr *)&addr, &addrSize);
600 NS_LOG_INFO ("EmuNetDevice::ReadThread(): Received packet");
601 NS_LOG_INFO ("EmuNetDevice::ReadThread(): Scheduling handler");
602 DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow (
603 MakeEvent (&EmuNetDevice::ForwardUp, this, buf, len));
609 EmuNetDevice::Send (Ptr<Packet> packet, const Address &dest, uint16_t protocolNumber)
611 NS_LOG_FUNCTION (packet << dest << protocolNumber);
613 // The immediate questions here are how are we going to encapsulate packets and what do we use as the MAC source and
614 // destination (hardware) addresses?
616 // If we return false from EmuNetDevice::NeedsArp, the ArpIpv4Interface will pass the broadcast address as the
617 // hardware (Ethernet) destination by default. If we return true from EmuNetDevice::NeedsArp, then the hardware
618 // destination is actually meaningful, but we'll have an ns-3 ARP running on this device. There can also be an ARP
619 // running on the underlying OS so we have to be very careful, both about multiple ARPs and also about TCP, UDP, etc.
621 // We are operating in promiscuous mode on the receive side (all ns-3 net devices are required to implement the
622 // promiscuous callback in a meaningful way), so we have an option regarding the hardware addresses. We don't actually have
623 // to use the real hardware addresses and IP addresses of the underlying system. We can completely use MAC-spoofing to
624 // fake out the OS by using the ns-3 assigned MAC address (and also the ns-3 assigned IP addresses). Ns-3 starts its
625 // MAC address allocation using the OUI (vendor-code) 00:00:00 which is unassigned to any organization and is a globally
626 // administered address, so there shouldn't be any collisions with real hardware.
628 // So what we do is we return true from EmuNetDevice::NeedsArp which tells ns-3 to use its own ARP. We spoof the
629 // MAC address of the device and use promiscuous mode to receive traffic destined to that address.
631 return SendFrom (packet, m_address, dest, protocolNumber);
635 EmuNetDevice::SendFrom (Ptr<Packet> packet, const Address &src, const Address &dest, uint16_t protocolNumber)
637 NS_LOG_FUNCTION (packet << src << dest << protocolNumber);
639 if (IsLinkUp () == false)
641 NS_LOG_LOGIC ("Link is down, returning");
645 Mac48Address destination = Mac48Address::ConvertFrom (dest);
646 Mac48Address source = Mac48Address::ConvertFrom (src);
648 NS_LOG_LOGIC ("Transmit packet with UID " << packet->GetUid ());
649 NS_LOG_LOGIC ("Transmit packet from " << source);
650 NS_LOG_LOGIC ("Transmit packet to " << destination);
655 bzero (&ifr, sizeof(ifr));
656 strncpy ((char *)ifr.ifr_name, m_deviceName.c_str (), IFNAMSIZ);
658 NS_LOG_LOGIC ("Getting MAC address");
659 int32_t rc = ioctl (m_sock, SIOCGIFHWADDR, &ifr);
662 NS_FATAL_ERROR ("EmuNetDevice::SendFrom(): Can't get MAC address");
665 std::ostringstream oss;
667 (ifr.ifr_hwaddr.sa_data[0] & 0xff) << ":" <<
668 (ifr.ifr_hwaddr.sa_data[1] & 0xff) << ":" <<
669 (ifr.ifr_hwaddr.sa_data[2] & 0xff) << ":" <<
670 (ifr.ifr_hwaddr.sa_data[3] & 0xff) << ":" <<
671 (ifr.ifr_hwaddr.sa_data[4] & 0xff) << ":" <<
672 (ifr.ifr_hwaddr.sa_data[5] & 0xff) << std::dec;
674 NS_LOG_LOGIC ("Fixup source to HW MAC " << oss.str ());
675 source = Mac48Address (oss.str ().c_str ());
676 NS_LOG_LOGIC ("source now " << source);
681 llc.SetType (protocolNumber);
682 packet->AddHeader (llc);
684 EthernetHeader header (false);
685 header.SetSource (source);
686 header.SetDestination (destination);
687 header.SetLengthType (packet->GetSize ());
688 packet->AddHeader (header);
690 EthernetTrailer trailer;
691 trailer.CalcFcs (packet);
692 packet->AddTrailer (trailer);
695 // Enqueue and dequeue the packet to hit the tracing hooks.
697 m_queue->Enqueue (packet);
698 packet = m_queue->Dequeue ();
700 struct sockaddr_ll ll;
701 bzero (&ll, sizeof (ll));
703 ll.sll_family = AF_PACKET;
704 ll.sll_ifindex = m_sll_ifindex;
705 ll.sll_protocol = htons(ETH_P_ALL);
707 NS_LOG_LOGIC ("calling sendto");
710 rc = sendto (m_sock, packet->PeekData (), packet->GetSize (), 0, reinterpret_cast<struct sockaddr *> (&ll), sizeof (ll));
712 NS_LOG_LOGIC ("sendto returns " << rc);
714 return rc == -1 ? false : true;
718 EmuNetDevice::SetDataRate(DataRate bps)
720 NS_LOG_FUNCTION (this << bps);
721 NS_FATAL_ERROR ("EmuNetDevice::SetDataRate(): Unable.");
725 EmuNetDevice::SetQueue (Ptr<Queue> q)
727 NS_LOG_FUNCTION (this << q);
732 EmuNetDevice::GetQueue(void) const
734 NS_LOG_FUNCTION_NOARGS ();
739 EmuNetDevice::NotifyLinkUp (void)
742 if (!m_linkChangeCallback.IsNull ())
744 m_linkChangeCallback ();
749 EmuNetDevice::SetName(const std::string name)
755 EmuNetDevice::GetName(void) const
761 EmuNetDevice::SetIfIndex(const uint32_t index)
767 EmuNetDevice::GetIfIndex(void) const
773 EmuNetDevice::GetChannel (void) const
775 NS_FATAL_ERROR ("EmuNetDevice::GetChannel(): Unable.");
780 EmuNetDevice::SetAddress (Mac48Address addr)
782 NS_LOG_FUNCTION (addr);
787 EmuNetDevice::GetAddress (void) const
789 NS_LOG_FUNCTION_NOARGS ();
794 EmuNetDevice::SetMtu (const uint16_t mtu)
796 NS_FATAL_ERROR ("EmuNetDevice::SetMtu(): Unable.");
801 EmuNetDevice::GetMtu (void) const
804 bzero (&ifr, sizeof (ifr));
805 strcpy(ifr.ifr_name, m_deviceName.c_str ());
807 int32_t fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
810 int32_t rc = ioctl(fd, SIOCGIFMTU, &ifr);
813 NS_FATAL_ERROR ("EmuNetDevice::GetMtu(): Can't ioctl SIOCGIFMTU");
822 EmuNetDevice::IsLinkUp (void) const
828 EmuNetDevice::SetLinkChangeCallback (Callback<void> callback)
830 m_linkChangeCallback = callback;
834 EmuNetDevice::IsBroadcast (void) const
840 EmuNetDevice::GetBroadcast (void) const
842 return Mac48Address ("ff:ff:ff:ff:ff:ff");
846 EmuNetDevice::IsMulticast (void) const
852 EmuNetDevice::GetMulticast (Ipv4Address multicastGroup) const
854 NS_LOG_FUNCTION (multicastGroup);
856 Mac48Address ad = Mac48Address::GetMulticast (multicastGroup);
859 // Implicit conversion (operator Address ()) is defined for Mac48Address, so
860 // use it by just returning the EUI-48 address which is automagically converted
863 NS_LOG_LOGIC ("multicast address is " << ad);
869 EmuNetDevice::GetMulticast (Ipv6Address addr) const
871 NS_LOG_FUNCTION(this << addr);
873 Mac48Address ad = Mac48Address::GetMulticast (addr);
874 NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad);
880 EmuNetDevice::IsPointToPoint (void) const
886 EmuNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
888 NS_FATAL_ERROR ("EmuNetDevice::SetPromiscReceiveCallback(): Not implemented");
892 EmuNetDevice::SupportsSendFrom () const
894 NS_LOG_FUNCTION_NOARGS ();
900 EmuNetDevice::GetNode (void) const
906 EmuNetDevice::SetNode (Ptr<Node> node)
912 EmuNetDevice::NeedsArp (void) const
918 EmuNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)