A Discrete-Event Network Simulator
API
packet-socket.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 Emmanuelle Laprise, INRIA
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  * Authors: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
19  * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  */
21 
22 #include "packet-socket.h"
23 #include "packet-socket-address.h"
24 #include "ns3/log.h"
25 #include "ns3/node.h"
26 #include "ns3/packet.h"
27 #include "ns3/uinteger.h"
28 #include "ns3/trace-source-accessor.h"
29 
30 #include <algorithm>
31 
32 namespace ns3 {
33 
34 NS_LOG_COMPONENT_DEFINE ("PacketSocket");
35 
36 NS_OBJECT_ENSURE_REGISTERED (PacketSocket);
37 
38 TypeId
40 {
41  static TypeId tid = TypeId ("ns3::PacketSocket")
42  .SetParent<Socket> ()
43  .SetGroupName("Network")
44  .AddConstructor<PacketSocket> ()
45  .AddTraceSource ("Drop", "Drop packet due to receive buffer overflow",
47  "ns3::Packet::TracedCallback")
48  .AddAttribute ("RcvBufSize",
49  "PacketSocket maximum receive buffer size (bytes)",
50  UintegerValue (131072),
52  MakeUintegerChecker<uint32_t> ())
53  ;
54  return tid;
55 }
56 
58 {
59  NS_LOG_FUNCTION (this);
61  m_shutdownSend = false;
62  m_shutdownRecv = false;
64  m_isSingleDevice = false;
65  m_device = 0;
66 }
67 
68 void
70 {
71  NS_LOG_FUNCTION (this << node);
72  m_node = node;
73 }
74 
76 {
77  NS_LOG_FUNCTION (this);
78 }
79 
80 void
82 {
83  NS_LOG_FUNCTION (this);
84  m_device = 0;
85 }
86 
89 {
90  NS_LOG_FUNCTION (this);
91  return m_errno;
92 }
93 
96 {
97  NS_LOG_FUNCTION (this);
98  return NS3_SOCK_RAW;
99 }
100 
101 Ptr<Node>
103 {
104  NS_LOG_FUNCTION (this);
105  return m_node;
106 }
107 
108 int
110 {
111  NS_LOG_FUNCTION (this);
113  address.SetProtocol (0);
114  address.SetAllDevices ();
115  return DoBind (address);
116 }
117 
118 int
120 {
121  NS_LOG_FUNCTION (this);
122  return(Bind());
123 }
124 
125 int
127 {
128  NS_LOG_FUNCTION (this << address);
130  {
132  return -1;
133  }
135  return DoBind (ad);
136 }
137 
138 int
140 {
141  NS_LOG_FUNCTION (this << address);
142  if (m_state == STATE_BOUND ||
144  {
146  return -1;
147  }
148  if (m_state == STATE_CLOSED)
149  {
151  return -1;
152  }
153  Ptr<NetDevice> dev;
154  if (address.IsSingleDevice ())
155  {
156  dev = m_node->GetDevice (address.GetSingleDevice ());
157  }
158  else
159  {
160  dev = 0;
161  }
163  address.GetProtocol (), dev);
165  m_protocol = address.GetProtocol ();
166  m_isSingleDevice = address.IsSingleDevice ();
167  m_device = address.GetSingleDevice ();
168  m_boundnetdevice = dev;
169  return 0;
170 }
171 
172 int
174 {
175  NS_LOG_FUNCTION (this);
176  if (m_state == STATE_CLOSED)
177  {
179  return -1;
180  }
181  m_shutdownSend = true;
182  return 0;
183 }
184 
185 int
187 {
188  NS_LOG_FUNCTION (this);
189  if (m_state == STATE_CLOSED)
190  {
192  return -1;
193  }
194  m_shutdownRecv = true;
195  return 0;
196 }
197 
198 int
200 {
201  NS_LOG_FUNCTION (this);
202  if (m_state == STATE_CLOSED)
203  {
205  return -1;
206  }
207  else if (m_state == STATE_BOUND || m_state == STATE_CONNECTED)
208  {
210  }
212  m_shutdownSend = true;
213  m_shutdownRecv = true;
214  return 0;
215 }
216 
217 int
219 {
220  NS_LOG_FUNCTION (this << ad);
222  if (m_state == STATE_CLOSED)
223  {
225  goto error;
226  }
227  if (m_state == STATE_OPEN)
228  {
229  // connect should happen _after_ bind.
230  m_errno = ERROR_INVAL; // generic error condition.
231  goto error;
232  }
233  if (m_state == STATE_CONNECTED)
234  {
236  goto error;
237  }
239  {
241  goto error;
242  }
243  m_destAddr = ad;
246  return 0;
247 error:
249  return -1;
250 }
251 int
253 {
254  NS_LOG_FUNCTION (this);
256  return -1;
257 }
258 
259 int
260 PacketSocket::Send (Ptr<Packet> p, uint32_t flags)
261 {
262  NS_LOG_FUNCTION (this << p << flags);
263  if (m_state == STATE_OPEN ||
264  m_state == STATE_BOUND)
265  {
267  return -1;
268  }
269  return SendTo (p, flags, m_destAddr);
270 }
271 
272 uint32_t
274 {
275  NS_LOG_FUNCTION (this << ad);
276  if (ad.IsSingleDevice ())
277  {
279  return device->GetMtu ();
280  }
281  else
282  {
283  uint32_t minMtu = 0xffff;
284  for (uint32_t i = 0; i < m_node->GetNDevices (); i++)
285  {
286  Ptr<NetDevice> device = m_node->GetDevice (i);
287  minMtu = std::min (minMtu, (uint32_t)device->GetMtu ());
288  }
289  return minMtu;
290  }
291 }
292 
293 uint32_t
295 {
296  NS_LOG_FUNCTION (this);
297  if (m_state == STATE_CONNECTED)
298  {
300  return GetMinMtu (ad);
301  }
302  // If we are not connected, we return a 'safe' value by default.
303  return 0xffff;
304 }
305 
306 int
307 PacketSocket::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address)
308 {
309  NS_LOG_FUNCTION (this << p << flags << address);
311  if (m_state == STATE_CLOSED)
312  {
313  NS_LOG_LOGIC ("ERROR_BADF");
315  return -1;
316  }
317  if (m_shutdownSend)
318  {
319  NS_LOG_LOGIC ("ERROR_SHUTDOWN");
321  return -1;
322  }
324  {
325  NS_LOG_LOGIC ("ERROR_AFNOSUPPORT");
327  return -1;
328  }
329  ad = PacketSocketAddress::ConvertFrom (address);
330  if (p->GetSize () > GetMinMtu (ad))
331  {
333  return -1;
334  }
335 
336  uint8_t priority = GetPriority ();
337  if (priority)
338  {
339  SocketPriorityTag priorityTag;
340  priorityTag.SetPriority (priority);
341  p->ReplacePacketTag (priorityTag);
342  }
343 
344  bool error = false;
345  Address dest = ad.GetPhysicalAddress ();
346  if (ad.IsSingleDevice ())
347  {
349  if (!device->Send (p, dest, ad.GetProtocol ()))
350  {
351  NS_LOG_LOGIC ("error: NetDevice::Send error");
352  error = true;
353  }
354  }
355  else
356  {
357  for (uint32_t i = 0; i < m_node->GetNDevices (); i++)
358  {
359  Ptr<NetDevice> device = m_node->GetDevice (i);
360  if (!device->Send (p, dest, ad.GetProtocol ()))
361  {
362  NS_LOG_LOGIC ("error: NetDevice::Send error");
363  error = true;
364  }
365  }
366  }
367  if (!error)
368  {
369  NotifyDataSent (p->GetSize ());
371  }
372 
373  if (error)
374  {
375  NS_LOG_LOGIC ("ERROR_INVAL 2");
377  return -1;
378  }
379  else
380  {
381  return p->GetSize ();
382  }
383 }
384 
385 void
387  uint16_t protocol, const Address &from,
388  const Address &to, NetDevice::PacketType packetType)
389 {
390  NS_LOG_FUNCTION (this << device << packet << protocol << from << to << packetType);
391  if (m_shutdownRecv)
392  {
393  return;
394  }
396  address.SetPhysicalAddress (from);
397  address.SetSingleDevice (device->GetIfIndex ());
398  address.SetProtocol (protocol);
399 
400  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
401  {
402  Ptr<Packet> copy = packet->Copy ();
403  DeviceNameTag dnt;
404  dnt.SetDeviceName (device->GetTypeId ().GetName ());
405  PacketSocketTag pst;
406  pst.SetPacketType (packetType);
407  pst.SetDestAddress (to);
408  copy->AddPacketTag (pst); // Attach Packet Type and Dest Address
409  copy->AddPacketTag (dnt); // Attach device source name
410  // in case the packet still has a priority tag, remove it
411  SocketPriorityTag priorityTag;
412  copy->RemovePacketTag (priorityTag);
413  m_deliveryQueue.push (std::make_pair (copy, address));
414  m_rxAvailable += packet->GetSize ();
415  NS_LOG_LOGIC ("UID is " << packet->GetUid () << " PacketSocket " << this);
416  NotifyDataRecv ();
417  }
418  else
419  {
420  // In general, this case should not occur unless the
421  // receiving application reads data from this socket slowly
422  // in comparison to the arrival rate
423  //
424  // drop and trace packet
425  NS_LOG_WARN ("No receive buffer space available. Drop.");
426  m_dropTrace (packet);
427  }
428 }
429 
430 uint32_t
432 {
433  NS_LOG_FUNCTION (this);
434  // We separately maintain this state to avoid walking the queue
435  // every time this might be called
436  return m_rxAvailable;
437 }
438 
440 PacketSocket::Recv (uint32_t maxSize, uint32_t flags)
441 {
442  NS_LOG_FUNCTION (this << maxSize << flags);
443 
444  Address fromAddress;
445  Ptr<Packet> packet = RecvFrom (maxSize, flags, fromAddress);
446  return packet;
447 }
448 
450 PacketSocket::RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)
451 {
452  NS_LOG_FUNCTION (this << maxSize << flags);
453 
454  if (m_deliveryQueue.empty () )
455  {
456  return 0;
457  }
458  Ptr<Packet> p = m_deliveryQueue.front ().first;
459  fromAddress = m_deliveryQueue.front ().second;
460 
461  if (p->GetSize () <= maxSize)
462  {
463  m_deliveryQueue.pop ();
464  m_rxAvailable -= p->GetSize ();
465  }
466  else
467  {
468  p = 0;
469  }
470  return p;
471 }
472 
473 int
475 {
476  NS_LOG_FUNCTION (this << address);
478 
479  ad.SetProtocol (m_protocol);
480  if (m_isSingleDevice)
481  {
483  ad.SetPhysicalAddress (device->GetAddress ());
485  }
486  else
487  {
488  ad.SetPhysicalAddress (Address ());
489  ad.SetAllDevices ();
490  }
491  address = ad;
492 
493  return 0;
494 }
495 
496 int
498 {
499  NS_LOG_FUNCTION (this << address);
500 
501  if (m_state != STATE_CONNECTED)
502  {
504  return -1;
505  }
506 
507  address = m_destAddr;
508 
509  return 0;
510 }
511 
512 bool
513 PacketSocket::SetAllowBroadcast (bool allowBroadcast)
514 {
515  NS_LOG_FUNCTION (this << allowBroadcast);
516  if (allowBroadcast)
517  {
518  return false;
519  }
520  return true;
521 }
522 
523 bool
525 {
526  NS_LOG_FUNCTION (this);
527  return false;
528 }
529 
530 /***************************************************************
531  * PacketSocket Tags
532  ***************************************************************/
533 
535 {
536 }
537 
538 void
540 {
541  m_packetType = t;
542 }
543 
546 {
547  return m_packetType;
548 }
549 
550 void
552 {
553  m_destAddr = a;
554 }
555 
556 Address
558 {
559  return m_destAddr;
560 }
561 
563 
564 TypeId
566 {
567  static TypeId tid = TypeId ("ns3::PacketSocketTag")
568  .SetParent<Tag> ()
569  .SetGroupName("Network")
570  .AddConstructor<PacketSocketTag> ()
571  ;
572  return tid;
573 }
574 TypeId
576 {
577  return GetTypeId ();
578 }
579 uint32_t
581 {
582  return 1 + m_destAddr.GetSerializedSize();
583 }
584 void
586 {
587  i.WriteU8 (m_packetType);
588  m_destAddr.Serialize (i);
589 }
590 void
592 {
593  m_packetType = (NetDevice::PacketType) i.ReadU8 ();
595 }
596 void
597 PacketSocketTag::Print (std::ostream &os) const
598 {
599  os << "packetType=" << m_packetType;
600 }
601 
602 /***************************************************************
603  * DeviceName Tags
604  ***************************************************************/
605 
607 {
608 }
609 
610 void
612 {
613  if ( n.substr(0,5) == "ns3::" )
614  {
615  n = n.substr (5);
616  }
617  m_deviceName = n;
618 }
619 
620 std::string
622 {
623  return m_deviceName;
624 }
625 
627 
628 TypeId
630 {
631  static TypeId tid = TypeId ("ns3::DeviceNameTag")
632  .SetParent<Tag> ()
633  .SetGroupName("Network")
634  .AddConstructor<DeviceNameTag> ();
635  return tid;
636 }
637 TypeId
639 {
640  return GetTypeId ();
641 }
642 uint32_t
644 {
645  uint32_t s = 1 + m_deviceName.size(); // +1 for name length field
646  return s;
647 }
648 void
650 {
651  const char *n = m_deviceName.c_str();
652  uint8_t l = (uint8_t) m_deviceName.size ();
653 
654  i.WriteU8 (l);
655  i.Write ( (uint8_t*) n , (uint32_t) l);
656 }
657 void
659 {
660  uint8_t l = i.ReadU8();
661  char buf[256];
662 
663  i.Read ( (uint8_t* ) buf, (uint32_t) l);
664  m_deviceName = std::string (buf, l);
665 }
666 void
667 DeviceNameTag::Print (std::ostream &os) const
668 {
669  os << "DeviceName=" << m_deviceName;
670 }
671 
672 
673 } // namespace ns3
static TypeId GetTypeId(void)
Get the type ID.
uint16_t GetProtocol(void) const
Get the protocol.
void Write(const uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:125
virtual enum SocketErrno GetErrno(void) const
Get last error number.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
#define min(a, b)
Definition: 80211b.c:42
void NotifyDataRecv(void)
Notify through the callback (if set) that some data have been received.
Definition: socket.cc:305
Address GetDestAddress(void) const
Get the destination address of the corresponding packet.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
Definition: socket.cc:175
Address m_destAddr
Default destination address.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:852
uint64_t GetUid(void) const
Returns the packet&#39;s Uid.
Definition: packet.cc:390
void NotifyConnectionFailed(void)
Notify through the callback (if set) that the connection has not been established due to an error...
Definition: socket.cc:227
an address for a packet socket
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)
Read a single packet from the socket and retrieve the sender address.
static bool IsMatchingType(const Address &address)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
virtual void DoDispose(void)
Destructor implementation.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:831
A PacketSocket is a link between an application and a net device.
Definition: packet-socket.h:93
void SetAllDevices(void)
Set the address to match all the outgoing NetDevice.
virtual uint32_t GetSerializedSize(void) const
void SetPacketType(NetDevice::PacketType t)
Set the packet type.
virtual int Bind(void)
Bind the socket to the NetDevice and register the protocol handler.
virtual void Print(std::ostream &os) const
uint32_t m_rxAvailable
Rx queue size [Bytes].
virtual int GetSockName(Address &address) const
Get socket address.
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
uint32_t GetSingleDevice(void) const
Get the device this address is bound to.
void UnregisterProtocolHandler(ProtocolHandler handler)
Definition: node.cc:261
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition: tag-buffer.h:195
a polymophic address class
Definition: address.h:90
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Ptr< Node > m_node
the associated node
virtual void Serialize(TagBuffer i) const
virtual int GetPeerName(Address &address) const
Get the peer address of a connected socket.
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:66
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
void SetDestAddress(Address a)
Set the destination address of the corresponding packet.
virtual int ShutdownRecv(void)
virtual void Deserialize(TagBuffer i)
Hold an unsigned integer type.
Definition: uinteger.h:44
enum State m_state
Socket state.
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
Definition: packet.cc:866
virtual uint32_t GetSerializedSize(void) const
indicates whether the socket has a priority set.
Definition: socket.h:1303
static TypeId GetTypeId(void)
Get the type ID.
PacketSocketTag()
Create an empty PacketSocketTag.
bool m_isSingleDevice
Is bound to a single netDevice.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:142
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:285
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
virtual int Listen(void)
Listen for incoming connections.
void Deserialize(TagBuffer buffer)
Definition: address.cc:163
void NotifyConnectionSucceeded(void)
Notify through the callback (if set) that the connection has been established.
Definition: socket.cc:217
uint32_t GetSerializedSize(void) const
Get the number of bytes needed to serialize the underlying Address Typically, this is GetLength () + ...
Definition: address.cc:147
uint32_t m_device
index of the bound NetDevice
uint32_t GetNDevices(void) const
Definition: node.cc:150
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
virtual uint32_t GetRxAvailable(void) const
Return number of bytes which can be returned from one or multiple calls to Recv.
tag a set of bytes in a packet
Definition: tag.h:36
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetPhysicalAddress(const Address address)
Set the destination address.
address
Definition: first.py:37
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
uint32_t m_rcvBufSize
Rx buffer size [Bytes].
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
Address GetPhysicalAddress(void) const
Get the destination address.
bool m_shutdownSend
Send no longer allowed.
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:172
This class implements a tag that carries the ns3 device name from where a packet is coming...
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
enum SocketErrno m_errno
Socket error code.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
Definition: node.cc:227
virtual void Deserialize(TagBuffer i)
virtual int Close(void)
Close a socket.
uint16_t m_protocol
Socket protocol.
bool m_shutdownRecv
Receive no longer allowed.
void SetNode(Ptr< Node > node)
Set the associated node.
static TypeId GetTypeId(void)
Get the type ID.
read and write tag data
Definition: tag-buffer.h:51
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
Definition: socket.h:1072
void Serialize(TagBuffer buffer) const
Serialize this address in host byte order to a byte buffer.
Definition: address.cc:154
int DoBind(const PacketSocketAddress &address)
Bind the socket to the NetDevice and register the protocol handler specified in the address...
virtual uint32_t GetTxAvailable(void) const
Returns the number of bytes which can be sent in a single call to Send.
virtual void Serialize(TagBuffer i) const
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:262
std::queue< std::pair< Ptr< Packet >, Address > > m_deliveryQueue
Rx queue.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:859
virtual ~PacketSocket()
NetDevice::PacketType GetPacketType(void) const
Get the packet type.
virtual void Print(std::ostream &os) const
bool IsSingleDevice(void) const
Checks if the address is bound to a specified NetDevice.
DeviceNameTag()
Create an empty DeviceNameTag.
void SetProtocol(uint16_t protocol)
Set the protocol.
static PacketSocketAddress ConvertFrom(const Address &address)
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
void Read(uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:176
uint32_t GetMinMtu(PacketSocketAddress ad) const
Get the minimum MTU supported by the NetDevices bound to a specific address.
virtual int Bind6(void)
Bind the socket to the NetDevice and register the protocol handler.
std::string GetDeviceName(void) const
Get the device name from where the corresponding packet is coming.
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:302
This class implements a tag that carries the dest address of a packet and the packet type...
TracedCallback< Ptr< const Packet > > m_dropTrace
Traced callback: dropped packets.
void SetPriority(uint8_t priority)
Set the tag&#39;s priority.
Definition: socket.cc:848
uint8_t GetPriority(void) const
Query the priority value of this socket.
Definition: socket.cc:402
virtual int ShutdownSend(void)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
SocketType
Enumeration of the possible socket types.
Definition: socket.h:104
a unique identifier for an interface.
Definition: type-id.h:58
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:295
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
virtual enum SocketType GetSocketType(void) const
void ForwardUp(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Called by the L3 protocol when it received a packet to pass on to TCP.
void SetDeviceName(std::string n)
Set the device name.