src/node/net-device.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 13 Mar 2008 11:10:38 -0700
changeset 2600 6c389d0c717d
parent 2542 a9b88fdc09d6
child 2834 1aab57845b07
permissions -rw-r--r--
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005,2006 INRIA
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 * All rights reserved.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 *
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 *
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 * GNU General Public License for more details.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 *
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 *
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 728
diff changeset
    20
 * Modified by Emmanuelle Laprise to remove dependance on LLC headers
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
 */
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#ifndef NET_DEVICE_H
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#define NET_DEVICE_H
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#include <string>
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include <stdint.h>
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
#include "ns3/callback.h"
710
2a9c061219a7 port code from Interface to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 607
diff changeset
    28
#include "ns3/object.h"
582
b10ef84683a5 NetDevice and Channel now derive from Interface rather than Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 568
diff changeset
    29
#include "ns3/ptr.h"
1161
bb72baff8b26 replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
    30
#include "address.h"
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
    31
#include "ipv4-address.h"
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
namespace ns3 {
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
728
95c426b1cb60 rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 710
diff changeset
    35
class Node;
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 247
diff changeset
    36
class TraceContext;
402
f47285751901 add NetDevice::GetChannel method and doxygen-document it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 401
diff changeset
    37
class Channel;
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1451
diff changeset
    38
class Packet;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
/**
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
 * \brief Network layer to device interface
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
 *
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
 * This interface defines the API which the IP and ARP
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
 * layers need to access to manage an instance of a network device 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
 * layer. It currently does not support MAC-level 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
 * multicast but this should not be too hard to add by adding
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
 * extra methods to register MAC multicast addresses to
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
 * filter out unwanted packets before handing them to the
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
 * higher layers.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
 *
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
 * In Linux, this interface is analogous to the interface
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
 * just above dev_queue_xmit() (i.e., IP packet is fully
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
 * constructed with destination MAC address already selected).
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
 * 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
 * If you want to write a new MAC layer, you need to subclass
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 345
diff changeset
    56
 * this base class and implement your own version of the
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
 * NetDevice::SendTo method.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
 */
710
2a9c061219a7 port code from Interface to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 607
diff changeset
    59
class NetDevice : public Object
469
676b647fc960 derive from Object for proper refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 465
diff changeset
    60
{
676b647fc960 derive from Object for proper refcounting
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 465
diff changeset
    61
public:
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
    62
  static TypeId GetTypeId (void);
487
04c5878c0a61 apply ref/unref rules consistently for Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 469
diff changeset
    63
  virtual ~NetDevice();
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 247
diff changeset
    64
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    65
  /**
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    66
   * \param name name of the device (e.g. "eth0")
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    67
   */
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    68
  virtual void SetName(const std::string name) = 0;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    69
  /**
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    70
   * \return name name of the device (e.g. "eth0")
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    71
   */
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    72
  virtual std::string GetName(void) const = 0;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    73
  /**
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    74
   * \param index ifIndex of the device 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    75
   */
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    76
  virtual void SetIfIndex(const uint32_t index) = 0;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    77
  /**
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    78
   * \return index ifIndex of the device 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    79
   */
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    80
  virtual uint32_t GetIfIndex(void) const = 0;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    81
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 247
diff changeset
    82
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
  /**
402
f47285751901 add NetDevice::GetChannel method and doxygen-document it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 401
diff changeset
    84
   * \return the channel this NetDevice is connected to. The value
f47285751901 add NetDevice::GetChannel method and doxygen-document it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 401
diff changeset
    85
   *         returned can be zero if the NetDevice is not yet connected
f47285751901 add NetDevice::GetChannel method and doxygen-document it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 401
diff changeset
    86
   *         to any channel.
f47285751901 add NetDevice::GetChannel method and doxygen-document it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 401
diff changeset
    87
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    88
  virtual Ptr<Channel> GetChannel (void) const = 0;
402
f47285751901 add NetDevice::GetChannel method and doxygen-document it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 401
diff changeset
    89
f47285751901 add NetDevice::GetChannel method and doxygen-document it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 401
diff changeset
    90
  /**
1161
bb72baff8b26 replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
    91
   * \return the current Address of this interface.
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    93
  virtual Address GetAddress (void) const = 0;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
  /**
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
   * \param mtu MTU value, in bytes, to set for the device
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
   * \return whether the MTU value was within legal bounds
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
   * 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
   * Override for default MTU defined on a per-type basis.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   100
  virtual bool SetMtu (const uint16_t mtu) = 0;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
  /**
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
   * \return the link-level MTU in bytes for this interface.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
   * 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
   * This value is typically used by the IP layer to perform
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
   * IP fragmentation when needed.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   107
  virtual uint16_t GetMtu (void) const = 0;
535
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 517
diff changeset
   108
  /**
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
   * \return true if link is up; false otherwise
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   111
  virtual bool IsLinkUp (void) const = 0;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
  /**
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
   * \param callback the callback to invoke
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
   *
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
   * Register a callback invoked whenever the link 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
   * status changes to UP. This callback is typically used
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
   * by the IP/ARP layer to flush the ARP cache 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
   * whenever the link goes up.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   120
  virtual void SetLinkChangeCallback (Callback<void> callback) = 0;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
  /**
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
   * \return true if this interface supports a broadcast address,
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
   *         false otherwise.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   125
  virtual bool IsBroadcast (void) const = 0;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
  /**
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
   * \return the broadcast address supported by
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
   *         this netdevice.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
   *
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
   * Calling this method is invalid if IsBroadcast returns
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
   * not true.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   133
  virtual Address GetBroadcast (void) const = 0;
1441
d6f8a7546e7f semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents: 1292
diff changeset
   134
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
  /**
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
   * \return value of m_isMulticast flag
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   138
  virtual bool IsMulticast (void) const = 0;
1441
d6f8a7546e7f semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents: 1292
diff changeset
   139
d6f8a7546e7f semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents: 1292
diff changeset
   140
  /**
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   141
   * \brief Return the MAC multicast base address used when mapping multicast
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   142
   * groups to MAC multicast addresses.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   143
   *
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   144
   * Typically when one constructs a multicast MAC addresses, some bits from
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   145
   * the IP multicast group are copied into a corresponding MAC multicast 
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   146
   * group.  In EUI-48, for example, the low order 23 bits of the multicast
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   147
   * group are copied to the MAC multicast group base address.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   148
   *
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   149
   * This method allows access to the underlying MAC multicast group base 
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   150
   * address.  It is expected that in most cases, a net device client will
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   151
   * allow the net device to perform the actual construction of the multicast
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   152
   * address.  Use of this method is discouraged unless you have a good reason
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   153
   * to perform a custom mapping.  You should prefer 
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   154
   * NetDevice::MakeMulticastAddress which will do the RFC-specified mapping
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   155
   * for the net device in question.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   156
   *
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   157
   * \return The multicast address supported by this net device.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   158
   *
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   159
   * \warning Calling this method is invalid if IsMulticast returns not true.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   160
   * The method NS_ASSERTs if the device is not a multicast device.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   161
   * \see NetDevice::MakeMulticastAddress
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   162
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   163
  virtual Address GetMulticast (void) const = 0;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   164
  
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   165
  /**
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   166
   * \brief Make and return a MAC multicast address using the provided
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   167
   *        multicast group
1441
d6f8a7546e7f semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents: 1292
diff changeset
   168
   *
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   169
   * RFC 1112 says that an Ipv4 host group address is mapped to an Ethernet 
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   170
   * multicast address by placing the low-order 23-bits of the IP address into 
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   171
   * the low-order 23 bits of the Ethernet multicast address 
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   172
   * 01-00-5E-00-00-00 (hex).  Similar RFCs exist for Ipv6 and Eui64 mappings.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   173
   * This method performs the multicast address creation function appropriate
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   174
   * to the underlying MAC address of the device.  This MAC address is
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   175
   * encapsulated in an abstract Address to avoid dependencies on the exact
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   176
   * MAC address format.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   177
   *
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   178
   * A default imlementation of MakeMulticastAddress is provided, but this
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   179
   * method simply NS_ASSERTS.  In the case of net devices that do not support
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   180
   * multicast, clients are expected to test NetDevice::IsMulticast and avoid
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   181
   * attempting to map multicast packets.  Subclasses of NetDevice that do
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   182
   * support multicasting are expected to override this method and provide an
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   183
   * implementation appropriate to the particular device.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   184
   *
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   185
   * \param multicastGroup The IP address for the multicast group destination
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   186
   * of the packet.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   187
   * \return The MAC multicast Address used to send packets to the provided
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   188
   * multicast group.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   189
   *
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   190
   * \warning Calling this method is invalid if IsMulticast returns not true.
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   191
   * \see Ipv4Address
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   192
   * \see Address
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   193
   * \see NetDevice::IsMulticast
1441
d6f8a7546e7f semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents: 1292
diff changeset
   194
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   195
  virtual Address MakeMulticastAddress (Ipv4Address multicastGroup) const = 0;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   196
  
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   197
  /**
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   198
   * \return value of m_isPointToPoint flag
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   199
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   200
  virtual bool IsPointToPoint (void) const = 0;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   201
  /**
2191
347400c335f9 Repair doxygen errors
Tom Henderson <tomh@tomh.org>
parents: 1866
diff changeset
   202
   * \param packet packet sent from above down to Network Device
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   203
   * \param dest mac address of the destination (already resolved)
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   204
   * \param protocolNumber identifies the type of payload contained in
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   205
   *        this packet. Used to call the right L3Protocol when the packet
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   206
   *        is received.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   207
   * 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   208
   *  Called from higher layer to send packet into Network Device
1161
bb72baff8b26 replace MacAddress by Address
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
   209
   *  to the specified destination Address
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   210
   * 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   211
   * \return whether the Send operation succeeded 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   212
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   213
  virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) = 0;
535
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 517
diff changeset
   214
  /**
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 517
diff changeset
   215
   * \returns the node base class which contains this network
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 517
diff changeset
   216
   *          interface.
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 517
diff changeset
   217
   *
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 517
diff changeset
   218
   * When a subclass needs to get access to the underlying node
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 517
diff changeset
   219
   * base class to print the nodeid for example, it can invoke
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 517
diff changeset
   220
   * this method.
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 517
diff changeset
   221
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   222
  virtual Ptr<Node> GetNode (void) const = 0;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   223
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
   224
  virtual void SetNode (Ptr<Node> node) = 0;
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
   225
597
4c8f1400f629 complete dox doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 592
diff changeset
   226
  /**
4c8f1400f629 complete dox doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 592
diff changeset
   227
   * \returns true if ARP is needed, false otherwise.
4c8f1400f629 complete dox doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 592
diff changeset
   228
   *
4c8f1400f629 complete dox doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 592
diff changeset
   229
   * Called by higher-layers to check if this NetDevice requires
4c8f1400f629 complete dox doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 592
diff changeset
   230
   * ARP to be used.
4c8f1400f629 complete dox doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 592
diff changeset
   231
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   232
  virtual bool NeedsArp (void) const = 0;
445
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   233
597
4c8f1400f629 complete dox doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 592
diff changeset
   234
  /**
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   235
   * \param device a pointer to the net device which is calling this callback
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   236
   * \param packet the packet received
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   237
   * \param protocol the 16 bit protocol number associated with this packet.
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   238
   *        This protocol number is expected to be the same protocol number
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   239
   *        given to the Send method by the user on the sender side.
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   240
   * \param address the address of the sender
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   241
   * \returns true if the callback could handle the packet successfully, false
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   242
   *          otherwise.
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   243
   */
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1451
diff changeset
   244
  typedef Callback<bool,Ptr<NetDevice>,Ptr<Packet>,uint16_t,const Address &> ReceiveCallback;
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   245
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   246
  /**
597
4c8f1400f629 complete dox doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 592
diff changeset
   247
   * \param cb callback to invoke whenever a packet has been received and must
4c8f1400f629 complete dox doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 592
diff changeset
   248
   *        be forwarded to the higher layers.
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   249
   *
597
4c8f1400f629 complete dox doc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 592
diff changeset
   250
   */
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   251
  virtual void SetReceiveCallback (ReceiveCallback cb) = 0;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   252
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   253
};
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   255
} // namespace ns3
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   256
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   257
#endif /* NET_DEVICE_H */