A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tap-bridge.cc
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
4  *
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;
8  *
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.
13  *
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
17  */
18 
19 #include "tap-bridge.h"
20 #include "tap-encode-decode.h"
21 
22 #include "ns3/node.h"
23 #include "ns3/channel.h"
24 #include "ns3/packet.h"
25 #include "ns3/ethernet-header.h"
26 #include "ns3/llc-snap-header.h"
27 #include "ns3/log.h"
28 #include "ns3/abort.h"
29 #include "ns3/boolean.h"
30 #include "ns3/string.h"
31 #include "ns3/enum.h"
32 #include "ns3/ipv4.h"
33 #include "ns3/simulator.h"
34 #include "ns3/realtime-simulator-impl.h"
35 #include "ns3/unix-fd-reader.h"
36 #include "ns3/uinteger.h"
37 
38 #include <sys/wait.h>
39 #include <sys/stat.h>
40 #include <sys/socket.h>
41 #include <sys/un.h>
42 #include <cerrno>
43 #include <limits>
44 #include <cstdlib>
45 #include <unistd.h>
46 
47 //
48 // Sometimes having a tap-creator is actually more trouble than solution. In
49 // these cases you can uncomment the define of TAP_CREATOR below and the
50 // simulation will just use a device you have preconfigured. This is useful
51 // if you are running in an environment where you have got to run as root,
52 // such as ORBIT or CORE.
53 //
54 
55 
56 // #define NO_CREATOR
57 
58 #ifdef NO_CREATOR
59 #include <fcntl.h>
60 #include <net/if.h>
61 #include <linux/if_tun.h>
62 #include <sys/ioctl.h>
63 #endif
64 
65 NS_LOG_COMPONENT_DEFINE ("TapBridge");
66 
67 namespace ns3 {
68 
70 {
72 
73  uint32_t bufferSize = 65536;
74  uint8_t *buf = (uint8_t *)std::malloc (bufferSize);
75  NS_ABORT_MSG_IF (buf == 0, "malloc() failed");
76 
77  NS_LOG_LOGIC ("Calling read on tap device fd " << m_fd);
78  ssize_t len = read (m_fd, buf, bufferSize);
79  if (len <= 0)
80  {
81  NS_LOG_INFO ("TapBridgeFdReader::DoRead(): done");
82  std::free (buf);
83  buf = 0;
84  len = 0;
85  }
86 
87  return FdReader::Data (buf, len);
88 }
89 
90 #define TAP_MAGIC 95549
91 
92 NS_OBJECT_ENSURE_REGISTERED (TapBridge);
93 
94 TypeId
95 TapBridge::GetTypeId (void)
96 {
97  static TypeId tid = TypeId ("ns3::TapBridge")
98  .SetParent<NetDevice> ()
99  .AddConstructor<TapBridge> ()
100  .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
101  UintegerValue (0),
102  MakeUintegerAccessor (&TapBridge::SetMtu,
104  MakeUintegerChecker<uint16_t> ())
105  .AddAttribute ("DeviceName",
106  "The name of the tap device to create.",
107  StringValue (""),
108  MakeStringAccessor (&TapBridge::m_tapDeviceName),
109  MakeStringChecker ())
110  .AddAttribute ("Gateway",
111  "The IP address of the default gateway to assign to the host machine, when in ConfigureLocal mode.",
112  Ipv4AddressValue ("255.255.255.255"),
113  MakeIpv4AddressAccessor (&TapBridge::m_tapGateway),
114  MakeIpv4AddressChecker ())
115  .AddAttribute ("IpAddress",
116  "The IP address to assign to the tap device, when in ConfigureLocal mode. "
117  "This address will override the discovered IP address of the simulated device.",
118  Ipv4AddressValue ("255.255.255.255"),
119  MakeIpv4AddressAccessor (&TapBridge::m_tapIp),
120  MakeIpv4AddressChecker ())
121  .AddAttribute ("MacAddress",
122  "The MAC address to assign to the tap device, when in ConfigureLocal mode. "
123  "This address will override the discovered MAC address of the simulated device.",
124  Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
125  MakeMac48AddressAccessor (&TapBridge::m_tapMac),
126  MakeMac48AddressChecker ())
127  .AddAttribute ("Netmask",
128  "The network mask to assign to the tap device, when in ConfigureLocal mode. "
129  "This address will override the discovered MAC address of the simulated device.",
130  Ipv4MaskValue ("255.255.255.255"),
131  MakeIpv4MaskAccessor (&TapBridge::m_tapNetmask),
132  MakeIpv4MaskChecker ())
133  .AddAttribute ("Start",
134  "The simulation time at which to spin up the tap device read thread.",
135  TimeValue (Seconds (0.)),
136  MakeTimeAccessor (&TapBridge::m_tStart),
137  MakeTimeChecker ())
138  .AddAttribute ("Stop",
139  "The simulation time at which to tear down the tap device read thread.",
140  TimeValue (Seconds (0.)),
141  MakeTimeAccessor (&TapBridge::m_tStop),
142  MakeTimeChecker ())
143  .AddAttribute ("Mode",
144  "The operating and configuration mode to use.",
146  MakeEnumAccessor (&TapBridge::SetMode),
147  MakeEnumChecker (CONFIGURE_LOCAL, "ConfigureLocal",
148  USE_LOCAL, "UseLocal",
149  USE_BRIDGE, "UseBridge"))
150  ;
151  return tid;
152 }
153 
154 TapBridge::TapBridge ()
155  : m_node (0),
156  m_ifIndex (0),
157  m_sock (-1),
158  m_startEvent (),
159  m_stopEvent (),
160  m_fdReader (0),
161  m_ns3AddressRewritten (false)
162 {
164  m_packetBuffer = new uint8_t[65536];
165  Start (m_tStart);
166 }
167 
168 TapBridge::~TapBridge()
169 {
171 
172  StopTapDevice ();
173 
174  delete [] m_packetBuffer;
175  m_packetBuffer = 0;
176 
177  m_bridgedDevice = 0;
178 }
179 
180 void
182 {
185 }
186 
187 void
189 {
190  NS_LOG_FUNCTION (tStart);
191 
192  //
193  // Cancel any pending start event and schedule a new one at some relative time in the future.
194  //
197 }
198 
199 void
201 {
202  NS_LOG_FUNCTION (tStop);
203  //
204  // Cancel any pending stop event and schedule a new one at some relative time in the future.
205  //
208 }
209 
210 void
212 {
214 
215  NS_ABORT_MSG_IF (m_sock != -1, "TapBridge::StartTapDevice(): Tap is already started");
216 
217  //
218  // A similar story exists for the node ID. We can't just naively do a
219  // GetNode ()->GetId () since GetNode is going to give us a Ptr<Node> which
220  // is reference counted. We need to stash away the node ID for use in the
221  // read thread.
222  //
223  m_nodeId = GetNode ()->GetId ();
224 
225  //
226  // Spin up the tap bridge and start receiving packets.
227  //
228  NS_LOG_LOGIC ("Creating tap device");
229 
230  //
231  // Call out to a separate process running as suid root in order to get the
232  // tap device allocated and set up. We do this to avoid having the entire
233  // simulation running as root. If this method returns, we'll have a socket
234  // waiting for us in m_sock that we can use to talk to the newly created
235  // tap device.
236  //
237  CreateTap ();
238 
239  //
240  // Now spin up a read thread to read packets from the tap device.
241  //
242  NS_ABORT_MSG_IF (m_fdReader != 0,"TapBridge::StartTapDevice(): Receive thread is already running");
243  NS_LOG_LOGIC ("Spinning up read thread");
244 
245  m_fdReader = Create<TapBridgeFdReader> ();
247 }
248 
249 void
251 {
253 
254  if (m_fdReader != 0)
255  {
256  m_fdReader->Stop ();
257  m_fdReader = 0;
258  }
259 
260  if (m_sock != -1)
261  {
262  close (m_sock);
263  m_sock = -1;
264  }
265 }
266 
267 void
269 {
271 
272  //
273  // The TapBridge has three distinct operating modes. At this point, the
274  // differences revolve around who is responsible for creating and configuring
275  // the underlying network tap that we use. In ConfigureLocal mode, the
276  // TapBridge has the responsibility for creating and configuring the TAP.
277  //
278  // In UseBridge or UseLocal modes, the user will provide us a configuration
279  // and we have to adapt to it. For example, in UseLocal mode, the user will
280  // be configuring a tap device outside the scope of the ns-3 simulation and
281  // will be expecting us to work with it. The user will do something like:
282  //
283  // sudo tunctl -t tap0
284  // sudo ifconfig tap0 hw ether 00:00:00:00:00:01
285  // sudo ifconfig tap0 10.1.1.1 netmask 255.255.255.0 up
286  //
287  // The user will then set the "Mode" Attribute of the TapBridge to "UseLocal"
288  // and the "DeviceName" Attribute to "tap0" in this case.
289  //
290  // In ConfigureLocal mode, the user is asking the TapBridge to do the
291  // configuration and create a TAP with the provided "DeviceName" with which
292  // the user can later do what she wants. We need to extract values for the
293  // MAC address, IP address, net mask, etc, from the simualtion itself and
294  // use them to initialize corresponding values on the created tap device.
295  //
296  // In UseBridge mode, the user is asking us to use an existing tap device
297  // has been included in an OS bridge. She is asking us to take the simulated
298  // net device and logically add it to the existing bridge. We expect that
299  // the user has done something like:
300  //
301  // sudo brctl addbr mybridge
302  // sudo tunctl -t mytap
303  // sudo ifconfig mytap hw ether 00:00:00:00:00:01
304  // sudo ifconfig mytap 0.0.0.0 up
305  // sudo brctl addif mybridge mytap
306  // sudo brctl addif mybridge ...
307  // sudo ifconfig mybridge 10.1.1.1 netmask 255.255.255.0 up
308  //
309  // The bottom line at this point is that we want to either create or use a
310  // tap device on the host based on the verb part "Use" or "Configure" of the
311  // operating mode. Unfortunately for us you have to have root privileges to
312  // do either. Instead of running the entire simulation as root, we decided
313  // to make a small program who's whole reason for being is to run as suid
314  // root and do what it takes to create the tap. We're just going to pass
315  // off the configuration information to that program and let it deal with
316  // the situation.
317  //
318  // We're going to fork and exec that program soon, but first we need to have
319  // a socket to talk to it with. So we create a local interprocess (Unix)
320  // socket for that purpose.
321  //
322  int sock = socket (PF_UNIX, SOCK_DGRAM, 0);
323  NS_ABORT_MSG_IF (sock == -1, "TapBridge::CreateTap(): Unix socket creation error, errno = " << std::strerror (errno));
324 
325  //
326  // Bind to that socket and let the kernel allocate an endpoint
327  //
328  struct sockaddr_un un;
329  memset (&un, 0, sizeof (un));
330  un.sun_family = AF_UNIX;
331  int status = bind (sock, (struct sockaddr*)&un, sizeof (sa_family_t));
332  NS_ABORT_MSG_IF (status == -1, "TapBridge::CreateTap(): Could not bind(): errno = " << std::strerror (errno));
333  NS_LOG_INFO ("Created Unix socket");
334  NS_LOG_INFO ("sun_family = " << un.sun_family);
335  NS_LOG_INFO ("sun_path = " << un.sun_path);
336 
337  //
338  // We have a socket here, but we want to get it there -- to the program we're
339  // going to exec. What we'll do is to do a getsockname and then encode the
340  // resulting address information as a string, and then send the string to the
341  // program as an argument. So we need to get the sock name.
342  //
343  socklen_t len = sizeof (un);
344  status = getsockname (sock, (struct sockaddr*)&un, &len);
345  NS_ABORT_MSG_IF (status == -1, "TapBridge::CreateTap(): Could not getsockname(): errno = " << std::strerror (errno));
346 
347  //
348  // Now encode that socket name (family and path) as a string of hex digits
349  //
350  std::string path = TapBufferToString ((uint8_t *)&un, len);
351  NS_LOG_INFO ("Encoded Unix socket as \"" << path << "\"");
352 
353  //
354  // Tom Goff reports the possiblility of a deadlock when trying to acquire the
355  // python GIL here. He says that this might be due to trying to access Python
356  // objects after fork() without calling PyOS_AfterFork() to properly reset
357  // Python state (including the GIL). Originally these next three lines were
358  // done after the fork, but were moved here to work around the deadlock.
359  //
361  Ptr<Node> n = nd->GetNode ();
362  Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> ();
363 
364  //
365  // Fork and exec the process to create our socket. If we're us (the parent)
366  // we wait for the child (the creator) to complete and read the socket it
367  // created and passed back using the ancillary data mechanism.
368  //
369  pid_t pid = ::fork ();
370  if (pid == 0)
371  {
372  NS_LOG_DEBUG ("Child process");
373 
374  //
375  // build a command line argument from the encoded endpoint string that
376  // the socket creation process will use to figure out how to respond to
377  // the (now) parent process. We're going to have to give this program
378  // quite a bit of information.
379  //
380  // -d<device-name> The name of the tap device we want to create;
381  // -g<gateway-address> The IP address to use as the default gateway;
382  // -i<IP-address> The IP address to assign to the new tap device;
383  // -m<MAC-address> The MAC-48 address to assign to the new tap device;
384  // -n<network-mask> The network mask to assign to the new tap device;
385  // -o<operating mode> The operating mode of the bridge (1=ConfigureLocal, 2=UseLocal, 3=UseBridge)
386  // -p<path> the path to the unix socket described above.
387  //
388  // Example tap-creator -dnewdev -g1.2.3.2 -i1.2.3.1 -m08:00:2e:00:01:23 -n255.255.255.0 -o1 -pblah
389  //
390  // We want to get as much of this stuff automagically as possible.
391  //
392  // For CONFIGURE_LOCAL mode only:
393  // <IP-address> is the IP address we are going to set in the newly
394  // created Tap device on the Linux host. At the point in the simulation
395  // where devices are coming up, we should have all of our IP addresses
396  // assigned. That means that we can find the IP address to assign to
397  // the new Tap device from the IP address associated with the bridged
398  // net device.
399  //
400 
401  bool wantIp = (m_mode == CONFIGURE_LOCAL);
402 
403  if (wantIp
404  && (ipv4 == 0)
405  && m_tapIp.IsBroadcast ()
407  {
408  NS_FATAL_ERROR ("TapBridge::CreateTap(): Tap device IP configuration requested but neither IP address nor IP netmask is provided");
409  }
410 
411  // Some stub values to make tap-creator happy
412  Ipv4Address ipv4Address ("255.255.255.255");
413  Ipv4Mask ipv4Mask ("255.255.255.255");
414 
415  if (ipv4 != 0)
416  {
417  uint32_t index = ipv4->GetInterfaceForDevice (nd);
418  if (ipv4->GetNAddresses (index) > 1)
419  {
420  NS_LOG_WARN ("Underlying bridged NetDevice has multiple IP addresses; using first one.");
421  }
422  ipv4Address = ipv4->GetAddress (index, 0).GetLocal ();
423 
424  //
425  // The net mask is sitting right there next to the ipv4 address.
426  //
427  ipv4Mask = ipv4->GetAddress (index, 0).GetMask ();
428  }
429 
430  //
431  // The MAC address should also already be assigned and waiting for us in
432  // the bridged net device.
433  //
434  Address address = nd->GetAddress ();
435  Mac48Address mac48Address = Mac48Address::ConvertFrom (address);
436 
437  //
438  // The device-name is something we may want the system to make up in
439  // every case. We also rely on it being configured via an Attribute
440  // through the helper. By default, it is set to the empty string
441  // which tells the system to make up a device name such as "tap123".
442  //
443  std::ostringstream ossDeviceName;
444  ossDeviceName << "-d" << m_tapDeviceName;
445 
446  //
447  // The gateway-address is something we can't derive, so we rely on it
448  // being configured via an Attribute through the helper.
449  //
450  std::ostringstream ossGateway;
451  ossGateway << "-g" << m_tapGateway;
452 
453  //
454  // For flexibility, we do allow a client to override any of the values
455  // above via attributes, so only use our found values if the Attribute
456  // is not equal to its default value (empty string or broadcast address).
457  //
458  std::ostringstream ossIp;
459  if (m_tapIp.IsBroadcast ())
460  {
461  ossIp << "-i" << ipv4Address;
462  }
463  else
464  {
465  ossIp << "-i" << m_tapIp;
466  }
467 
468  std::ostringstream ossMac;
469  if (m_tapMac.IsBroadcast ())
470  {
471  ossMac << "-m" << mac48Address;
472  }
473  else
474  {
475  ossMac << "-m" << m_tapMac;
476  }
477 
478  std::ostringstream ossNetmask;
480  {
481  ossNetmask << "-n" << ipv4Mask;
482  }
483  else
484  {
485  ossNetmask << "-n" << m_tapNetmask;
486  }
487 
488  std::ostringstream ossMode;
489  ossMode << "-o";
490  if (m_mode == CONFIGURE_LOCAL)
491  {
492  ossMode << "1";
493  }
494  else if (m_mode == USE_LOCAL)
495  {
496  ossMode << "2";
497  }
498  else
499  {
500  ossMode << "3";
501  }
502 
503  std::ostringstream ossPath;
504  ossPath << "-p" << path;
505  //
506  // Execute the socket creation process image.
507  //
508  status = ::execlp (TAP_CREATOR,
509  TAP_CREATOR, // argv[0] (filename)
510  ossDeviceName.str ().c_str (), // argv[1] (-d<device name>)
511  ossGateway.str ().c_str (), // argv[2] (-g<gateway>)
512  ossIp.str ().c_str (), // argv[3] (-i<IP address>)
513  ossMac.str ().c_str (), // argv[4] (-m<MAC address>)
514  ossNetmask.str ().c_str (), // argv[5] (-n<net mask>)
515  ossMode.str ().c_str (), // argv[6] (-o<operating mode>)
516  ossPath.str ().c_str (), // argv[7] (-p<path>)
517  (char *)NULL);
518 
519  //
520  // If the execlp successfully completes, it never returns. If it returns it failed or the OS is
521  // broken. In either case, we bail.
522  //
523  NS_FATAL_ERROR ("TapBridge::CreateTap(): Back from execlp(), errno = " << ::strerror (errno));
524  }
525  else
526  {
527  NS_LOG_DEBUG ("Parent process");
528  //
529  // We're the process running the emu net device. We need to wait for the
530  // socket creator process to finish its job.
531  //
532  int st;
533  pid_t waited = waitpid (pid, &st, 0);
534  NS_ABORT_MSG_IF (waited == -1, "TapBridge::CreateTap(): waitpid() fails, errno = " << std::strerror (errno));
535  NS_ASSERT_MSG (pid == waited, "TapBridge::CreateTap(): pid mismatch");
536 
537  //
538  // Check to see if the socket creator exited normally and then take a
539  // look at the exit code. If it bailed, so should we. If it didn't
540  // even exit normally, we bail too.
541  //
542  if (WIFEXITED (st))
543  {
544  int exitStatus = WEXITSTATUS (st);
545  NS_ABORT_MSG_IF (exitStatus != 0,
546  "TapBridge::CreateTap(): socket creator exited normally with status " << exitStatus);
547  }
548  else
549  {
550  NS_FATAL_ERROR ("TapBridge::CreateTap(): socket creator exited abnormally");
551  }
552 
553  //
554  // At this point, the socket creator has run successfully and should
555  // have created our tap device, initialized it with the information we
556  // passed and sent it back to the socket address we provided. A socket
557  // (fd) we can use to talk to this tap device should be waiting on the
558  // Unix socket we set up to receive information back from the creator
559  // program. We've got to do a bunch of grunt work to get at it, though.
560  //
561  // The struct iovec below is part of a scatter-gather list. It describes a
562  // buffer. In this case, it describes a buffer (an integer) that will
563  // get the data that comes back from the socket creator process. It will
564  // be a magic number that we use as a consistency/sanity check.
565  //
566  struct iovec iov;
567  uint32_t magic;
568  iov.iov_base = &magic;
569  iov.iov_len = sizeof(magic);
570 
571  //
572  // The CMSG macros you'll see below are used to create and access control
573  // messages (which is another name for ancillary data). The ancillary
574  // data is made up of pairs of struct cmsghdr structures and associated
575  // data arrays.
576  //
577  // First, we're going to allocate a buffer on the stack to receive our
578  // data array (that contains the socket). Sometimes you'll see this called
579  // an "ancillary element" but the msghdr uses the control message termimology
580  // so we call it "control."
581  //
582  size_t msg_size = sizeof(int);
583  char control[CMSG_SPACE (msg_size)];
584 
585  //
586  // There is a msghdr that is used to minimize the number of parameters
587  // passed to recvmsg (which we will use to receive our ancillary data).
588  // This structure uses terminology corresponding to control messages, so
589  // you'll see msg_control, which is the pointer to the ancillary data and
590  // controllen which is the size of the ancillary data array.
591  //
592  // So, initialize the message header that describes the ancillary/control
593  // data we expect to receive and point it to buffer.
594  //
595  struct msghdr msg;
596  msg.msg_name = 0;
597  msg.msg_namelen = 0;
598  msg.msg_iov = &iov;
599  msg.msg_iovlen = 1;
600  msg.msg_control = control;
601  msg.msg_controllen = sizeof (control);
602  msg.msg_flags = 0;
603 
604  //
605  // Now we can actually receive the interesting bits from the tap
606  // creator process. Lots of pain to get four bytes.
607  //
608  ssize_t bytesRead = recvmsg (sock, &msg, 0);
609  NS_ABORT_MSG_IF (bytesRead != sizeof(int), "TapBridge::CreateTap(): Wrong byte count from socket creator");
610 
611  //
612  // There may be a number of message headers/ancillary data arrays coming in.
613  // Let's look for the one with a type SCM_RIGHTS which indicates it's the
614  // one we're interested in.
615  //
616  struct cmsghdr *cmsg;
617  for (cmsg = CMSG_FIRSTHDR (&msg); cmsg != NULL; cmsg = CMSG_NXTHDR (&msg, cmsg))
618  {
619  if (cmsg->cmsg_level == SOL_SOCKET &&
620  cmsg->cmsg_type == SCM_RIGHTS)
621  {
622  //
623  // This is the type of message we want. Check to see if the magic
624  // number is correct and then pull out the socket we care about if
625  // it matches
626  //
627  if (magic == TAP_MAGIC)
628  {
629  NS_LOG_INFO ("Got SCM_RIGHTS with correct magic " << magic);
630  int *rawSocket = (int*)CMSG_DATA (cmsg);
631  NS_LOG_INFO ("Got the socket from the socket creator = " << *rawSocket);
632  m_sock = *rawSocket;
633  return;
634  }
635  else
636  {
637  NS_LOG_INFO ("Got SCM_RIGHTS, but with bad magic " << magic);
638  }
639  }
640  }
641  NS_FATAL_ERROR ("Did not get the raw socket from the socket creator");
642  }
643 }
644 
645 void
646 TapBridge::ReadCallback (uint8_t *buf, ssize_t len)
647 {
649 
650  NS_ASSERT_MSG (buf != 0, "invalid buf argument");
651  NS_ASSERT_MSG (len > 0, "invalid len argument");
652 
653  //
654  // It's important to remember that we're in a completely different thread
655  // than the simulator is running in. We need to synchronize with that
656  // other thread to get the packet up into ns-3. What we will need to do
657  // is to schedule a method to deal with the packet using the multithreaded
658  // simulator we are most certainly running. However, I just said it -- we
659  // are talking about two threads here, so it is very, very dangerous to do
660  // any kind of reference counting on a shared object. Just don't do it.
661  // So what we're going to do is pass the buffer allocated on the heap
662  // into the ns-3 context thread where it will create the packet.
663  //
664 
665  NS_LOG_INFO ("TapBridge::ReadCallback(): Received packet on node " << m_nodeId);
666  NS_LOG_INFO ("TapBridge::ReadCallback(): Scheduling handler");
667  Simulator::ScheduleWithContext (m_nodeId, Seconds (0.0), MakeEvent (&TapBridge::ForwardToBridgedDevice, this, buf, len));
668 }
669 
670 void
671 TapBridge::ForwardToBridgedDevice (uint8_t *buf, ssize_t len)
672 {
673  NS_LOG_FUNCTION (buf << len);
674 
675  //
676  // There are three operating modes for the TapBridge
677  //
678  // CONFIGURE_LOCAL means that ns-3 will create and configure a tap device
679  // and we are expected to use it. The tap device and the ns-3 net device
680  // will have the same MAC address by definition. Thus Send and SendFrom
681  // are equivalent in this case. We use Send to allow all ns-3 devices to
682  // participate in this mode.
683  //
684  // USE_LOCAL mode tells us that we have got to USE a pre-created tap device
685  // that will have a different MAC address from the ns-3 net device. We
686  // also enforce the requirement that there will only be one MAC address
687  // bridged on the Linux side so we can use Send (instead of SendFrom) in
688  // the linux to ns-3 direction. Again, all ns-3 devices can participate
689  // in this mode.
690  //
691  // USE_BRIDGE mode tells us that we are logically extending a Linux bridge
692  // on which lies our tap device. In this case there may be many linux
693  // net devices on the other side of the bridge and so we must use SendFrom
694  // to preserve the possibly many source addresses. Thus, ns-3 devices
695  // must support SendFrom in order to be considered for USE_BRIDGE mode.
696  //
697 
698  //
699  // First, create a packet out of the byte buffer we received and free that
700  // buffer.
701  //
702  Ptr<Packet> packet = Create<Packet> (reinterpret_cast<const uint8_t *> (buf), len);
703  std::free (buf);
704  buf = 0;
705 
706  //
707  // Make sure the packet we received is reasonable enough for the rest of the
708  // system to handle and get it ready to be injected directly into an ns-3
709  // device. What should come back is a packet with the Ethernet header
710  // (and possibly an LLC header as well) stripped off.
711  //
712  Address src, dst;
713  uint16_t type;
714 
715  NS_LOG_LOGIC ("Received packet from tap device");
716 
717  Ptr<Packet> p = Filter (packet, &src, &dst, &type);
718  if (p == 0)
719  {
720  NS_LOG_LOGIC ("TapBridge::ForwardToBridgedDevice: Discarding packet as unfit for ns-3 consumption");
721  return;
722  }
723 
724  NS_LOG_LOGIC ("Pkt source is " << src);
725  NS_LOG_LOGIC ("Pkt destination is " << dst);
726  NS_LOG_LOGIC ("Pkt LengthType is " << type);
727  if (m_mode == USE_LOCAL)
728  {
729  //
730  // Packets we are going to forward should not be from a broadcast src
731  //
732  NS_ASSERT_MSG (Mac48Address::ConvertFrom (src) != Mac48Address ("ff:ff:ff:ff:ff:ff"),
733  "TapBridge::ForwardToBridgedDevice: Source addr is broadcast");
734  if (m_ns3AddressRewritten == false)
735  {
736  //
737  // Set the ns-3 device's mac address to the overlying container's
738  // mac address
739  //
740  Mac48Address learnedMac = Mac48Address::ConvertFrom (src);
741  NS_LOG_LOGIC ("Learned MacAddr is " << learnedMac << ": setting ns-3 device to use this address");
742  m_bridgedDevice->SetAddress (Mac48Address::ConvertFrom (learnedMac));
743  m_ns3AddressRewritten = true;
744  }
745  //
746  // If we are operating in USE_LOCAL mode, we may be attached to an ns-3
747  // device that does not support bridging (SupportsSendFrom returns false).
748  // But, since the mac addresses are now aligned, we can call Send()
749  //
750  NS_LOG_LOGIC ("Forwarding packet to ns-3 device via Send()");
751  m_bridgedDevice->Send (packet, dst, type);
752  return;
753  }
754 
755  //
756  // If we are operating in USE_BRIDGE mode, we have the
757  // situation described below:
758  //
759  // Other Device <-bridge-> Tap Device <-bridge-> ns3 device
760  // Mac Addr A Mac Addr B Mac Addr C
761  //
762  // In Linux, "Other Device" and "Tap Device" are bridged together. By this
763  // we mean that a user has sone something in Linux like:
764  //
765  // brctl addbr mybridge
766  // brctl addif other-device
767  // brctl addif tap-device
768  //
769  // In USE_BRIDGE mode, we want to logically extend this Linux behavior to the
770  // simulated ns3 device and make it appear as if it is connected to the Linux
771  // subnet. As you may expect, this means that we need to act like a real
772  // Linux bridge and take all packets that come from "Tap Device" and ask
773  // "ns3 Device" to send them down its directly connected network. Just like
774  // in a normal everyday bridge we need to call SendFrom in order to preserve
775  //the original packet's from address.
776  //
777  // If we are operating in CONFIGURE_LOCAL mode, we simply simply take all packets
778  // that come from "Tap Device" and ask "ns3 Device" to send them down its
779  // directly connected network. A normal bridge would need to call SendFrom
780  // in order to preserve the original from address, but in CONFIGURE_LOCAL mode
781  // the tap device and the ns-3 device have the same MAC address by definition so
782  // we can call Send.
783  //
784  NS_LOG_LOGIC ("Forwarding packet");
785 
786  if (m_mode == USE_BRIDGE)
787  {
788  m_bridgedDevice->SendFrom (packet, src, dst, type);
789  }
790  else
791  {
792  NS_ASSERT_MSG (m_mode == CONFIGURE_LOCAL, "TapBridge::ForwardToBridgedDevice(): Internal error");
793  m_bridgedDevice->Send (packet, dst, type);
794  }
795 }
796 
797 Ptr<Packet>
798 TapBridge::Filter (Ptr<Packet> p, Address *src, Address *dst, uint16_t *type)
799 {
800  NS_LOG_FUNCTION (p);
801  uint32_t pktSize;
802 
803  //
804  // We have a candidate packet for injection into ns-3. We expect that since
805  // it came over a socket that provides Ethernet packets, it should be big
806  // enough to hold an EthernetHeader. If it can't, we signify the packet
807  // should be filtered out by returning 0.
808  //
809  pktSize = p->GetSize ();
810  EthernetHeader header (false);
811  if (pktSize < header.GetSerializedSize ())
812  {
813  return 0;
814  }
815 
816  p->RemoveHeader (header);
817 
818  NS_LOG_LOGIC ("Pkt source is " << header.GetSource ());
819  NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ());
820  NS_LOG_LOGIC ("Pkt LengthType is " << header.GetLengthType ());
821 
822  //
823  // If the length/type is less than 1500, it corresponds to a length
824  // interpretation packet. In this case, it is an 802.3 packet and
825  // will also have an 802.2 LLC header. If greater than 1500, we
826  // find the protocol number (Ethernet type) directly.
827  //
828  if (header.GetLengthType () <= 1500)
829  {
830  *src = header.GetSource ();
831  *dst = header.GetDestination ();
832 
833  pktSize = p->GetSize ();
834  LlcSnapHeader llc;
835  if (pktSize < llc.GetSerializedSize ())
836  {
837  return 0;
838  }
839 
840  p->RemoveHeader (llc);
841  *type = llc.GetType ();
842  }
843  else
844  {
845  *src = header.GetSource ();
846  *dst = header.GetDestination ();
847  *type = header.GetLengthType ();
848  }
849 
850  //
851  // What we give back is a packet without the Ethernet header (nor the
852  // possible llc/snap header) on it. We think it is ready to send on
853  // out the bridged net device.
854  //
855  return p;
856 }
857 
860 {
862  return m_bridgedDevice;
863 }
864 
865 void
867 {
868  NS_LOG_FUNCTION (bridgedDevice);
869 
870  NS_ASSERT_MSG (m_node != 0, "TapBridge::SetBridgedDevice: Bridge not installed in a node");
871  NS_ASSERT_MSG (bridgedDevice != this, "TapBridge::SetBridgedDevice: Cannot bridge to self");
872  NS_ASSERT_MSG (m_bridgedDevice == 0, "TapBridge::SetBridgedDevice: Already bridged");
873 
874  if (!Mac48Address::IsMatchingType (bridgedDevice->GetAddress ()))
875  {
876  NS_FATAL_ERROR ("TapBridge::SetBridgedDevice: Device does not support eui 48 addresses: cannot be added to bridge.");
877  }
878 
879  if (m_mode == USE_BRIDGE && !bridgedDevice->SupportsSendFrom ())
880  {
881  NS_FATAL_ERROR ("TapBridge::SetBridgedDevice: Device does not support SendFrom: cannot be added to bridge.");
882  }
883 
884  //
885  // We need to disconnect the bridged device from the internet stack on our
886  // node to ensure that only one stack responds to packets inbound over the
887  // bridged device. That one stack lives outside ns-3 so we just blatantly
888  // steal the device callbacks.
889  //
890  // N.B This can be undone if someone does a RegisterProtocolHandler later
891  // on this node.
892  //
893  bridgedDevice->SetReceiveCallback (MakeCallback (&TapBridge::DiscardFromBridgedDevice, this));
894  bridgedDevice->SetPromiscReceiveCallback (MakeCallback (&TapBridge::ReceiveFromBridgedDevice, this));
895  m_bridgedDevice = bridgedDevice;
896 }
897 
898 bool
899 TapBridge::DiscardFromBridgedDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol, const Address &src)
900 {
901  NS_LOG_FUNCTION (device << packet << protocol << src);
902  NS_LOG_LOGIC ("Discarding packet stolen from bridged device " << device);
903  return true;
904 }
905 
906 bool
907 TapBridge::ReceiveFromBridgedDevice (
908  Ptr<NetDevice> device,
909  Ptr<const Packet> packet,
910  uint16_t protocol,
911  const Address &src,
912  const Address &dst,
913  PacketType packetType)
914 {
915  NS_LOG_FUNCTION (device << packet << protocol << src << dst << packetType);
916  NS_ASSERT_MSG (device == m_bridgedDevice, "TapBridge::SetBridgedDevice: Received packet from unexpected device");
917  NS_LOG_DEBUG ("Packet UID is " << packet->GetUid ());
918 
919  //
920  // There are three operating modes for the TapBridge
921  //
922  // CONFIGURE_LOCAL means that ns-3 will create and configure a tap device
923  // and we are expected to use it. The tap device and the ns-3 net device
924  // will have the same MAC address by definition.
925  //
926  // USE_LOCAL mode tells us that we have got to USE a pre-created tap device
927  // that will have a different MAC address from the ns-3 net device. In this
928  // case we will be spoofing the MAC address of a received packet to match
929  // the single allowed address on the Linux side.
930  //
931  // USE_BRIDGE mode tells us that we are logically extending a Linux bridge
932  // on which lies our tap device.
933  //
934 
935  if (m_mode == CONFIGURE_LOCAL && packetType == PACKET_OTHERHOST)
936  {
937  //
938  // We hooked the promiscuous mode protocol handler so we could get the
939  // destination address of the actual packet. This means we will be
940  // getting PACKET_OTHERHOST packets (not broadcast, not multicast, not
941  // unicast to the ns-3 net device, but to some other address). In
942  // CONFIGURE_LOCAL mode we are not interested in these packets since they
943  // don't refer to the single MAC address shared by the ns-3 device and
944  // the TAP device. If, however, we are in USE_LOCAL or USE_BRIDGE mode,
945  // we want to act like a bridge and forward these PACKET_OTHERHOST
946  // packets.
947  //
948  return true;
949  }
950 
951  Mac48Address from = Mac48Address::ConvertFrom (src);
952  Mac48Address to = Mac48Address::ConvertFrom (dst);
953 
954  Ptr<Packet> p = packet->Copy ();
955  EthernetHeader header = EthernetHeader (false);
956  header.SetSource (from);
957  header.SetDestination (to);
958 
959  header.SetLengthType (protocol);
960  p->AddHeader (header);
961 
962  NS_LOG_LOGIC ("Writing packet to Linux host");
963  NS_LOG_LOGIC ("Pkt source is " << header.GetSource ());
964  NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ());
965  NS_LOG_LOGIC ("Pkt LengthType is " << header.GetLengthType ());
966  NS_LOG_LOGIC ("Pkt size is " << p->GetSize ());
967 
968  NS_ASSERT_MSG (p->GetSize () <= 65536, "TapBridge::ReceiveFromBridgedDevice: Packet too big " << p->GetSize ());
969  p->CopyData (m_packetBuffer, p->GetSize ());
970 
971  uint32_t bytesWritten = write (m_sock, m_packetBuffer, p->GetSize ());
972  NS_ABORT_MSG_IF (bytesWritten != p->GetSize (), "TapBridge::ReceiveFromBridgedDevice(): Write error.");
973 
974  NS_LOG_LOGIC ("End of receive packet handling on node " << m_node->GetId ());
975  return true;
976 }
977 
978 void
979 TapBridge::SetIfIndex (const uint32_t index)
980 {
982  m_ifIndex = index;
983 }
984 
985 uint32_t
987 {
989  return m_ifIndex;
990 }
991 
994 {
996  return 0;
997 }
998 
999 void
1001 {
1002  NS_LOG_FUNCTION (address);
1004 }
1005 
1006 Address
1008 {
1010  return m_address;
1011 }
1012 
1013 void
1015 {
1016  NS_LOG_FUNCTION (mode);
1017  m_mode = mode;
1018 }
1019 
1022 {
1024  return m_mode;
1025 }
1026 
1027 bool
1028 TapBridge::SetMtu (const uint16_t mtu)
1029 {
1031  m_mtu = mtu;
1032  return true;
1033 }
1034 
1035 uint16_t
1036 TapBridge::GetMtu (void) const
1037 {
1039  return m_mtu;
1040 }
1041 
1042 
1043 bool
1045 {
1047  return true;
1048 }
1049 
1050 void
1052 {
1054 }
1055 
1056 bool
1058 {
1060  return true;
1061 }
1062 
1063 Address
1065 {
1067  return Mac48Address ("ff:ff:ff:ff:ff:ff");
1068 }
1069 
1070 bool
1072 {
1074  return true;
1075 }
1076 
1077 Address
1078 TapBridge::GetMulticast (Ipv4Address multicastGroup) const
1079 {
1080  NS_LOG_FUNCTION (this << multicastGroup);
1081  Mac48Address multicast = Mac48Address::GetMulticast (multicastGroup);
1082  return multicast;
1083 }
1084 
1085 bool
1087 {
1089  return false;
1090 }
1091 
1092 bool
1094 {
1096  //
1097  // Returning false from IsBridge in a device called TapBridge may seem odd
1098  // at first glance, but this test is for a device that bridges ns-3 devices
1099  // together. The Tap bridge doesn't do that -- it bridges an ns-3 device to
1100  // a Linux device. This is a completely different story.
1101  //
1102  return false;
1103 }
1104 
1105 bool
1106 TapBridge::Send (Ptr<Packet> packet, const Address& dst, uint16_t protocol)
1107 {
1108  NS_LOG_FUNCTION (packet << dst << protocol);
1109  NS_FATAL_ERROR ("TapBridge::Send: You may not call Send on a TapBridge directly");
1110  return false;
1111 }
1112 
1113 bool
1114 TapBridge::SendFrom (Ptr<Packet> packet, const Address& src, const Address& dst, uint16_t protocol)
1115 {
1116  NS_LOG_FUNCTION (packet << src << dst << protocol);
1117  NS_FATAL_ERROR ("TapBridge::Send: You may not call SendFrom on a TapBridge directly");
1118  return false;
1119 }
1120 
1121 Ptr<Node>
1123 {
1125  return m_node;
1126 }
1127 
1128 void
1130 {
1132  m_node = node;
1133 }
1134 
1135 bool
1137 {
1139  return true;
1140 }
1141 
1142 void
1144 {
1146  m_rxCallback = cb;
1147 }
1148 
1149 void
1151 {
1153  m_promiscRxCallback = cb;
1154 }
1155 
1156 bool
1158 {
1160  return true;
1161 }
1162 
1164 {
1165  NS_LOG_FUNCTION (this << addr);
1166  return Mac48Address::GetMulticast (addr);
1167 }
1168 
1169 } // namespace ns3
void Start(int fd, Callback< void, uint8_t *, ssize_t > readCallback)
uint32_t RemoveHeader(Header &header)
Definition: packet.cc:285
static bool IsMatchingType(const Address &address)
EventId m_startEvent
Definition: tap-bridge.h:352
virtual Ptr< Channel > GetChannel(void) const
Definition: tap-bridge.cc:993
Ipv4Address m_tapIp
Definition: tap-bridge.h:422
virtual void DoDispose(void)
Definition: tap-bridge.cc:181
static Ipv4Mask GetOnes(void)
keep track of time unit.
Definition: nstime.h:149
virtual void SetNode(Ptr< Node > node)
Definition: tap-bridge.cc:1129
virtual Ptr< Node > GetNode(void) const
Definition: tap-bridge.cc:1122
A structure representing data read.
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Definition: tap-bridge.cc:1078
void SetBridgedNetDevice(Ptr< NetDevice > bridgedDevice)
Set the ns-3 net device to bridge.
Definition: tap-bridge.cc:866
void SetMode(TapBridge::Mode mode)
Definition: tap-bridge.cc:1014
hold variables of type string
Definition: string.h:19
virtual bool SetMtu(const uint16_t mtu)
Definition: tap-bridge.cc:1028
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:210
void StartTapDevice(void)
Definition: tap-bridge.cc:211
void Start(Time tStart)
Set a start time for the device.
Definition: tap-bridge.cc:188
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
uint16_t GetLengthType(void) const
EventId m_stopEvent
Definition: tap-bridge.h:360
uint32_t GetSize(void) const
Definition: packet.h:620
bool IsBroadcast(void) const
virtual void DoDispose(void)
Definition: object.cc:335
Mac48Address m_tapMac
Definition: tap-bridge.h:432
#define NS_LOG_INFO(msg)
Definition: log.h:264
static void Cancel(const EventId &id)
Definition: simulator.cc:267
#define NS_LOG_FUNCTION_NOARGS()
Definition: log.h:275
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Definition: simulator.h:820
void Stop(Time tStop)
Definition: tap-bridge.cc:200
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
a polymophic address class
Definition: address.h:86
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
Definition: tap-bridge.cc:1086
void CreateTap(void)
Definition: tap-bridge.cc:268
std::string TapBufferToString(uint8_t *buffer, uint32_t len)
Convert a byte buffer to a string containing a hex representation of the buffer. Make the string pret...
uint8_t * m_packetBuffer
Definition: tap-bridge.h:458
virtual void AddLinkChangeCallback(Callback< void > callback)
Definition: tap-bridge.cc:1051
virtual void SetIfIndex(const uint32_t index)
Definition: tap-bridge.cc:979
hold variables of type 'enum'
Definition: enum.h:37
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
Definition: tap-bridge.cc:1093
static Mac48Address GetMulticast(Ipv4Address address)
hold objects of type ns3::Time
Definition: nstime.h:700
int m_fd
The file descriptor to read from.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Definition: tap-bridge.cc:1106
Hold an unsigned integer type.
Definition: uinteger.h:46
A bridge to make it appear that a real host process is connected to an ns-3 net device.
Definition: tap-bridge.h:103
Ptr< NetDevice > GetBridgedNetDevice(void)
Get the bridged net device.
Definition: tap-bridge.cc:859
bool IsBroadcast(void) const
FdReader::Data DoRead(void)
The read implementation.
Definition: tap-bridge.cc:69
uint32_t m_ifIndex
Definition: tap-bridge.h:329
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Definition: tap-bridge.cc:1114
virtual uint16_t GetMtu(void) const
Definition: tap-bridge.cc:1036
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:502
virtual bool NeedsArp(void) const
Definition: tap-bridge.cc:1136
void StopTapDevice(void)
Definition: tap-bridge.cc:250
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
Definition: simulator.h:900
#define NS_LOG_LOGIC(msg)
Definition: log.h:334
Ptr< NetDevice > m_bridgedDevice
Definition: tap-bridge.h:446
virtual void SetAddress(Address address)
Definition: tap-bridge.cc:1000
static Mac48Address ConvertFrom(const Address &address)
void ReadCallback(uint8_t *buf, ssize_t len)
Definition: tap-bridge.cc:646
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:75
Ptr< Packet > Copy(void) const
Definition: packet.cc:131
std::string m_tapDeviceName
Definition: tap-bridge.h:408
Ptr< Node > m_node
Definition: tap-bridge.h:321
Ptr< TapBridgeFdReader > m_fdReader
Definition: tap-bridge.h:368
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Definition: tap-bridge.h:314
Ipv4Address m_tapGateway
Definition: tap-bridge.h:415
an EUI-48 address
Definition: mac48-address.h:41
bool m_ns3AddressRewritten
Definition: tap-bridge.h:453
Packet header for Ethernet.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Definition: tap-bridge.cc:1143
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
Definition: tap-bridge.cc:1150
virtual Address GetAddress(void) const
Definition: tap-bridge.cc:1007
hold objects of type ns3::Ipv4Address
virtual Address GetBroadcast(void) const
Definition: tap-bridge.cc:1064
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
Mac48Address m_address
Definition: tap-bridge.h:386
Mac48Address GetSource(void) const
Describes an IPv6 address.
Definition: ipv6-address.h:44
Ptr< Packet > Filter(Ptr< Packet > packet, Address *src, Address *dst, uint16_t *type)
Definition: tap-bridge.cc:798
Mac48Address GetDestination(void) const
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
TapBridge::Mode GetMode(void)
Definition: tap-bridge.cc:1021
virtual bool IsMulticast(void) const
Definition: tap-bridge.cc:1071
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition: nstime.h:586
uint32_t GetId(void) const
Definition: node.cc:105
virtual bool IsLinkUp(void) const
Definition: tap-bridge.cc:1044
Network layer to device interface.
Definition: net-device.h:75
#define NS_LOG_WARN(msg)
Definition: log.h:246
hold objects of type ns3::Mac48Address
virtual uint32_t GetSerializedSize(void) const
bool IsEqual(Ipv4Mask other) const
Definition: ipv4-address.cc:99
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
hold objects of type ns3::Ipv4Mask
virtual uint32_t GetSerializedSize(void) const
Ipv4Mask m_tapNetmask
Definition: tap-bridge.h:439
virtual uint32_t GetIfIndex(void) const
Definition: tap-bridge.cc:986
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if cond is true.
Definition: abort.h:98
virtual bool IsBroadcast(void) const
Definition: tap-bridge.cc:1057
uint16_t m_mtu
Definition: tap-bridge.h:336
Ptr< T > GetObject(void) const
Definition: object.h:332
a unique identifier for an interface.
Definition: type-id.h:44
NetDevice::ReceiveCallback m_rxCallback
Definition: tap-bridge.h:301
TypeId SetParent(TypeId tid)
Definition: type-id.cc:471
virtual bool SupportsSendFrom() const
Definition: tap-bridge.cc:1157
Header for the LLC/SNAP encapsulation.