View | Details | Raw Unified | Return to bug 938
Collapse All | Expand All

(-)a/src/internet/model/arp-cache.h (-18 / +81 lines)
 Lines 49-82    Link Here 
49
class ArpCache : public Object
49
class ArpCache : public Object
50
{
50
{
51
private:
51
private:
52
  /**
53
   * \brief Copy constructor
54
   *
55
   * Defined and unimplemented to avoid misuse
56
   */
52
  ArpCache (ArpCache const &);
57
  ArpCache (ArpCache const &);
58
  /**
59
   * \brief Copy constructor
60
   *
61
   * Defined and unimplemented to avoid misuse
62
   * \returns
63
   */
53
  ArpCache& operator= (ArpCache const &);
64
  ArpCache& operator= (ArpCache const &);
54
65
55
public:
66
public:
67
  /**
68
   * \brief Get the type ID.
69
   * \return the object TypeId
70
   */
56
  static TypeId GetTypeId (void);
71
  static TypeId GetTypeId (void);
57
  class Entry;
72
  class Entry;
58
  ArpCache ();
73
  ArpCache ();
59
  ~ArpCache ();
74
  ~ArpCache ();
60
75
61
  /**
76
  /**
77
   * \brief Set the NetDevice and Ipv4Interface associated with the ArpCache
78
   *
62
   * \param device The hardware NetDevice associated with this ARP chache
79
   * \param device The hardware NetDevice associated with this ARP chache
63
   * \param interface the Ipv4Interface associated with this ARP chache
80
   * \param interface the Ipv4Interface associated with this ARP chache
64
   */
81
   */
65
  void SetDevice (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
82
  void SetDevice (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
66
  /**
83
  /**
84
   * \brief Returns the NetDevice that this ARP cache is associated with
67
   * \return The NetDevice that this ARP cache is associated with
85
   * \return The NetDevice that this ARP cache is associated with
68
   */
86
   */
69
  Ptr<NetDevice> GetDevice (void) const;
87
  Ptr<NetDevice> GetDevice (void) const;
70
  /**
88
  /**
89
   * \brief Returns the Ipv4Interface that this ARP cache is associated with
71
   * \return the Ipv4Interface that this ARP cache is associated with
90
   * \return the Ipv4Interface that this ARP cache is associated with
72
   */
91
   */
73
  Ptr<Ipv4Interface> GetInterface (void) const;
92
  Ptr<Ipv4Interface> GetInterface (void) const;
74
93
94
  /**
95
   * \brief Set the time the entry will be in ALIVE state (unless refreshed)
96
   * \param aliveTimeout the Alive state timeout
97
   */
75
  void SetAliveTimeout (Time aliveTimeout);
98
  void SetAliveTimeout (Time aliveTimeout);
99
  /**
100
   * \brief Set the time the entry will be in DEAD state before being removed
101
   * \param deadTimeout the Dead state timeout
102
   */
76
  void SetDeadTimeout (Time deadTimeout);
103
  void SetDeadTimeout (Time deadTimeout);
104
  /**
105
   * \brief Set the time the entry will be in WAIT_REPLY state
106
   * \param waitReplyTimeout the WAIT_REPLY state timeout
107
   */
77
  void SetWaitReplyTimeout (Time waitReplyTimeout);
108
  void SetWaitReplyTimeout (Time waitReplyTimeout);
109
110
  /**
111
   * \brief Get the time the entry will be in ALIVE state (unless refreshed)
112
   * \returns the Alive state timeout
113
   */
78
  Time GetAliveTimeout (void) const;
114
  Time GetAliveTimeout (void) const;
115
  /**
116
   * \brief Get the time the entry will be in DEAD state before being removed
117
   * \returns the Dead state timeout
118
   */
79
  Time GetDeadTimeout (void) const;
119
  Time GetDeadTimeout (void) const;
120
  /**
121
   * \brief Get the time the entry will be in WAIT_REPLY state
122
   * \returns the WAIT_REPLY state timeout
123
   */
80
  Time GetWaitReplyTimeout (void) const;
124
  Time GetWaitReplyTimeout (void) const;
81
125
82
  /**
126
  /**
 Lines 190-235    Link Here 
190
    void ClearRetries (void);
234
    void ClearRetries (void);
191
235
192
private:
236
private:
237
    /**
238
     * \brief ARP cache entry states
239
     */
193
    enum ArpCacheEntryState_e {
240
    enum ArpCacheEntryState_e {
194
      ALIVE,
241
      ALIVE,
195
      WAIT_REPLY,
242
      WAIT_REPLY,
196
      DEAD
243
      DEAD
197
    };
244
    };
198
245
246
    /**
247
     * \brief Update the entry when seeing a packet
248
     */
199
    void UpdateSeen (void);
249
    void UpdateSeen (void);
250
251
    /**
252
     * \brief Returns the entry timeout
253
     * \returns the entry timeout
254
     */
200
    Time GetTimeout (void) const;
255
    Time GetTimeout (void) const;
201
    ArpCache *m_arp;
256
202
    ArpCacheEntryState_e m_state;
257
    ArpCache *m_arp; //!< pointer to the ARP cache owning the entry
203
    Time m_lastSeen;
258
    ArpCacheEntryState_e m_state; //!< state of the entry
204
    Address m_macAddress;
259
    Time m_lastSeen; //!< last moment a packet from that address has been seen
205
    Ipv4Address m_ipv4Address;
260
    Address m_macAddress; //!< entry's MAC address
206
    std::list<Ptr<Packet> > m_pending;
261
    Ipv4Address m_ipv4Address; //!< entry's IP address
207
    uint32_t m_retries;
262
    std::list<Ptr<Packet> > m_pending; //!< list of pending packets for the entry's IP
263
    uint32_t m_retries; //!< rerty counter
208
  };
264
  };
209
265
210
private:
266
private:
267
  /**
268
   * \brief ARP Cache container
269
   */
211
  typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash> Cache;
270
  typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash> Cache;
271
  /**
272
   * \brief ARP Cache container iterator
273
   */
212
  typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>::iterator CacheI;
274
  typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>::iterator CacheI;
213
275
214
  virtual void DoDispose (void);
276
  virtual void DoDispose (void);
215
277
216
  Ptr<NetDevice> m_device;
278
  Ptr<NetDevice> m_device; //!< NetDevice associated with the cache
217
  Ptr<Ipv4Interface> m_interface;
279
  Ptr<Ipv4Interface> m_interface; //!< Ipv4Interface associated with the cache
218
  Time m_aliveTimeout;
280
  Time m_aliveTimeout; //!< cache alive state timeout
219
  Time m_deadTimeout;
281
  Time m_deadTimeout; //!< cache dead state timeout
220
  Time m_waitReplyTimeout;
282
  Time m_waitReplyTimeout; //!< cache reply state timeout
221
  EventId m_waitReplyTimer;
283
  EventId m_waitReplyTimer;  //!< cache alive state timer
222
  Callback<void, Ptr<const ArpCache>, Ipv4Address> m_arpRequestCallback;
284
  Callback<void, Ptr<const ArpCache>, Ipv4Address> m_arpRequestCallback;  //!< reply timeout callback
223
  uint32_t m_maxRetries;
285
  uint32_t m_maxRetries; //!< max retries for a resolution
286
224
  /**
287
  /**
225
   * This function is an event handler for the event that the
288
   * This function is an event handler for the event that the
226
   * ArpCache wants to check whether it must retry any Arp requests.
289
   * ArpCache wants to check whether it must retry any Arp requests.
227
   * If there are no Arp requests pending, this event is not scheduled.
290
   * If there are no Arp requests pending, this event is not scheduled.
228
   */
291
   */
229
  void HandleWaitReplyTimeout (void);
292
  void HandleWaitReplyTimeout (void);
230
  uint32_t m_pendingQueueSize;
293
  uint32_t m_pendingQueueSize; //!< number of packets waiting for a resolution
231
  Cache m_arpCache;
294
  Cache m_arpCache; //!< the ARP cache
232
  TracedCallback<Ptr<const Packet> > m_dropTrace;
295
  TracedCallback<Ptr<const Packet> > m_dropTrace; //!< trace for packets dropped by the ARP cache queue
233
};
296
};
234
297
235
298
(-)a/src/internet/model/arp-header.h (-5 / +56 lines)
 Lines 34-54    Link Here 
34
class ArpHeader : public Header 
34
class ArpHeader : public Header 
35
{
35
{
36
public:
36
public:
37
  /**
38
   * \brief Set the ARP request parameters
39
   * \param sourceHardwareAddress the source hardware address
40
   * \param sourceProtocolAddress the source IP address
41
   * \param destinationHardwareAddress the destination hardware address (usually the broadcast address)
42
   * \param destinationProtocolAddress the destination IP address
43
   */
37
  void SetRequest (Address sourceHardwareAddress,
44
  void SetRequest (Address sourceHardwareAddress,
38
                   Ipv4Address sourceProtocolAddress,
45
                   Ipv4Address sourceProtocolAddress,
39
                   Address destinationHardwareAddress,
46
                   Address destinationHardwareAddress,
40
                   Ipv4Address destinationProtocolAddress);
47
                   Ipv4Address destinationProtocolAddress);
48
  /**
49
   * \brief Set the ARP reply parameters
50
   * \param sourceHardwareAddress the source hardware address
51
   * \param sourceProtocolAddress the source IP address
52
   * \param destinationHardwareAddress the destination hardware address (usually the broadcast address)
53
   * \param destinationProtocolAddress the destination IP address
54
   */
41
  void SetReply (Address sourceHardwareAddress,
55
  void SetReply (Address sourceHardwareAddress,
42
                 Ipv4Address sourceProtocolAddress,
56
                 Ipv4Address sourceProtocolAddress,
43
                 Address destinationHardwareAddress,
57
                 Address destinationHardwareAddress,
44
                 Ipv4Address destinationProtocolAddress);
58
                 Ipv4Address destinationProtocolAddress);
59
60
  /**
61
   * \brief Check if the ARP is a request
62
   * \returns true if it is a request
63
   */
45
  bool IsRequest (void) const;
64
  bool IsRequest (void) const;
65
66
  /**
67
   * \brief Check if the ARP is a reply
68
   * \returns true if it is a reply
69
   */
46
  bool IsReply (void) const;
70
  bool IsReply (void) const;
71
72
  /**
73
   * \brief Returns the source hardware address
74
   * \returns the source hardware address
75
   */
47
  Address GetSourceHardwareAddress (void);
76
  Address GetSourceHardwareAddress (void);
77
78
  /**
79
   * \brief Returns the destination hardware address
80
   * \returns the destination hardware address
81
   */
48
  Address GetDestinationHardwareAddress (void);
82
  Address GetDestinationHardwareAddress (void);
83
84
  /**
85
   * \brief Returns the source IP address
86
   * \returns the source IP address
87
   */
49
  Ipv4Address GetSourceIpv4Address (void);
88
  Ipv4Address GetSourceIpv4Address (void);
89
90
  /**
91
   * \brief Returns the destination IP address
92
   * \returns the destination IP address
93
   */
50
  Ipv4Address GetDestinationIpv4Address (void);
94
  Ipv4Address GetDestinationIpv4Address (void);
51
95
96
  /**
97
   * \brief Get the type ID.
98
   * \return the object TypeId
99
   */
52
  static TypeId GetTypeId (void);
100
  static TypeId GetTypeId (void);
53
  virtual TypeId GetInstanceTypeId (void) const;
101
  virtual TypeId GetInstanceTypeId (void) const;
54
  virtual void Print (std::ostream &os) const;
102
  virtual void Print (std::ostream &os) const;
 Lines 56-70    Link Here 
56
  virtual void Serialize (Buffer::Iterator start) const;
104
  virtual void Serialize (Buffer::Iterator start) const;
57
  virtual uint32_t Deserialize (Buffer::Iterator start);
105
  virtual uint32_t Deserialize (Buffer::Iterator start);
58
106
107
  /**
108
   * \brief Enumeration listing the possible ARP types
109
   */
59
  enum ArpType_e {
110
  enum ArpType_e {
60
    ARP_TYPE_REQUEST = 1,
111
    ARP_TYPE_REQUEST = 1,
61
    ARP_TYPE_REPLY   = 2
112
    ARP_TYPE_REPLY   = 2
62
  };
113
  };
63
  uint16_t m_type;
114
  uint16_t m_type;           //!< type of the ICMP (ARP_TYPE_REQUEST)
64
  Address m_macSource;
115
  Address m_macSource;       //!< hardware source address
65
  Address m_macDest;
116
  Address m_macDest;         //!< hardware destination address
66
  Ipv4Address m_ipv4Source;
117
  Ipv4Address m_ipv4Source;  //!< IP source address
67
  Ipv4Address m_ipv4Dest;
118
  Ipv4Address m_ipv4Dest;    //!< IP destination address
68
};
119
};
69
120
70
} // namespace ns3
121
} // namespace ns3
(-)a/src/internet/model/arp-l3-protocol.h (-12 / +65 lines)
 Lines 49-77    Link Here 
49
class ArpL3Protocol : public Object
49
class ArpL3Protocol : public Object
50
{
50
{
51
public:
51
public:
52
  /**
53
   * \brief Get the type ID.
54
   * \return the object TypeId
55
   */
52
  static TypeId GetTypeId (void);
56
  static TypeId GetTypeId (void);
53
  static const uint16_t PROT_NUMBER;
57
  static const uint16_t PROT_NUMBER; //!< ARP protocol number (0x0806)
54
58
55
  ArpL3Protocol ();
59
  ArpL3Protocol ();
56
  virtual ~ArpL3Protocol ();
60
  virtual ~ArpL3Protocol ();
57
61
62
  /**
63
   * \brief Set the node the ARP L3 protocol is associated with
64
   * \param node the node
65
   */
58
  void SetNode (Ptr<Node> node);
66
  void SetNode (Ptr<Node> node);
59
67
68
  /**
69
   * \brief Create an ARP cache for the device/interface
70
   * \param device the NetDevice
71
   * \param interface the Ipv4Interface
72
   * \returns a smart pointer to the ARP cache
73
   */
60
  Ptr<ArpCache> CreateCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
74
  Ptr<ArpCache> CreateCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
61
75
62
  /**
76
  /**
63
   * \brief Receive a packet
77
   * \brief Receive a packet
78
   * \param device the source NetDevice
79
   * \param p the packet
80
   * \param protocol the protocol
81
   * \param from the source address
82
   * \param to the destination address
83
   * \param packetType type of packet (i.e., unicast, multicast, etc.)
64
   */
84
   */
65
  void Receive (Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to,
85
  void Receive (Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to,
66
                NetDevice::PacketType packetType);
86
                NetDevice::PacketType packetType);
67
  /**
87
  /**
68
   * \brief Perform an ARP lookup
88
   * \brief Perform an ARP lookup
69
   * \param p
89
   * \param p the packet
70
   * \param destination
90
   * \param destination destination IP address
71
   * \param device
91
   * \param device outgoing device
72
   * \param cache
92
   * \param cache ARP cache
73
   * \param hardwareDestination
93
   * \param hardwareDestination filled with the destination MAC address (if the entry exists)
74
   * \return 
94
   * \return true if there is a matching ARP Entry
75
   */
95
   */
76
  bool Lookup (Ptr<Packet> p, Ipv4Address destination, 
96
  bool Lookup (Ptr<Packet> p, Ipv4Address destination, 
77
               Ptr<NetDevice> device,
97
               Ptr<NetDevice> device,
 Lines 96-111    Link Here 
96
   */
116
   */
97
  virtual void NotifyNewAggregate ();
117
  virtual void NotifyNewAggregate ();
98
private:
118
private:
99
  typedef std::list<Ptr<ArpCache> > CacheList;
119
  typedef std::list<Ptr<ArpCache> > CacheList; //!< container of the ARP caches
120
  /**
121
   * \brief Copy constructor
122
   *
123
   * Defined and unimplemented to avoid misuse
124
   * \param o
125
   */
100
  ArpL3Protocol (const ArpL3Protocol &o);
126
  ArpL3Protocol (const ArpL3Protocol &o);
127
  /**
128
   * \brief Copy constructor
129
   *
130
   * Defined and unimplemented to avoid misuse
131
   * \param o
132
   * \returns
133
   */
101
  ArpL3Protocol &operator = (const ArpL3Protocol &o);
134
  ArpL3Protocol &operator = (const ArpL3Protocol &o);
135
136
  /**
137
   * \brief Finds the cache associated with a NetDevice
138
   * \param device the NetDevice
139
   * \returns the ARP cache, or null if no cache is found
140
   */
102
  Ptr<ArpCache> FindCache (Ptr<NetDevice> device);
141
  Ptr<ArpCache> FindCache (Ptr<NetDevice> device);
142
143
  /**
144
   * \brief Send an ARP request to an host
145
   * \param cache the ARP cache to use
146
   * \param to the destination IP
147
   */
103
  void SendArpRequest (Ptr<const ArpCache>cache, Ipv4Address to);
148
  void SendArpRequest (Ptr<const ArpCache>cache, Ipv4Address to);
149
  /**
150
   * \brief Send an ARP reply to an host
151
   * \param cache the ARP cache to use
152
   * \param myIp the source IP address
153
   * \param toIp the destination IP
154
   * \param toMac the destination MAC address
155
   */
104
  void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac);
156
  void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac);
105
  CacheList m_cacheList;
157
106
  Ptr<Node> m_node;
158
  CacheList m_cacheList; //!< ARP cache container
107
  TracedCallback<Ptr<const Packet> > m_dropTrace;
159
  Ptr<Node> m_node; //!< node the ARP L3 protocol is associated with
108
  Ptr<RandomVariableStream> m_requestJitter;
160
  TracedCallback<Ptr<const Packet> > m_dropTrace; //!< trace for packets dropped by ARP
161
  Ptr<RandomVariableStream> m_requestJitter; //!< jitter to de-sync ARP requests
109
162
110
};
163
};
111
164
(-)a/src/internet/model/candidate-queue.cc (+7 lines)
 Lines 27-32    Link Here 
27
27
28
namespace ns3 {
28
namespace ns3 {
29
29
30
/**
31
 * \brief Stream insertion operator.
32
 *
33
 * \param os the reference to the output stream
34
 * \param t the SPFVertex type
35
 * \returns the reference to the output stream
36
 */
30
std::ostream&
37
std::ostream&
31
operator<< (std::ostream& os, const SPFVertex::VertexType& t)
38
operator<< (std::ostream& os, const SPFVertex::VertexType& t)
32
{
39
{
(-)a/src/internet/model/candidate-queue.h (-2 / +12 lines)
 Lines 176-181    Link Here 
176
 * prevent the compiler from slipping in incorrect versions that don't
176
 * prevent the compiler from slipping in incorrect versions that don't
177
 * properly deal with deep copies.
177
 * properly deal with deep copies.
178
 * \param sr object to assign
178
 * \param sr object to assign
179
 * \return copied object
179
 */
180
 */
180
  CandidateQueue& operator= (CandidateQueue& sr);
181
  CandidateQueue& operator= (CandidateQueue& sr);
181
/**
182
/**
 Lines 185-197    Link Here 
185
 * defined by this method. If v1 should be popped before v2, this 
186
 * defined by this method. If v1 should be popped before v2, this 
186
 * method return true; false otherwise
187
 * method return true; false otherwise
187
 *
188
 *
189
 * \param v1 first operand
190
 * \param v2 second operand
188
 * \return True if v1 should be popped before v2; false otherwise
191
 * \return True if v1 should be popped before v2; false otherwise
189
 */
192
 */
190
  static bool CompareSPFVertex (const SPFVertex* v1, const SPFVertex* v2);
193
  static bool CompareSPFVertex (const SPFVertex* v1, const SPFVertex* v2);
191
194
192
  typedef std::list<SPFVertex*> CandidateList_t;
195
  typedef std::list<SPFVertex*> CandidateList_t; //!< container of SPFVertex pointers
193
  CandidateList_t m_candidates;
196
  CandidateList_t m_candidates;  //!< SPFVertex candidates
194
197
198
  /**
199
   * \brief Stream insertion operator.
200
   *
201
   * \param os the reference to the output stream
202
   * \param q the CandidateQueue
203
   * \returns the reference to the output stream
204
   */
195
  friend std::ostream& operator<< (std::ostream& os, const CandidateQueue& q);
205
  friend std::ostream& operator<< (std::ostream& os, const CandidateQueue& q);
196
};
206
};
197
207
(-)a/src/internet/model/global-route-manager-impl.cc (+7 lines)
 Lines 44-49    Link Here 
44
44
45
namespace ns3 {
45
namespace ns3 {
46
46
47
/**
48
 * \brief Stream insertion operator.
49
 *
50
 * \param os the reference to the output stream
51
 * \param exit the exit node
52
 * \returns the reference to the output stream
53
 */
47
std::ostream& 
54
std::ostream& 
48
operator<< (std::ostream& os, const SPFVertex::NodeExit_t& exit)
55
operator<< (std::ostream& os, const SPFVertex::NodeExit_t& exit)
49
{
56
{
(-)a/src/internet/model/global-route-manager-impl.h (-24 / +218 lines)
 Lines 34-40    Link Here 
34
34
35
namespace ns3 {
35
namespace ns3 {
36
36
37
const uint32_t SPF_INFINITY = 0xffffffff;
37
const uint32_t SPF_INFINITY = 0xffffffff; //!< "infinite" distance between nodes
38
38
39
class CandidateQueue;
39
class CandidateQueue;
40
class Ipv4GlobalRouting;
40
class Ipv4GlobalRouting;
 Lines 298-304    Link Here 
298
 * network represented by "this" SPFVertex.
298
 * network represented by "this" SPFVertex.
299
 */
299
 */
300
  void SetRootExitDirection (Ipv4Address nextHop, int32_t id = SPF_INFINITY);
300
  void SetRootExitDirection (Ipv4Address nextHop, int32_t id = SPF_INFINITY);
301
  typedef std::pair<Ipv4Address, int32_t> NodeExit_t;
301
302
  typedef std::pair<Ipv4Address, int32_t> NodeExit_t; //!< IPv4 / interface container for exit nodes.
303
302
/**
304
/**
303
 * @brief Set the IP address and outgoing interface index that should be used 
305
 * @brief Set the IP address and outgoing interface index that should be used 
304
 * to begin forwarding packets from the root SPFVertex to "this" SPFVertex.
306
 * to begin forwarding packets from the root SPFVertex to "this" SPFVertex.
 Lines 532-553    Link Here 
532
   */ 
534
   */ 
533
  bool IsVertexProcessed (void) const;
535
  bool IsVertexProcessed (void) const;
534
536
537
  /**
538
   * @brief Clear the value of the VertexProcessed flag
539
   *
540
   * Flag to note whether vertex has been processed in stage two of
541
   * SPF computation
542
   */
535
  void ClearVertexProcessed (void);
543
  void ClearVertexProcessed (void);
536
544
537
private:
545
private:
538
  VertexType m_vertexType;
546
  VertexType m_vertexType; //!< Vertex type
539
  Ipv4Address m_vertexId;
547
  Ipv4Address m_vertexId; //!< Vertex ID
540
  GlobalRoutingLSA* m_lsa;
548
  GlobalRoutingLSA* m_lsa; //!< Link State Advertisement
541
  uint32_t m_distanceFromRoot;
549
  uint32_t m_distanceFromRoot; //!< Distance from root node
542
  int32_t m_rootOif;
550
  int32_t m_rootOif; //!< root Output Interface
543
  Ipv4Address m_nextHop;
551
  Ipv4Address m_nextHop; //!< next hop
544
  typedef std::list< NodeExit_t > ListOfNodeExit_t;
552
  typedef std::list< NodeExit_t > ListOfNodeExit_t; //!< container of Exit nodes
545
  /// store the multiple root's exits for supporting ECMP
553
  ListOfNodeExit_t m_ecmpRootExits; //!< store the multiple root's exits for supporting ECMP
546
  ListOfNodeExit_t m_ecmpRootExits;
554
  typedef std::list<SPFVertex*> ListOfSPFVertex_t; //!< container of SPFVertexes
547
  typedef std::list<SPFVertex*> ListOfSPFVertex_t;
555
  ListOfSPFVertex_t m_parents; //!< parent list
548
  ListOfSPFVertex_t m_parents;
556
  ListOfSPFVertex_t m_children; //!< Children list
549
  ListOfSPFVertex_t m_children;
557
  bool m_vertexProcessed; //!< Flag to note whether vertex has been processed in stage two of SPF computation
550
  bool m_vertexProcessed; 
551
558
552
/**
559
/**
553
 * @brief The SPFVertex copy construction is disallowed.  There's no need for
560
 * @brief The SPFVertex copy construction is disallowed.  There's no need for
 Lines 561-568    Link Here 
561
 */
568
 */
562
  SPFVertex& operator= (SPFVertex& v);
569
  SPFVertex& operator= (SPFVertex& v);
563
570
564
  //friend std::ostream& operator<< (std::ostream& os, const ListOfIf_t& ifs);
571
  /**
565
  //friend std::ostream& operator<< (std::ostream& os, const ListOfAddr_t& addrs);
572
   * \brief Stream insertion operator.
573
   *
574
   * \param os the reference to the output stream
575
   * \param vs a list of SPFVertexes
576
   * \returns the reference to the output stream
577
   */
566
  friend std::ostream& operator<< (std::ostream& os, const SPFVertex::ListOfSPFVertex_t& vs);
578
  friend std::ostream& operator<< (std::ostream& os, const SPFVertex::ListOfSPFVertex_t& vs);
567
};
579
};
568
580
 Lines 662-677    Link Here 
662
 */
674
 */
663
  void Initialize ();
675
  void Initialize ();
664
676
677
  /**
678
   * @brief Look up the External Link State Advertisement associated with the given
679
   * index.
680
   * @internal
681
   *
682
   * The external database map is searched for the given index and corresponding
683
   * GlobalRoutingLSA is returned.
684
   *
685
   * @see GlobalRoutingLSA
686
   * @param index the index associated with the LSA.
687
   * @returns A pointer to the Link State Advertisement.
688
   */
665
  GlobalRoutingLSA* GetExtLSA (uint32_t index) const;
689
  GlobalRoutingLSA* GetExtLSA (uint32_t index) const;
690
  /**
691
   * @brief Get the number of External Link State Advertisements.
692
   * @internal
693
   *
694
   * @see GlobalRoutingLSA
695
   * @returns the number of External Link State Advertisements.
696
   */
666
  uint32_t GetNumExtLSAs () const;
697
  uint32_t GetNumExtLSAs () const;
667
698
668
699
669
private:
700
private:
670
  typedef std::map<Ipv4Address, GlobalRoutingLSA*> LSDBMap_t;
701
  typedef std::map<Ipv4Address, GlobalRoutingLSA*> LSDBMap_t; //!< container of IPv4 addresses / Link State Advertisements
671
  typedef std::pair<Ipv4Address, GlobalRoutingLSA*> LSDBPair_t;
702
  typedef std::pair<Ipv4Address, GlobalRoutingLSA*> LSDBPair_t; //!< pair of IPv4 addresses / Link State Advertisements
672
703
673
  LSDBMap_t m_database;
704
  LSDBMap_t m_database; //!< database of IPv4 addresses / Link State Advertisements
674
  std::vector<GlobalRoutingLSA*> m_extdatabase;
705
  std::vector<GlobalRoutingLSA*> m_extdatabase; //!< database of External Link State Advertisements
675
706
676
/**
707
/**
677
 * @brief GlobalRouteManagerLSDB copy construction is disallowed.  There's no 
708
 * @brief GlobalRouteManagerLSDB copy construction is disallowed.  There's no 
 Lines 736-741    Link Here 
736
/**
767
/**
737
 * @brief Debugging routine; call the core SPF from the unit tests
768
 * @brief Debugging routine; call the core SPF from the unit tests
738
 * @internal
769
 * @internal
770
 * @param root the root node to start calculations
739
 */
771
 */
740
  void DebugSPFCalculate (Ipv4Address root);
772
  void DebugSPFCalculate (Ipv4Address root);
741
773
 Lines 754-775    Link Here 
754
 */
786
 */
755
  GlobalRouteManagerImpl& operator= (GlobalRouteManagerImpl& srmi);
787
  GlobalRouteManagerImpl& operator= (GlobalRouteManagerImpl& srmi);
756
788
757
  SPFVertex* m_spfroot;
789
  SPFVertex* m_spfroot; //!< the root node
758
  GlobalRouteManagerLSDB* m_lsdb;
790
  GlobalRouteManagerLSDB* m_lsdb; //!< the Link State DataBase (LSDB) of the Global Route Manager
791
792
  /**
793
   * \brief Test if a node is a stub, from an OSPF sense.
794
   *
795
   * If there is only one link of type 1 or 2, then a default route
796
   * can safely be added to the next-hop router and SPF does not need
797
   * to be run
798
   *
799
   * \param root the root node
800
   * \returns true if the node is a stub
801
   */
759
  bool CheckForStubNode (Ipv4Address root);
802
  bool CheckForStubNode (Ipv4Address root);
803
804
  /**
805
   * \brief Calculate the shortest path first (SPF) tree
806
   *
807
   * Equivalent to quagga ospf_spf_calculate
808
   * \param root the root node
809
   */
760
  void SPFCalculate (Ipv4Address root);
810
  void SPFCalculate (Ipv4Address root);
811
812
  /**
813
   * \brief Process Stub nodes
814
   *
815
   * Processing logic from RFC 2328, page 166 and quagga ospf_spf_process_stubs ()
816
   * stub link records will exist for point-to-point interfaces and for
817
   * broadcast interfaces for which no neighboring router can be found
818
   *
819
   * \param v vertex to be processed
820
   */
761
  void SPFProcessStubs (SPFVertex* v);
821
  void SPFProcessStubs (SPFVertex* v);
822
823
  /**
824
   * \brief Process Autonomous Systems (AS) External LSA
825
   *
826
   * \param v vertex to be processed
827
   * \param extlsa external LSA
828
   */
762
  void ProcessASExternals (SPFVertex* v, GlobalRoutingLSA* extlsa);
829
  void ProcessASExternals (SPFVertex* v, GlobalRoutingLSA* extlsa);
763
  void SPFNext (SPFVertex*, CandidateQueue&);
830
831
  /**
832
   * \brief Examine the links in v's LSA and update the list of candidates with any
833
   *        vertices not already on the list
834
   *
835
   * \internal
836
   *
837
   * This method is derived from quagga ospf_spf_next ().  See RFC2328 Section
838
   * 16.1 (2) for further details.
839
   *
840
   * We're passed a parameter \a v that is a vertex which is already in the SPF
841
   * tree.  A vertex represents a router node.  We also get a reference to the
842
   * SPF candidate queue, which is a priority queue containing the shortest paths
843
   * to the networks we know about.
844
   *
845
   * We examine the links in v's LSA and update the list of candidates with any
846
   * vertices not already on the list.  If a lower-cost path is found to a
847
   * vertex already on the candidate list, store the new (lower) cost.
848
   *
849
   * \param v the vertex
850
   * \param candidate the SPF candidate queue
851
   */
852
  void SPFNext (SPFVertex* v, CandidateQueue& candidate);
853
854
  /**
855
   * \brief Calculate nexthop from root through V (parent) to vertex W (destination)
856
   *        with given distance from root->W.
857
   *
858
   * This method is derived from quagga ospf_nexthop_calculation() 16.1.1.
859
   * For now, this is greatly simplified from the quagga code
860
   *
861
   * \param v the parent
862
   * \param w the destination
863
   * \param l the link record
864
   * \param distance the target distance
865
   * \returns 1 on success
866
   */
764
  int SPFNexthopCalculation (SPFVertex* v, SPFVertex* w, 
867
  int SPFNexthopCalculation (SPFVertex* v, SPFVertex* w, 
765
                             GlobalRoutingLinkRecord* l, uint32_t distance);
868
                             GlobalRoutingLinkRecord* l, uint32_t distance);
869
870
  /**
871
   * \brief Adds a vertex to the list of children *in* each of its parents
872
   *
873
   * Derived from quagga ospf_vertex_add_parents ()
874
   *
875
   * This is a somewhat oddly named method (blame quagga).  Although you might
876
   * expect it to add a parent *to* something, it actually adds a vertex
877
   * to the list of children *in* each of its parents.
878
   *
879
   * Given a pointer to a vertex, it links back to the vertex's parent that it
880
   * already has set and adds itself to that vertex's list of children.
881
   *
882
   * \param v the vertex
883
   */
766
  void SPFVertexAddParent (SPFVertex* v);
884
  void SPFVertexAddParent (SPFVertex* v);
885
886
  /**
887
   * \brief Search for a link between two vertexes.
888
   *
889
   * This method is derived from quagga ospf_get_next_link ()
890
   *
891
   * First search the Global Router Link Records of vertex \a v for one
892
   * representing a point-to point link to vertex \a w.
893
   *
894
   * What is done depends on prev_link.  Contrary to appearances, prev_link just
895
   * acts as a flag here.  If prev_link is NULL, we return the first Global
896
   * Router Link Record we find that describes a point-to-point link from \a v
897
   * to \a w.  If prev_link is not NULL, we return a Global Router Link Record
898
   * representing a possible *second* link from \a v to \a w.
899
   *
900
   * \param v first vertex
901
   * \param w second vertex
902
   * \param prev_link the previous link in the list
903
   * \returns the link's record
904
   */
767
  GlobalRoutingLinkRecord* SPFGetNextLink (SPFVertex* v, SPFVertex* w, 
905
  GlobalRoutingLinkRecord* SPFGetNextLink (SPFVertex* v, SPFVertex* w, 
768
                                           GlobalRoutingLinkRecord* prev_link);
906
                                           GlobalRoutingLinkRecord* prev_link);
907
908
  /**
909
   * \brief Add a host route to the routing tables
910
   *
911
   *
912
   * This method is derived from quagga ospf_intra_add_router ()
913
   *
914
   * This is where we are actually going to add the host routes to the routing
915
   * tables of the individual nodes.
916
   *
917
   * The vertex passed as a parameter has just been added to the SPF tree.
918
   * This vertex must have a valid m_root_oid, corresponding to the outgoing
919
   * interface on the root router of the tree that is the first hop on the path
920
   * to the vertex.  The vertex must also have a next hop address, corresponding
921
   * to the next hop on the path to the vertex.  The vertex has an m_lsa field
922
   * that has some number of link records.  For each point to point link record,
923
   * the m_linkData is the local IP address of the link.  This corresponds to
924
   * a destination IP address, reachable from the root, to which we add a host
925
   * route.
926
   *
927
   * \param v the vertex
928
   *
929
   */
769
  void SPFIntraAddRouter (SPFVertex* v);
930
  void SPFIntraAddRouter (SPFVertex* v);
931
932
  /**
933
   * \brief Add a transit to the routing tables
934
   *
935
   * \param v the vertex
936
   */
770
  void SPFIntraAddTransit (SPFVertex* v);
937
  void SPFIntraAddTransit (SPFVertex* v);
938
939
  /**
940
   * \brief Add a stub to the routing tables
941
   *
942
   * \param l the global routing link record
943
   * \param v the vertex
944
   */
771
  void SPFIntraAddStub (GlobalRoutingLinkRecord *l, SPFVertex* v);
945
  void SPFIntraAddStub (GlobalRoutingLinkRecord *l, SPFVertex* v);
946
947
  /**
948
   * \brief Add an external route to the routing tables
949
   *
950
   * \param extlsa the external LSA
951
   * \param v the vertex
952
   */
772
  void SPFAddASExternal (GlobalRoutingLSA *extlsa, SPFVertex *v);
953
  void SPFAddASExternal (GlobalRoutingLSA *extlsa, SPFVertex *v);
954
955
  /**
956
   * \brief Return the interface number corresponding to a given IP address and mask
957
   *
958
   * This is a wrapper around GetInterfaceForPrefix(), but we first
959
   * have to find the right node pointer to pass to that function.
960
   * If no such interface is found, return -1 (note:  unit test framework
961
   * for routing assumes -1 to be a legal return value)
962
   *
963
   * \param a the target IP address
964
   * \param amask the target subnet mask
965
   * \return the outgoing interface number
966
   */
773
  int32_t FindOutgoingInterfaceId (Ipv4Address a, 
967
  int32_t FindOutgoingInterfaceId (Ipv4Address a, 
774
                                   Ipv4Mask amask = Ipv4Mask ("255.255.255.255"));
968
                                   Ipv4Mask amask = Ipv4Mask ("255.255.255.255"));
775
};
969
};
(-)a/src/internet/model/global-router-interface.h (-15 / +127 lines)
 Lines 559-567    Link Here 
559
 * proper position in the tree.
559
 * proper position in the tree.
560
 */
560
 */
561
  SPFStatus m_status;
561
  SPFStatus m_status;
562
  uint32_t m_node_id;
562
  uint32_t m_node_id; //!< node ID
563
};
563
};
564
564
565
/**
566
 * \brief Stream insertion operator.
567
 *
568
 * \param os the reference to the output stream
569
 * \param lsa the LSA
570
 * \returns the reference to the output stream
571
 */
565
std::ostream& operator<< (std::ostream& os, GlobalRoutingLSA& lsa);
572
std::ostream& operator<< (std::ostream& os, GlobalRoutingLSA& lsa);
566
573
567
/**
574
/**
 Lines 576-586    Link Here 
576
class GlobalRouter : public Object
583
class GlobalRouter : public Object
577
{
584
{
578
public:
585
public:
579
/**
586
  /**
580
 * @brief The Interface ID of the Global Router interface.
587
   * \brief Get the type ID.
581
 *
588
   * \return the object TypeId
582
 * @see Object::GetObject ()
589
   */
583
 */
584
  static TypeId GetTypeId (void);
590
  static TypeId GetTypeId (void);
585
591
586
/**
592
/**
 Lines 588-595    Link Here 
588
 */
594
 */
589
  GlobalRouter ();
595
  GlobalRouter ();
590
596
597
  /**
598
   * \brief Set the specific Global Routing Protocol to be used
599
   * \param routing the routing protocol
600
   */
601
  void SetRoutingProtocol (Ptr<Ipv4GlobalRouting> routing);
591
602
592
  void SetRoutingProtocol (Ptr<Ipv4GlobalRouting> routing);
603
  /**
604
   * \brief Get the specific Global Routing Protocol used
605
   * \returns the routing protocol
606
   */
593
  Ptr<Ipv4GlobalRouting> GetRoutingProtocol (void);
607
  Ptr<Ipv4GlobalRouting> GetRoutingProtocol (void);
594
608
595
/**
609
/**
 Lines 709-739    Link Here 
709
723
710
private:
724
private:
711
  virtual ~GlobalRouter ();
725
  virtual ~GlobalRouter ();
726
727
  /**
728
   * \brief Clear list of LSAs
729
   */
712
  void ClearLSAs (void);
730
  void ClearLSAs (void);
713
731
732
  /**
733
   * \brief Link through the given channel and find the net device that's on the other end.
734
   *
735
   * This only makes sense with a point-to-point channel.
736
   *
737
   * \param nd outgoing NetDevice
738
   * \param ch channel
739
   * \returns the NetDevice on the other end
740
   */
714
  Ptr<NetDevice> GetAdjacent (Ptr<NetDevice> nd, Ptr<Channel> ch) const;
741
  Ptr<NetDevice> GetAdjacent (Ptr<NetDevice> nd, Ptr<Channel> ch) const;
742
743
  /**
744
   * \brief Given a node and a net device, find an IPV4 interface index that corresponds
745
   *        to that net device.
746
   *
747
   * This function may fail for various reasons.  If a node
748
   * does not have an internet stack (for example if it is a bridge) we won't have
749
   * an IPv4 at all.  If the node does have a stack, but the net device in question
750
   * is bridged, there will not be an interface associated directly with the device.
751
   *
752
   * \param node the node
753
   * \param nd outgoing NetDevice
754
   * \param index the IPV4 interface index
755
   * \returns true on success
756
   */
715
  bool FindInterfaceForDevice (Ptr<Node> node, Ptr<NetDevice> nd, uint32_t &index) const;
757
  bool FindInterfaceForDevice (Ptr<Node> node, Ptr<NetDevice> nd, uint32_t &index) const;
758
759
  /**
760
   * \brief Finds a designated router
761
   *
762
   * Given a local net device, we need to walk the channel to which the net device is
763
   * attached and look for nodes with GlobalRouter interfaces on them (one of them
764
   * will be us).  Of these, the router with the lowest IP address on the net device
765
   * connecting to the channel becomes the designated router for the link.
766
   *
767
   * \param ndLocal local NetDevice to scan
768
   * \param allowRecursion Recursively look for routers down bridge port
769
   * \returns the IP address of the designated router
770
   */
716
  Ipv4Address FindDesignatedRouterForLink (Ptr<NetDevice> ndLocal, bool allowRecursion) const;
771
  Ipv4Address FindDesignatedRouterForLink (Ptr<NetDevice> ndLocal, bool allowRecursion) const;
772
773
  /**
774
   * \brief Checks for the presence of another router on the NetDevice
775
   *
776
   * Given a node and an attached net device, take a look off in the channel to
777
   * which the net device is attached and look for a node on the other side
778
   * that has a GlobalRouter interface aggregated.  Life gets more complicated
779
   * when there is a bridged net device on the other side.
780
   *
781
   * \param nd NetDevice to scan
782
   * \param allowRecursion Recursively look for routers down bridge port
783
   * \returns true if a router is found
784
   */
717
  bool AnotherRouterOnLink (Ptr<NetDevice> nd, bool allowRecursion) const;
785
  bool AnotherRouterOnLink (Ptr<NetDevice> nd, bool allowRecursion) const;
786
787
  /**
788
   * \brief Process a generic broadcast link
789
   *
790
   * \param nd the NetDevice
791
   * \param pLSA the Global LSA
792
   * \param c the returned NetDevice container
793
   */
718
  void ProcessBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c);
794
  void ProcessBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c);
795
796
  /**
797
   * \brief Process a single broadcast link
798
   *
799
   * \param nd the NetDevice
800
   * \param pLSA the Global LSA
801
   * \param c the returned NetDevice container
802
   */
719
  void ProcessSingleBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c);
803
  void ProcessSingleBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c);
804
805
  /**
806
   * \brief Process a bridged broadcast link
807
   *
808
   * \param nd the NetDevice
809
   * \param pLSA the Global LSA
810
   * \param c the returned NetDevice container
811
   */
720
  void ProcessBridgedBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c);
812
  void ProcessBridgedBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c);
721
813
814
  /**
815
   * \brief Process a point to point link
816
   *
817
   * \param ndLocal the NetDevice
818
   * \param pLSA the Global LSA
819
   */
722
  void ProcessPointToPointLink (Ptr<NetDevice> ndLocal, GlobalRoutingLSA *pLSA);
820
  void ProcessPointToPointLink (Ptr<NetDevice> ndLocal, GlobalRoutingLSA *pLSA);
821
822
  /**
823
   * \brief Build one NetworkLSA for each net device talking to a network that we are the
824
   * designated router for.
825
   *
826
   * \param c the devices.
827
   */
723
  void BuildNetworkLSAs (NetDeviceContainer c);
828
  void BuildNetworkLSAs (NetDeviceContainer c);
829
830
  /**
831
   * \brief Decide whether or not a given net device is being bridged by a BridgeNetDevice.
832
   *
833
   * \param nd the NetDevice
834
   * \returns the BridgeNetDevice smart pointer or null if not found
835
   */
724
  Ptr<BridgeNetDevice> NetDeviceIsBridged (Ptr<NetDevice> nd) const;
836
  Ptr<BridgeNetDevice> NetDeviceIsBridged (Ptr<NetDevice> nd) const;
725
837
726
838
727
  typedef std::list<GlobalRoutingLSA*> ListOfLSAs_t;
839
  typedef std::list<GlobalRoutingLSA*> ListOfLSAs_t; //!< container for the GlobalRoutingLSAs
728
  ListOfLSAs_t m_LSAs;
840
  ListOfLSAs_t m_LSAs; //!< database of GlobalRoutingLSAs
729
841
730
  Ipv4Address m_routerId;
842
  Ipv4Address m_routerId; //!< router ID (its IPv4 address)
731
  Ptr<Ipv4GlobalRouting> m_routingProtocol;
843
  Ptr<Ipv4GlobalRouting> m_routingProtocol; //!< the Ipv4GlobalRouting in use
732
844
733
  typedef std::list<Ipv4RoutingTableEntry *> InjectedRoutes;
845
  typedef std::list<Ipv4RoutingTableEntry *> InjectedRoutes; //!< container of Ipv4RoutingTableEntry
734
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator InjectedRoutesCI;
846
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator InjectedRoutesCI; //!< Const Iterator to container of Ipv4RoutingTableEntry
735
  typedef std::list<Ipv4RoutingTableEntry *>::iterator InjectedRoutesI;
847
  typedef std::list<Ipv4RoutingTableEntry *>::iterator InjectedRoutesI; //!< Iterator to container of Ipv4RoutingTableEntry
736
  InjectedRoutes m_injectedRoutes; // Routes we are exporting
848
  InjectedRoutes m_injectedRoutes; //!< Routes we are exporting
737
849
738
  // inherited from Object
850
  // inherited from Object
739
  virtual void DoDispose (void);
851
  virtual void DoDispose (void);
(-)a/src/internet/model/icmpv4-l4-protocol.h (-5 / +98 lines)
 Lines 14-35    Link Here 
14
class Icmpv4L4Protocol : public IpL4Protocol
14
class Icmpv4L4Protocol : public IpL4Protocol
15
{
15
{
16
public:
16
public:
17
  /**
18
   * \brief Get the type ID.
19
   * \return the object TypeId
20
   */
17
  static TypeId GetTypeId (void);
21
  static TypeId GetTypeId (void);
18
  static const uint8_t PROT_NUMBER;
22
  static const uint8_t PROT_NUMBER; //!< ICMP protocol number (0x1)
19
23
20
  Icmpv4L4Protocol ();
24
  Icmpv4L4Protocol ();
21
  virtual ~Icmpv4L4Protocol ();
25
  virtual ~Icmpv4L4Protocol ();
22
26
27
  /**
28
   * \brief Set the node the protocol is associated with.
29
   * \param node the node
30
   */
23
  void SetNode (Ptr<Node> node);
31
  void SetNode (Ptr<Node> node);
24
32
33
  /**
34
   * Get the protocol number
35
   * \returns the protocol number
36
   */
25
  static uint16_t GetStaticProtocolNumber (void);
37
  static uint16_t GetStaticProtocolNumber (void);
38
39
  /**
40
   * Get the protocol number
41
   * \returns the protocol number
42
   */
26
  virtual int GetProtocolNumber (void) const;
43
  virtual int GetProtocolNumber (void) const;
27
44
28
  /**
45
  /**
29
   * \brief Receive method.
46
   * \brief Receive method.
30
   * \param p the packet
47
   * \param p the packet
31
   * \param header the IPv4 header
48
   * \param header the IPv4 header
32
   * \param interface the interface from which the packet is coming
49
   * \param incomingInterface the interface from which the packet is coming
50
   * \returns the receive status
33
   */
51
   */
34
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
52
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
35
                                               Ipv4Header const &header,
53
                                               Ipv4Header const &header,
 Lines 39-52    Link Here 
39
   * \brief Receive method.
57
   * \brief Receive method.
40
   * \param p the packet
58
   * \param p the packet
41
   * \param header the IPv6 header
59
   * \param header the IPv6 header
42
   * \param interface the interface from which the packet is coming
60
   * \param incomingInterface the interface from which the packet is coming
61
   * \returns the receive status
43
   */
62
   */
44
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
63
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
45
                                               Ipv6Header const &header,
64
                                               Ipv6Header const &header,
46
                                               Ptr<Ipv6Interface> incomingInterface);
65
                                               Ptr<Ipv6Interface> incomingInterface);
47
66
67
  /**
68
   * \brief Send a Destination Unreachable - Fragmentation needed ICMP error
69
   * \param header the original IP header
70
   * \param orgData the original packet
71
   * \param nextHopMtu the next hop MTU
72
   */
48
  void SendDestUnreachFragNeeded (Ipv4Header header, Ptr<const Packet> orgData, uint16_t nextHopMtu);
73
  void SendDestUnreachFragNeeded (Ipv4Header header, Ptr<const Packet> orgData, uint16_t nextHopMtu);
74
75
  /**
76
   * \brief Send a Time Exceeded ICMP error
77
   * \param header the original IP header
78
   * \param orgData the original packet
79
   */
49
  void SendTimeExceededTtl (Ipv4Header header, Ptr<const Packet> orgData);
80
  void SendTimeExceededTtl (Ipv4Header header, Ptr<const Packet> orgData);
81
82
  /**
83
   * \brief Send a Time Exceeded ICMP error
84
   * \param header the original IP header
85
   * \param orgData the original packet
86
   */
50
  void SendDestUnreachPort (Ipv4Header header, Ptr<const Packet> orgData);
87
  void SendDestUnreachPort (Ipv4Header header, Ptr<const Packet> orgData);
51
88
52
  // From IpL4Protocol
89
  // From IpL4Protocol
 Lines 62-91    Link Here 
62
   */
99
   */
63
  virtual void NotifyNewAggregate ();
100
  virtual void NotifyNewAggregate ();
64
private:
101
private:
102
  /**
103
   * \brief Handles an incoming ICMP Echo packet
104
   * \param p the packet
105
   * \param header the IP header
106
   * \param source the source address
107
   * \param destination the destination address
108
   */
65
  void HandleEcho (Ptr<Packet> p,
109
  void HandleEcho (Ptr<Packet> p,
66
                   Icmpv4Header header,
110
                   Icmpv4Header header,
67
                   Ipv4Address source,
111
                   Ipv4Address source,
68
                   Ipv4Address destination);
112
                   Ipv4Address destination);
113
  /**
114
   * \brief Handles an incoming ICMP Destination Unreachable packet
115
   * \param p the packet
116
   * \param header the IP header
117
   * \param source the source address
118
   * \param destination the destination address
119
   */
69
  void HandleDestUnreach (Ptr<Packet> p,
120
  void HandleDestUnreach (Ptr<Packet> p,
70
                          Icmpv4Header header,
121
                          Icmpv4Header header,
71
                          Ipv4Address source,
122
                          Ipv4Address source,
72
                          Ipv4Address destination);
123
                          Ipv4Address destination);
124
  /**
125
   * \brief Handles an incoming ICMP Time Exceeded packet
126
   * \param p the packet
127
   * \param icmp the ICMP header
128
   * \param source the source address
129
   * \param destination the destination address
130
   */
73
  void HandleTimeExceeded (Ptr<Packet> p,
131
  void HandleTimeExceeded (Ptr<Packet> p,
74
                           Icmpv4Header icmp,
132
                           Icmpv4Header icmp,
75
                           Ipv4Address source,
133
                           Ipv4Address source,
76
                           Ipv4Address destination);
134
                           Ipv4Address destination);
135
  /**
136
   * \brief Send an ICMP Destination Unreachable packet
137
   *
138
   * \param header the original IP header
139
   * \param orgData the original packet
140
   * \param code the ICMP code
141
   * \param nextHopMtu the next hop MTU
142
   */
77
  void SendDestUnreach (Ipv4Header header, Ptr<const Packet> orgData, 
143
  void SendDestUnreach (Ipv4Header header, Ptr<const Packet> orgData, 
78
                        uint8_t code, uint16_t nextHopMtu);
144
                        uint8_t code, uint16_t nextHopMtu);
145
  /**
146
   * \brief Send a generic ICMP packet
147
   *
148
   * \param packet the packet
149
   * \param dest the destination
150
   * \param type the ICMP type
151
   * \param code the ICMP code
152
   */
79
  void SendMessage (Ptr<Packet> packet, Ipv4Address dest, uint8_t type, uint8_t code);
153
  void SendMessage (Ptr<Packet> packet, Ipv4Address dest, uint8_t type, uint8_t code);
154
  /**
155
   * \brief Send a generic ICMP packet
156
   *
157
   * \param packet the packet
158
   * \param source the source
159
   * \param dest the destination
160
   * \param type the ICMP type
161
   * \param code the ICMP code
162
   * \param route the route to be used
163
   */
80
  void SendMessage (Ptr<Packet> packet, Ipv4Address source, Ipv4Address dest, uint8_t type, uint8_t code, Ptr<Ipv4Route> route);
164
  void SendMessage (Ptr<Packet> packet, Ipv4Address source, Ipv4Address dest, uint8_t type, uint8_t code, Ptr<Ipv4Route> route);
165
  /**
166
   * \brief Forward the message to an L4 protocol
167
   *
168
   * \param source the source
169
   * \param icmp the ICMP header
170
   * \param info info data (e.g., the target MTU)
171
   * \param ipHeader the IP header carried by ICMP
172
   * \param payload payload chunk carried by ICMP
173
   */
81
  void Forward (Ipv4Address source, Icmpv4Header icmp,
174
  void Forward (Ipv4Address source, Icmpv4Header icmp,
82
                uint32_t info, Ipv4Header ipHeader,
175
                uint32_t info, Ipv4Header ipHeader,
83
                const uint8_t payload[8]);
176
                const uint8_t payload[8]);
84
177
85
  virtual void DoDispose (void);
178
  virtual void DoDispose (void);
86
179
87
  Ptr<Node> m_node;
180
  Ptr<Node> m_node; //!< the node this protocol is associated with
88
  IpL4Protocol::DownTargetCallback m_downTarget;
181
  IpL4Protocol::DownTargetCallback m_downTarget; //!< callback to Ipv4::Send
89
};
182
};
90
183
91
} // namespace ns3
184
} // namespace ns3
(-)a/src/internet/model/icmpv4.h (-12 / +120 lines)
 Lines 40-55    Link Here 
40
    TIME_EXCEEDED = 11
40
    TIME_EXCEEDED = 11
41
  };
41
  };
42
42
43
  /**
44
   * Enables ICMP Checksum calculation
45
   */
43
  void EnableChecksum (void);
46
  void EnableChecksum (void);
47
48
  /**
49
   * Set ICMP type
50
   * \param type the ICMP type
51
   */
44
  void SetType (uint8_t type);
52
  void SetType (uint8_t type);
53
54
  /**
55
   * Set ICMP code
56
   * \param code the ICMP code
57
   */
45
  void SetCode (uint8_t code);
58
  void SetCode (uint8_t code);
46
59
60
  /**
61
   * Get ICMP type
62
   * \returns the ICMP type
63
   */
47
  uint8_t GetType (void) const;
64
  uint8_t GetType (void) const;
65
  /**
66
   * Get ICMP code
67
   * \returns the ICMP code
68
   */
48
  uint8_t GetCode (void) const;
69
  uint8_t GetCode (void) const;
49
70
71
  /**
72
   * \brief Get the type ID.
73
   * \return the object TypeId
74
   */
50
  static TypeId GetTypeId (void);
75
  static TypeId GetTypeId (void);
51
  Icmpv4Header ();
76
  Icmpv4Header ();
52
  virtual ~Icmpv4Header ();
77
  virtual ~Icmpv4Header ();
78
53
  virtual TypeId GetInstanceTypeId (void) const;
79
  virtual TypeId GetInstanceTypeId (void) const;
54
  virtual uint32_t GetSerializedSize (void) const;
80
  virtual uint32_t GetSerializedSize (void) const;
55
  virtual void Serialize (Buffer::Iterator start) const;
81
  virtual void Serialize (Buffer::Iterator start) const;
 Lines 57-79    Link Here 
57
  virtual void Print (std::ostream &os) const;
83
  virtual void Print (std::ostream &os) const;
58
84
59
private:
85
private:
60
  uint8_t m_type;
86
  uint8_t m_type; //!< ICMP type
61
  uint8_t m_code;
87
  uint8_t m_code; //!< ICMP code
62
  bool m_calcChecksum;
88
  bool m_calcChecksum;  //!< true if checksum is calculated
63
};
89
};
64
90
65
class Icmpv4Echo : public Header
91
class Icmpv4Echo : public Header
66
{
92
{
67
public:
93
public:
94
  /**
95
   * \brief Set the Echo identifier
96
   * \param id the identifier
97
   */
68
  void SetIdentifier (uint16_t id);
98
  void SetIdentifier (uint16_t id);
99
  /**
100
   * \brief Set the Echo sequence number
101
   * \param seq the sequence number
102
   */
69
  void SetSequenceNumber (uint16_t seq);
103
  void SetSequenceNumber (uint16_t seq);
104
  /**
105
   * \brief Set the Echo data
106
   * \param data the data
107
   */
70
  void SetData (Ptr<const Packet> data);
108
  void SetData (Ptr<const Packet> data);
109
  /**
110
   * \brief Get the Echo identifier
111
   * \returns the identifier
112
   */
71
  uint16_t GetIdentifier (void) const;
113
  uint16_t GetIdentifier (void) const;
114
  /**
115
   * \brief Get the Echo sequence number
116
   * \returns the sequence number
117
   */
72
  uint16_t GetSequenceNumber (void) const;
118
  uint16_t GetSequenceNumber (void) const;
119
  /**
120
   * \brief Get the Echo data size
121
   * \returns the data size
122
   */
73
  uint32_t GetDataSize (void) const;
123
  uint32_t GetDataSize (void) const;
124
  /**
125
   * \brief Get the Echo data
126
   * \param payload the data (filled)
127
   * \returns the data length
128
   */
74
  uint32_t GetData (uint8_t payload[]) const;
129
  uint32_t GetData (uint8_t payload[]) const;
75
130
76
131
132
  /**
133
   * Get ICMP type
134
   * \returns the ICMP type
135
   */
77
  static TypeId GetTypeId (void);
136
  static TypeId GetTypeId (void);
78
  Icmpv4Echo ();
137
  Icmpv4Echo ();
79
  virtual ~Icmpv4Echo ();
138
  virtual ~Icmpv4Echo ();
 Lines 83-92    Link Here 
83
  virtual uint32_t Deserialize (Buffer::Iterator start);
142
  virtual uint32_t Deserialize (Buffer::Iterator start);
84
  virtual void Print (std::ostream &os) const;
143
  virtual void Print (std::ostream &os) const;
85
private:
144
private:
86
  uint16_t m_identifier;
145
  uint16_t m_identifier; //!< identifier
87
  uint16_t m_sequence;
146
  uint16_t m_sequence;   //!< sequence number
88
  uint8_t *m_data;
147
  uint8_t *m_data;       //!< data
89
  uint32_t m_dataSize;
148
  uint32_t m_dataSize;   //!< data size
90
};
149
};
91
150
92
class Icmpv4DestinationUnreachable : public Header
151
class Icmpv4DestinationUnreachable : public Header
 Lines 100-116    Link Here 
100
    FRAG_NEEDED = 4,
159
    FRAG_NEEDED = 4,
101
    SOURCE_ROUTE_FAILED = 5
160
    SOURCE_ROUTE_FAILED = 5
102
  };
161
  };
162
163
  /**
164
   * Get ICMP type
165
   * \returns the ICMP type
166
   */
103
  static TypeId GetTypeId (void);
167
  static TypeId GetTypeId (void);
104
  Icmpv4DestinationUnreachable ();
168
  Icmpv4DestinationUnreachable ();
105
  virtual ~Icmpv4DestinationUnreachable ();
169
  virtual ~Icmpv4DestinationUnreachable ();
106
170
171
  /**
172
   * \brief Set the next hop MTU
173
   * \param mtu the MTU
174
   */
107
  void SetNextHopMtu (uint16_t mtu);
175
  void SetNextHopMtu (uint16_t mtu);
176
  /**
177
   * \brief Get the next hop MTU
178
   * \returns the MTU
179
   */
108
  uint16_t GetNextHopMtu (void) const;
180
  uint16_t GetNextHopMtu (void) const;
109
181
182
  /**
183
   * \brief Set the ICMP carried data
184
   * \param data the data
185
   */
110
  void SetData (Ptr<const Packet> data);
186
  void SetData (Ptr<const Packet> data);
187
  /**
188
   * \brief Set the ICMP carried IPv4 header
189
   * \param header the header
190
   */
111
  void SetHeader (Ipv4Header header);
191
  void SetHeader (Ipv4Header header);
112
192
193
  /**
194
   * \brief Get the ICMP carried data
195
   * \param payload the data (filled)
196
   */
113
  void GetData (uint8_t payload[8]) const;
197
  void GetData (uint8_t payload[8]) const;
198
  /**
199
   * \brief Get the ICMP carried IPv4 header
200
   * \returns the header
201
   */
114
  Ipv4Header GetHeader (void) const;
202
  Ipv4Header GetHeader (void) const;
115
203
116
private:
204
private:
 Lines 120-128    Link Here 
120
  virtual uint32_t Deserialize (Buffer::Iterator start);
208
  virtual uint32_t Deserialize (Buffer::Iterator start);
121
  virtual void Print (std::ostream &os) const;
209
  virtual void Print (std::ostream &os) const;
122
private:
210
private:
123
  uint16_t m_nextHopMtu;
211
  uint16_t m_nextHopMtu; //!< next hop MTU
124
  Ipv4Header m_header;
212
  Ipv4Header m_header;   //!< carried IPv4 header
125
  uint8_t m_data[8];
213
  uint8_t m_data[8];     //!< carried data
126
};
214
};
127
215
128
216
 Lines 134-145    Link Here 
134
    FRAGMENT_REASSEMBLY = 1
222
    FRAGMENT_REASSEMBLY = 1
135
  };
223
  };
136
224
225
  /**
226
   * \brief Get the ICMP carried data
227
   * \param data the data
228
   */
137
  void SetData (Ptr<const Packet> data);
229
  void SetData (Ptr<const Packet> data);
230
  /**
231
   * \brief Set the ICMP carried IPv4 header
232
   * \param header the header
233
   */
138
  void SetHeader (Ipv4Header header);
234
  void SetHeader (Ipv4Header header);
139
235
236
  /**
237
   * \brief Get the ICMP carried data
238
   * \param payload the data (filled)
239
   */
140
  void GetData (uint8_t payload[8]) const;
240
  void GetData (uint8_t payload[8]) const;
241
  /**
242
   * \brief Get the ICMP carried IPv4 header
243
   * \returns the header
244
   */
141
  Ipv4Header GetHeader (void) const;
245
  Ipv4Header GetHeader (void) const;
142
246
247
  /**
248
   * Get ICMP type
249
   * \returns the ICMP type
250
   */
143
  static TypeId GetTypeId (void);
251
  static TypeId GetTypeId (void);
144
  Icmpv4TimeExceeded ();
252
  Icmpv4TimeExceeded ();
145
  virtual ~Icmpv4TimeExceeded ();
253
  virtual ~Icmpv4TimeExceeded ();
 Lines 150-157    Link Here 
150
  virtual void Print (std::ostream &os) const;
258
  virtual void Print (std::ostream &os) const;
151
259
152
private:
260
private:
153
  Ipv4Header m_header;
261
  Ipv4Header m_header;   //!< carried IPv4 header
154
  uint8_t m_data[8];
262
  uint8_t m_data[8];     //!< carried data
155
};
263
};
156
264
157
} // namespace ns3
265
} // namespace ns3
(-)a/src/internet/model/icmpv6-l4-protocol.h (-3 / +9 lines)
 Lines 338-343    Link Here 
338
   * \param p the packet
338
   * \param p the packet
339
   * \param header the IPv4 header
339
   * \param header the IPv4 header
340
   * \param interface the interface from which the packet is coming
340
   * \param interface the interface from which the packet is coming
341
   * \returns the receive status
341
   */
342
   */
342
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
343
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
343
                                               Ipv4Header const &header,
344
                                               Ipv4Header const &header,
 Lines 348-353    Link Here 
348
   * \param p the packet
349
   * \param p the packet
349
   * \param header the IPv6 header
350
   * \param header the IPv6 header
350
   * \param interface the interface from which the packet is coming
351
   * \param interface the interface from which the packet is coming
352
   * \returns the receive status
351
   */
353
   */
352
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
354
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
353
                                               Ipv6Header const &header,
355
                                               Ipv6Header const &header,
 Lines 363-373    Link Here 
363
365
364
  /**
366
  /**
365
   * \brief Lookup in the ND cache for the IPv6 address
367
   * \brief Lookup in the ND cache for the IPv6 address
368
   *
369
   * \note Unlike other Lookup method, it does not send NS request!
370
   *
366
   * \param dst destination address
371
   * \param dst destination address
367
   * \param device device
372
   * \param device device
368
   * \param cache the neighbor cache
373
   * \param cache the neighbor cache
369
   * \param hardwareDestination hardware address
374
   * \param hardwareDestination hardware address
370
   * \note Unlike other Lookup method, it does not send NS request!
375
   * \return true if the address is in the ND cache, the hardwareDestination is updated.
371
   */
376
   */
372
  bool Lookup (Ipv6Address dst, Ptr<NetDevice> device, Ptr<NdiscCache> cache, Address* hardwareDestination);
377
  bool Lookup (Ipv6Address dst, Ptr<NetDevice> device, Ptr<NdiscCache> cache, Address* hardwareDestination);
373
378
 Lines 423-429    Link Here 
423
  virtual void DoDispose ();
428
  virtual void DoDispose ();
424
429
425
private:
430
private:
426
  typedef std::list<Ptr<NdiscCache> > CacheList;
431
  typedef std::list<Ptr<NdiscCache> > CacheList; //!< container of NdiscCaches
427
432
428
  /**
433
  /**
429
   * \brief The node.
434
   * \brief The node.
 Lines 559-564    Link Here 
559
  /**
564
  /**
560
   * \brief Get the cache corresponding to the device.
565
   * \brief Get the cache corresponding to the device.
561
   * \param device the device
566
   * \param device the device
567
   * \returns the NdiscCache associated with the device
562
   */
568
   */
563
  Ptr<NdiscCache> FindCache (Ptr<NetDevice> device);
569
  Ptr<NdiscCache> FindCache (Ptr<NetDevice> device);
564
570
 Lines 569-575    Link Here 
569
  virtual IpL4Protocol::DownTargetCallback GetDownTarget (void) const;
575
  virtual IpL4Protocol::DownTargetCallback GetDownTarget (void) const;
570
  virtual IpL4Protocol::DownTargetCallback6 GetDownTarget6 (void) const;
576
  virtual IpL4Protocol::DownTargetCallback6 GetDownTarget6 (void) const;
571
577
572
  IpL4Protocol::DownTargetCallback6 m_downTarget;
578
  IpL4Protocol::DownTargetCallback6 m_downTarget; //!< callback to Ipv6::Send
573
579
574
};
580
};
575
581
(-)a/src/internet/model/ip-l4-protocol.h (-12 / +25 lines)
 Lines 47-52    Link Here 
47
class IpL4Protocol : public Object
47
class IpL4Protocol : public Object
48
{
48
{
49
public:
49
public:
50
  /**
51
   * \brief Rx status codes
52
   */
50
  enum RxStatus {
53
  enum RxStatus {
51
    RX_OK,
54
    RX_OK,
52
    RX_CSUM_FAILED,
55
    RX_CSUM_FAILED,
 Lines 54-59    Link Here 
54
    RX_ENDPOINT_UNREACH
57
    RX_ENDPOINT_UNREACH
55
  };
58
  };
56
59
60
  /**
61
   * \brief Get the type ID.
62
   * \return the object TypeId
63
   */
57
  static TypeId GetTypeId (void);
64
  static TypeId GetTypeId (void);
58
65
59
  virtual ~IpL4Protocol ();
66
  virtual ~IpL4Protocol ();
 Lines 64-93    Link Here 
64
  virtual int GetProtocolNumber (void) const = 0;
71
  virtual int GetProtocolNumber (void) const = 0;
65
72
66
  /**
73
  /**
74
   * \brief Called from lower-level layers to send the packet up in the stack.
67
   * \param p packet to forward up
75
   * \param p packet to forward up
68
   * \param header IPv4 Header information
76
   * \param header IPv4 Header information
69
   * \param incomingInterface the Ipv4Interface on which the packet arrived
77
   * \param incomingInterface the Ipv4Interface on which the packet arrived
70
   * 
78
   * \returns Rx status code
71
   * Called from lower-level layers to send the packet up
72
   * in the stack. 
73
   */
79
   */
74
  virtual enum RxStatus Receive (Ptr<Packet> p,
80
  virtual enum RxStatus Receive (Ptr<Packet> p,
75
                                 Ipv4Header const &header,
81
                                 Ipv4Header const &header,
76
                                 Ptr<Ipv4Interface> incomingInterface) = 0;
82
                                 Ptr<Ipv4Interface> incomingInterface) = 0;
77
83
78
  /**
84
  /**
85
   * \brief Called from lower-level layers to send the packet up in the stack.
79
   * \param p packet to forward up
86
   * \param p packet to forward up
80
   * \param header IPv6 Header information
87
   * \param header IPv6 Header information
81
   * \param incomingInterface the Ipv6Interface on which the packet arrived
88
   * \param incomingInterface the Ipv6Interface on which the packet arrived
82
   *
89
   * \returns Rx status code
83
   * Called from lower-level layers to send the packet up
84
   * in the stack.
85
   */
90
   */
86
  virtual enum RxStatus Receive (Ptr<Packet> p,
91
  virtual enum RxStatus Receive (Ptr<Packet> p,
87
                                 Ipv6Header const &header,
92
                                 Ipv6Header const &header,
88
                                 Ptr<Ipv6Interface> incomingInterface) = 0;
93
                                 Ptr<Ipv6Interface> incomingInterface) = 0;
89
94
90
  /**
95
  /**
96
   * \brief Called from lower-level layers to send the ICMP packet up in the stack.
91
   * \param icmpSource the source address of the icmp message
97
   * \param icmpSource the source address of the icmp message
92
   * \param icmpTtl the ttl of the icmp message
98
   * \param icmpTtl the ttl of the icmp message
93
   * \param icmpType the 'type' field of the icmp message
99
   * \param icmpType the 'type' field of the icmp message
 Lines 98-104    Link Here 
98
   *        the icmp message
104
   *        the icmp message
99
   * \param payloadDestination the destination address of the packet which
105
   * \param payloadDestination the destination address of the packet which
100
   *        triggered the icmp message.
106
   *        triggered the icmp message.
101
   * \param payload the first 8 bytes of the udp header of the packet
107
   * \param payload the first 8 bytes of the packet payload
102
   *        which triggered the icmp message.
108
   *        which triggered the icmp message.
103
   */
109
   */
104
  virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
110
  virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
 Lines 108-113    Link Here 
108
114
109
115
110
  /**
116
  /**
117
   * \brief Called from lower-level layers to send the ICMPv6 packet up in the stack.
111
   * \param icmpSource the source address of the icmp message
118
   * \param icmpSource the source address of the icmp message
112
   * \param icmpTtl the ttl of the icmp message
119
   * \param icmpTtl the ttl of the icmp message
113
   * \param icmpType the 'type' field of the icmp message
120
   * \param icmpType the 'type' field of the icmp message
 Lines 118-124    Link Here 
118
   *        the icmp message
125
   *        the icmp message
119
   * \param payloadDestination the destination address of the packet which
126
   * \param payloadDestination the destination address of the packet which
120
   *        triggered the icmp message.
127
   *        triggered the icmp message.
121
   * \param payload the first 8 bytes of the udp header of the packet
128
   * \param payload the first 8 bytes of the packet payload
122
   *        which triggered the icmp message.
129
   *        which triggered the icmp message.
123
   */
130
   */
124
  virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl,
131
  virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl,
 Lines 126-137    Link Here 
126
                            Ipv6Address payloadSource, Ipv6Address payloadDestination,
133
                            Ipv6Address payloadSource, Ipv6Address payloadDestination,
127
                            const uint8_t payload[8]);
134
                            const uint8_t payload[8]);
128
135
136
  /**
137
   * \brief callback to send packets over IPv4
138
   */
129
  typedef Callback<void,Ptr<Packet>, Ipv4Address, Ipv4Address, uint8_t, Ptr<Ipv4Route> > DownTargetCallback;
139
  typedef Callback<void,Ptr<Packet>, Ipv4Address, Ipv4Address, uint8_t, Ptr<Ipv4Route> > DownTargetCallback;
140
  /**
141
   * \brief callback to send packets over IPv6
142
   */
130
  typedef Callback<void,Ptr<Packet>, Ipv6Address, Ipv6Address, uint8_t, Ptr<Ipv6Route> > DownTargetCallback6;
143
  typedef Callback<void,Ptr<Packet>, Ipv6Address, Ipv6Address, uint8_t, Ptr<Ipv6Route> > DownTargetCallback6;
131
144
132
  /**
145
  /**
133
   * This method allows a caller to set the current down target callback
146
   * This method allows a caller to set the current down target callback
134
   * set for this L4 protocol
147
   * set for this L4 protocol (IPv4 case)
135
   *
148
   *
136
   * \param cb current Callback for the L4 protocol
149
   * \param cb current Callback for the L4 protocol
137
   */
150
   */
 Lines 139-145    Link Here 
139
152
140
  /**
153
  /**
141
   * This method allows a caller to set the current down target callback
154
   * This method allows a caller to set the current down target callback
142
   * set for this L4 protocol
155
   * set for this L4 protocol (IPv6 case)
143
   *
156
   *
144
   * \param cb current Callback for the L4 protocol
157
   * \param cb current Callback for the L4 protocol
145
   */
158
   */
 Lines 147-153    Link Here 
147
160
148
  /**
161
  /**
149
   * This method allows a caller to get the current down target callback
162
   * This method allows a caller to get the current down target callback
150
   * set for this L4 protocol, for
163
   * set for this L4 protocol (IPv4 case)
151
   *
164
   *
152
   * \return current Callback for the L4 protocol
165
   * \return current Callback for the L4 protocol
153
   */
166
   */
 Lines 155-161    Link Here 
155
168
156
  /**
169
  /**
157
   * This method allows a caller to get the current down target callback
170
   * This method allows a caller to get the current down target callback
158
   * set for this L4 protocol, for
171
   * set for this L4 protocol (IPv6 case)
159
   *
172
   *
160
   * \return current Callback for the L4 protocol
173
   * \return current Callback for the L4 protocol
161
   */
174
   */
(-)a/src/internet/model/ipv4-address-generator.cc (-13 / +120 lines)
 Lines 27-79    Link Here 
27
27
28
namespace ns3 {
28
namespace ns3 {
29
29
30
/**
31
 * \internal
32
 * \ingroup address
33
 *
34
 * \brief Implementation class of Ipv4AddressGenerator
35
 * This generator assigns addresses sequentially from a provided
36
 * network address; used in topology code. It also keeps track of all
37
 * addresses assigned to perform duplicate detection.
38
 */
30
class Ipv4AddressGeneratorImpl
39
class Ipv4AddressGeneratorImpl
31
{
40
{
32
public:
41
public:
33
  Ipv4AddressGeneratorImpl ();
42
  Ipv4AddressGeneratorImpl ();
34
  virtual ~Ipv4AddressGeneratorImpl ();
43
  virtual ~Ipv4AddressGeneratorImpl ();
35
44
45
  /**
46
   * \internal
47
   * \brief Initialise the base network, mask and address for the generator
48
   *
49
   * The first call to NextAddress() or GetAddress() will return the
50
   * value passed in.
51
   *
52
   * \param net The network for the base Ipv4Address
53
   * \param mask The network mask of the base Ipv4Address
54
   * \param addr The base address used for initialization
55
   */
36
  void Init (const Ipv4Address net, const Ipv4Mask mask, 
56
  void Init (const Ipv4Address net, const Ipv4Mask mask, 
37
             const Ipv4Address addr);
57
             const Ipv4Address addr);
38
58
59
  /**
60
   * \internal
61
   * \brief Get the current network of the given Ipv4Mask
62
   *
63
   * Does not change the internal state; this just peeks at the current
64
   * network
65
   *
66
   * \param mask The Ipv4Mask for the current network
67
   * \returns the IPv4 address of the current network
68
   */
39
  Ipv4Address GetNetwork (const Ipv4Mask mask) const;
69
  Ipv4Address GetNetwork (const Ipv4Mask mask) const;
70
71
  /**
72
   * \internal
73
   * \brief Get the next network according to the given Ipv4Mask
74
   *
75
   * This operation is a pre-increment, meaning that the internal state
76
   * is changed before returning the new network address.
77
   *
78
   * This also resets the address to the base address that was
79
   * used for initialization.
80
   *
81
   * \param mask The Ipv4Mask used to set the next network
82
   * \returns the IPv4 address of the next network
83
   */
40
  Ipv4Address NextNetwork (const Ipv4Mask mask);
84
  Ipv4Address NextNetwork (const Ipv4Mask mask);
41
85
86
  /**
87
   * \internal
88
   * \brief Set the address for the given mask
89
   *
90
   * \param addr The address to set for the current mask
91
   * \param mask The Ipv4Mask whose address is to be set
92
   */
42
  void InitAddress (const Ipv4Address addr, const Ipv4Mask mask);
93
  void InitAddress (const Ipv4Address addr, const Ipv4Mask mask);
43
  Ipv4Address GetAddress (const Ipv4Mask mask) const;
94
95
  /**
96
   * \internal
97
   * \brief Allocate the next Ipv4Address for the configured network and mask
98
   *
99
   * This operation is a post-increment, meaning that the first address
100
   * allocated will be the one that was initially configured.
101
   *
102
   * \param mask The Ipv4Mask for the current network
103
   * \returns the IPv4 address
104
   */
44
  Ipv4Address NextAddress (const Ipv4Mask mask);
105
  Ipv4Address NextAddress (const Ipv4Mask mask);
45
106
107
  /**
108
   * \internal
109
   * \brief Get the Ipv4Address that will be allocated upon NextAddress ()
110
   *
111
   * Does not change the internal state; just is used to peek the next
112
   * address that will be allocated upon NextAddress ()
113
   *
114
   * \param mask The Ipv4Mask for the current network
115
   * \returns the IPv4 address
116
   */
117
  Ipv4Address GetAddress (const Ipv4Mask mask) const;
118
119
  /**
120
   * \internal
121
   * \brief Reset the networks and Ipv4Address to zero
122
   */
46
  void Reset (void);
123
  void Reset (void);
124
125
  /**
126
   * \internal
127
   * \brief Add the Ipv4Address to the list of IPv4 entries
128
   *
129
   * Typically, this is used by external address allocators that want
130
   * to make use of this class's ability to track duplicates.  AddAllocated
131
   * is always called internally for any address generated by NextAddress ()
132
   *
133
   * \param addr The Ipv4Address to be added to the list of Ipv4 entries
134
   * \returns true on success
135
   */
47
  bool AddAllocated (const Ipv4Address addr);
136
  bool AddAllocated (const Ipv4Address addr);
48
137
138
  /**
139
   * \internal
140
   * \brief Used to turn off fatal errors and assertions, for testing
141
   */
49
  void TestMode (void);
142
  void TestMode (void);
50
private:
143
private:
51
  static const uint32_t N_BITS = 32;
144
  static const uint32_t N_BITS = 32;  //!< /internal the number of bits in the address
52
  static const uint32_t MOST_SIGNIFICANT_BIT = 0x80000000;
145
  static const uint32_t MOST_SIGNIFICANT_BIT = 0x80000000; //!< /internal MSB set to 1
53
146
147
  /**
148
   * \internal
149
   * \brief Create an index number for the network mask
150
   * \param mask the mask to index
151
   * \returns an index
152
   */
54
  uint32_t MaskToIndex (Ipv4Mask mask) const;
153
  uint32_t MaskToIndex (Ipv4Mask mask) const;
55
154
155
  /**
156
   * \internal
157
   * \brief This class holds the state for a given network
158
   */
56
  class NetworkState
159
  class NetworkState
57
  {
160
  {
58
public:
161
public:
59
    uint32_t mask;
162
    uint32_t mask;      //!< /internal the network mask
60
    uint32_t shift;
163
    uint32_t shift;     //!< /internal a shift
61
    uint32_t network;
164
    uint32_t network;   //!< /internal the network
62
    uint32_t addr;
165
    uint32_t addr;      //!< /internal the address
63
    uint32_t addrMax;
166
    uint32_t addrMax;   //!< /internal the maximum address
64
  };
167
  };
65
168
66
  NetworkState m_netTable[N_BITS];
169
  NetworkState m_netTable[N_BITS]; //!< /internal the available networks
67
170
171
  /**
172
   * \internal
173
   * \brief This class holds the allocated addresses
174
   */
68
  class Entry
175
  class Entry
69
  {
176
  {
70
public:
177
public:
71
    uint32_t addrLow;
178
    uint32_t addrLow;  //!< /internal the lowest allocated address
72
    uint32_t addrHigh;
179
    uint32_t addrHigh; //!< /internal the highest allocated address
73
  };
180
  };
74
181
75
  std::list<Entry> m_entries;
182
  std::list<Entry> m_entries; //!< /internal contained of allocated addresses
76
  bool m_test;
183
  bool m_test; //!< /internal test mode (if true)
77
};
184
};
78
185
79
Ipv4AddressGeneratorImpl::Ipv4AddressGeneratorImpl () 
186
Ipv4AddressGeneratorImpl::Ipv4AddressGeneratorImpl () 
(-)a/src/internet/model/ipv4-address-generator.h (+81 lines)
 Lines 28-49    Link Here 
28
 *
28
 *
29
 * \brief This generator assigns addresses sequentially from a provided
29
 * \brief This generator assigns addresses sequentially from a provided
30
 * network address; used in topology code.
30
 * network address; used in topology code.
31
 *
32
 * \note BEWARE: this class acts as a Singleton.
33
 * In other terms, two different instances of Ipv4AddressGenerator will
34
 * pick IPv4 numbers from the same pool. Changing the network in one of them
35
 * will also change the network in the other instances.
36
 *
31
 */
37
 */
32
class Ipv4AddressGenerator {
38
class Ipv4AddressGenerator {
33
public:
39
public:
40
  /**
41
   * \brief Initialise the base network, mask and address for the generator
42
   *
43
   * The first call to NextAddress() or GetAddress() will return the
44
   * value passed in.
45
   *
46
   * \param net The network for the base Ipv4Address
47
   * \param mask The network mask of the base Ipv4Address
48
   * \param addr The base address used for initialization
49
   */
34
  static void Init (const Ipv4Address net, const Ipv4Mask mask, 
50
  static void Init (const Ipv4Address net, const Ipv4Mask mask, 
35
                    const Ipv4Address addr = "0.0.0.1");
51
                    const Ipv4Address addr = "0.0.0.1");
36
52
53
  /**
54
   * \brief Get the next network according to the given Ipv4Mask
55
   *
56
   * This operation is a pre-increment, meaning that the internal state
57
   * is changed before returning the new network address.
58
   *
59
   * This also resets the address to the base address that was
60
   * used for initialization.
61
   *
62
   * \param mask The Ipv4Mask used to set the next network
63
   * \returns the IPv4 address of the next network
64
   */
37
  static Ipv4Address NextNetwork (const Ipv4Mask mask);
65
  static Ipv4Address NextNetwork (const Ipv4Mask mask);
66
67
  /**
68
   * \brief Get the current network of the given Ipv4Mask
69
   *
70
   * Does not change the internal state; this just peeks at the current
71
   * network
72
   *
73
   * \param mask The Ipv4Mask for the current network
74
   * \returns the IPv4 address of the current network
75
   */
38
  static Ipv4Address GetNetwork (const Ipv4Mask mask);
76
  static Ipv4Address GetNetwork (const Ipv4Mask mask);
39
77
78
  /**
79
   * \brief Set the address for the given mask
80
   *
81
   * \param addr The address to set for the current mask
82
   * \param mask The Ipv4Mask whose address is to be set
83
   */
40
  static void InitAddress (const Ipv4Address addr, const Ipv4Mask mask);
84
  static void InitAddress (const Ipv4Address addr, const Ipv4Mask mask);
85
86
  /**
87
   * \brief Allocate the next Ipv4Address for the configured network and mask
88
   *
89
   * This operation is a post-increment, meaning that the first address
90
   * allocated will be the one that was initially configured.
91
   *
92
   * \param mask The Ipv4Mask for the current network
93
   * \returns the IPv4 address
94
   */
41
  static Ipv4Address NextAddress (const Ipv4Mask mask);
95
  static Ipv4Address NextAddress (const Ipv4Mask mask);
96
97
  /**
98
   * \brief Get the Ipv4Address that will be allocated upon NextAddress ()
99
   *
100
   * Does not change the internal state; just is used to peek the next
101
   * address that will be allocated upon NextAddress ()
102
   *
103
   * \param mask The Ipv4Mask for the current network
104
   * \returns the IPv4 address
105
   */
42
  static Ipv4Address GetAddress (const Ipv4Mask mask);
106
  static Ipv4Address GetAddress (const Ipv4Mask mask);
43
107
108
  /**
109
   * \brief Reset the networks and Ipv4Address to zero
110
   */
44
  static void Reset (void);
111
  static void Reset (void);
112
113
  /**
114
   * \brief Add the Ipv4Address to the list of IPv4 entries
115
   *
116
   * Typically, this is used by external address allocators that want
117
   * to make use of this class's ability to track duplicates.  AddAllocated
118
   * is always called internally for any address generated by NextAddress ()
119
   *
120
   * \param addr The Ipv4Address to be added to the list of Ipv4 entries
121
   * \returns true on success
122
   */
45
  static bool AddAllocated (const Ipv4Address addr);
123
  static bool AddAllocated (const Ipv4Address addr);
46
124
125
  /**
126
   * \brief Used to turn off fatal errors and assertions, for testing
127
   */
47
  static void TestMode (void);
128
  static void TestMode (void);
48
};
129
};
49
130
(-)a/src/internet/model/ipv4-end-point-demux.h (+98 lines)
 Lines 42-84    Link Here 
42
42
43
class Ipv4EndPointDemux {
43
class Ipv4EndPointDemux {
44
public:
44
public:
45
  /**
46
   * \brief Container of the IPv4 endpoints.
47
   */
45
  typedef std::list<Ipv4EndPoint *> EndPoints;
48
  typedef std::list<Ipv4EndPoint *> EndPoints;
49
50
  /**
51
   * \brief Iterator to the container of the IPv4 endpoints.
52
   */
46
  typedef std::list<Ipv4EndPoint *>::iterator EndPointsI;
53
  typedef std::list<Ipv4EndPoint *>::iterator EndPointsI;
47
54
48
  Ipv4EndPointDemux ();
55
  Ipv4EndPointDemux ();
49
  ~Ipv4EndPointDemux ();
56
  ~Ipv4EndPointDemux ();
50
57
58
  /**
59
   * \brief Get the entire list of end points registered.
60
   * \return list of Ipv4EndPoint
61
   */
51
  EndPoints GetAllEndPoints (void);
62
  EndPoints GetAllEndPoints (void);
63
64
  /**
65
   * \brief Lookup for port local.
66
   * \param port port to test
67
   * \return true if a port local is in EndPoints, false otherwise
68
   */
52
  bool LookupPortLocal (uint16_t port);
69
  bool LookupPortLocal (uint16_t port);
70
71
  /**
72
   * \brief Lookup for address and port.
73
   * \param addr address to test
74
   * \param port port to test
75
   * \return true if there is a match in EndPoints, false otherwise
76
   */
53
  bool LookupLocal (Ipv4Address addr, uint16_t port);
77
  bool LookupLocal (Ipv4Address addr, uint16_t port);
78
79
  /**
80
   * \brief lookup for a match with all the parameters.
81
   * \param daddr destination address to test
82
   * \param dport destination port to test
83
   * \param saddr source address to test
84
   * \param sport source port to test
85
   * \param incomingInterface the incoming interface
86
   * \return list of IPv4EndPoints (could be 0 element)
87
   */
54
  EndPoints Lookup (Ipv4Address daddr, 
88
  EndPoints Lookup (Ipv4Address daddr, 
55
                    uint16_t dport, 
89
                    uint16_t dport, 
56
                    Ipv4Address saddr, 
90
                    Ipv4Address saddr, 
57
                    uint16_t sport,
91
                    uint16_t sport,
58
                    Ptr<Ipv4Interface> incomingInterface);
92
                    Ptr<Ipv4Interface> incomingInterface);
59
93
94
  /**
95
   * \brief simple lookup for a match with all the parameters.
96
   * \param daddr destination address to test
97
   * \param dport destination port to test
98
   * \param saddr source address to test
99
   * \param sport source port to test
100
   * \return IPv4EndPoint (0 if not found)
101
   */
60
  Ipv4EndPoint *SimpleLookup (Ipv4Address daddr, 
102
  Ipv4EndPoint *SimpleLookup (Ipv4Address daddr, 
61
                              uint16_t dport, 
103
                              uint16_t dport, 
62
                              Ipv4Address saddr, 
104
                              Ipv4Address saddr, 
63
                              uint16_t sport);
105
                              uint16_t sport);
64
106
107
  /**
108
   * \brief Allocate a Ipv4EndPoint.
109
   * \return an empty Ipv4EndPoint instance
110
   */
65
  Ipv4EndPoint *Allocate (void);
111
  Ipv4EndPoint *Allocate (void);
112
113
  /**
114
   * \brief Allocate a Ipv4EndPoint.
115
   * \param address IPv4 address
116
   * \return an Ipv4EndPoint instance
117
   */
66
  Ipv4EndPoint *Allocate (Ipv4Address address);
118
  Ipv4EndPoint *Allocate (Ipv4Address address);
119
120
  /**
121
   * \brief Allocate a Ipv4EndPoint.
122
   * \param port local port
123
   * \return an Ipv4EndPoint instance
124
   */
67
  Ipv4EndPoint *Allocate (uint16_t port);
125
  Ipv4EndPoint *Allocate (uint16_t port);
126
127
  /**
128
   * \brief Allocate a Ipv4EndPoint.
129
   * \param address local address
130
   * \param port local port
131
   * \return an Ipv4EndPoint instance
132
   */
68
  Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
133
  Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
134
135
  /**
136
   * \brief Allocate a Ipv4EndPoint.
137
   * \param localAddress local address
138
   * \param localPort local port
139
   * \param peerAddress peer address
140
   * \param peerPort peer port
141
   * \return an Ipv4EndPoint instance
142
   */
69
  Ipv4EndPoint *Allocate (Ipv4Address localAddress, 
143
  Ipv4EndPoint *Allocate (Ipv4Address localAddress, 
70
                          uint16_t localPort,
144
                          uint16_t localPort,
71
                          Ipv4Address peerAddress, 
145
                          Ipv4Address peerAddress, 
72
                          uint16_t peerPort);
146
                          uint16_t peerPort);
73
147
148
  /**
149
   * \brief Remove a end point.
150
   * \param endPoint the end point to remove
151
   */
74
  void DeAllocate (Ipv4EndPoint *endPoint);
152
  void DeAllocate (Ipv4EndPoint *endPoint);
75
153
76
private:
154
private:
155
156
  /**
157
   * \brief Allocate an ephemeral port.
158
   * \returns the ephemeral port
159
   */
77
  uint16_t AllocateEphemeralPort (void);
160
  uint16_t AllocateEphemeralPort (void);
78
161
162
  /**
163
   * \brief The ephemeral port.
164
   */
79
  uint16_t m_ephemeral;
165
  uint16_t m_ephemeral;
166
167
  /**
168
   * \brief The last ephemeral port.
169
   */
80
  uint16_t m_portLast;
170
  uint16_t m_portLast;
171
172
  /**
173
   * \brief The first ephemeral port.
174
   */
81
  uint16_t m_portFirst;
175
  uint16_t m_portFirst;
176
177
  /**
178
   * \brief A list of IPv4 end points.
179
   */
82
  EndPoints m_endPoints;
180
  EndPoints m_endPoints;
83
};
181
};
84
182
(-)a/src/internet/model/ipv4-end-point.h (-5 / +145 lines)
 Lines 46-93    Link Here 
46
46
47
class Ipv4EndPoint {
47
class Ipv4EndPoint {
48
public:
48
public:
49
  /**
50
   * \brief Constructor.
51
   * \param address the IPv4 address
52
   * \param port the port
53
   */
49
  Ipv4EndPoint (Ipv4Address address, uint16_t port);
54
  Ipv4EndPoint (Ipv4Address address, uint16_t port);
50
  ~Ipv4EndPoint ();
55
  ~Ipv4EndPoint ();
51
56
57
  /**
58
   * \brief Get the local address.
59
   * \return the local address
60
   */
52
  Ipv4Address GetLocalAddress (void);
61
  Ipv4Address GetLocalAddress (void);
62
63
  /**
64
   * \brief Set the local address.
65
   * \param address the address to set
66
   */
53
  void SetLocalAddress (Ipv4Address address);
67
  void SetLocalAddress (Ipv4Address address);
68
69
  /**
70
   * \brief Get the local port.
71
   * \return the local port
72
   */
54
  uint16_t GetLocalPort (void);
73
  uint16_t GetLocalPort (void);
74
75
  /**
76
   * \brief Get the peer address.
77
   * \return the peer address
78
   */
55
  Ipv4Address GetPeerAddress (void);
79
  Ipv4Address GetPeerAddress (void);
80
81
  /**
82
   * \brief Get the peer port.
83
   * \return the peer port
84
   */
56
  uint16_t GetPeerPort (void);
85
  uint16_t GetPeerPort (void);
57
86
87
  /**
88
   * \brief Set the peer informations (address and port).
89
   * \param address peer address
90
   * \param port peer port
91
   */
58
  void SetPeer (Ipv4Address address, uint16_t port);
92
  void SetPeer (Ipv4Address address, uint16_t port);
59
93
94
  /**
95
   * \brief Bind a socket to specific device.
96
   *
97
   * This method corresponds to using setsockopt() SO_BINDTODEVICE
98
   * of real network or BSD sockets.   If set on a socket, this option will
99
   * force packets to leave the bound device regardless of the device that
100
   * IP routing would naturally choose.  In the receive direction, only
101
   * packets received from the bound interface will be delivered.
102
   *
103
   * This option has no particular relationship to binding sockets to
104
   * an address via Socket::Bind ().  It is possible to bind sockets to a
105
   * specific IP address on the bound interface by calling both
106
   * Socket::Bind (address) and Socket::BindToNetDevice (device), but it
107
   * is also possible to bind to mismatching device and address, even if
108
   * the socket can not receive any packets as a result.
109
   *
110
   * \param netdevice Pointer to Netdevice of desired interface
111
   */
60
  void BindToNetDevice (Ptr<NetDevice> netdevice);
112
  void BindToNetDevice (Ptr<NetDevice> netdevice);
113
114
  /**
115
   * \brief Returns socket's bound netdevice, if any.
116
   *
117
   * This method corresponds to using getsockopt() SO_BINDTODEVICE
118
   * of real network or BSD sockets.
119
   *
120
   *
121
   * \returns Pointer to interface.
122
   */
61
  Ptr<NetDevice> GetBoundNetDevice (void);
123
  Ptr<NetDevice> GetBoundNetDevice (void);
62
124
63
  // Called from socket implementations to get notified about important events.
125
  // Called from socket implementations to get notified about important events.
126
  /**
127
   * \brief Set the reception callback.
128
   * \param callback callback function
129
   */
64
  void SetRxCallback (Callback<void,Ptr<Packet>, Ipv4Header, uint16_t, Ptr<Ipv4Interface> > callback);
130
  void SetRxCallback (Callback<void,Ptr<Packet>, Ipv4Header, uint16_t, Ptr<Ipv4Interface> > callback);
131
  /**
132
   * \brief Set the ICMP callback.
133
   * \param callback callback function
134
   */
65
  void SetIcmpCallback (Callback<void,Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> callback);
135
  void SetIcmpCallback (Callback<void,Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> callback);
136
  /**
137
   * \brief Set the default destroy callback.
138
   * \param callback callback function
139
   */
66
  void SetDestroyCallback (Callback<void> callback);
140
  void SetDestroyCallback (Callback<void> callback);
67
141
68
  // Called from an L4Protocol implementation to notify an endpoint of a
142
  /**
69
  // packet reception.
143
   * \brief Forward the packet to the upper level.
144
   *
145
   * Called from an L4Protocol implementation to notify an endpoint of a
146
   * packet reception.
147
   * \param p the packet
148
   * \param header the packet header
149
   * \param sport source port
150
   * \param incomingInterface incoming interface
151
   */
70
  void ForwardUp (Ptr<Packet> p, const Ipv4Header& header, uint16_t sport, 
152
  void ForwardUp (Ptr<Packet> p, const Ipv4Header& header, uint16_t sport, 
71
                  Ptr<Ipv4Interface> incomingInterface);
153
                  Ptr<Ipv4Interface> incomingInterface);
72
  // Called from an L4Protocol implementation to notify an endpoint of
154
73
  // an icmp message reception.
155
  /**
156
   * \brief Forward the ICMP packet to the upper level.
157
   *
158
   * Called from an L4Protocol implementation to notify an endpoint of
159
   * an icmp message reception.
160
   *
161
   * \param icmpSource source IP address
162
   * \param icmpTtl time-to-live
163
   * \param icmpType ICMP type
164
   * \param icmpCode ICMP code
165
   * \param icmpInfo ICMP info
166
   */
74
  void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, 
167
  void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, 
75
                    uint8_t icmpType, uint8_t icmpCode,
168
                    uint8_t icmpType, uint8_t icmpCode,
76
                    uint32_t icmpInfo);
169
                    uint32_t icmpInfo);
77
170
78
private:
171
private:
172
  /**
173
   * \brief ForwardUp wrapper.
174
   * \param p packet
175
   * \param header the packet header
176
   * \param sport source port
177
   * \param incomingInterface incoming interface
178
   */
79
  void DoForwardUp (Ptr<Packet> p, const Ipv4Header& header, uint16_t sport,
179
  void DoForwardUp (Ptr<Packet> p, const Ipv4Header& header, uint16_t sport,
80
                    Ptr<Ipv4Interface> incomingInterface);
180
                    Ptr<Ipv4Interface> incomingInterface);
81
  void DoForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, 
181
  /**
182
   * \brief ForwardIcmp wrapper.
183
   * \param icmpSource source IP address
184
   * \param icmpTtl time-to-live
185
   * \param icmpType ICMP type
186
   * \param icmpCode ICMP code
187
   * \param icmpInfo ICMP info
188
   */
189
  void DoForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
82
                      uint8_t icmpType, uint8_t icmpCode,
190
                      uint8_t icmpType, uint8_t icmpCode,
83
                      uint32_t icmpInfo);
191
                      uint32_t icmpInfo);
192
193
  /**
194
   * \brief The local address.
195
   */
84
  Ipv4Address m_localAddr;
196
  Ipv4Address m_localAddr;
197
198
  /**
199
   * \brief The local port.
200
   */
85
  uint16_t m_localPort;
201
  uint16_t m_localPort;
202
203
  /**
204
   * \brief The peer address.
205
   */
86
  Ipv4Address m_peerAddr;
206
  Ipv4Address m_peerAddr;
207
208
  /**
209
   * \brief The peer port.
210
   */
87
  uint16_t m_peerPort;
211
  uint16_t m_peerPort;
212
213
  /**
214
   * \brief The NetDevice the EndPoint is bound to (if any).
215
   */
88
  Ptr<NetDevice> m_boundnetdevice;
216
  Ptr<NetDevice> m_boundnetdevice;
217
218
  /**
219
   * \brief The RX callback.
220
   */
89
  Callback<void,Ptr<Packet>, Ipv4Header, uint16_t, Ptr<Ipv4Interface> > m_rxCallback;
221
  Callback<void,Ptr<Packet>, Ipv4Header, uint16_t, Ptr<Ipv4Interface> > m_rxCallback;
222
223
  /**
224
   * \brief The ICMPv6 callback.
225
   */
90
  Callback<void,Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback;
226
  Callback<void,Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback;
227
228
  /**
229
   * \brief The destroy callback.
230
   */
91
  Callback<void> m_destroyCallback;
231
  Callback<void> m_destroyCallback;
92
};
232
};
93
233
(-)a/src/internet/model/ipv4-global-routing.h (-111 / +127 lines)
 Lines 69-83    Link Here 
69
class Ipv4GlobalRouting : public Ipv4RoutingProtocol
69
class Ipv4GlobalRouting : public Ipv4RoutingProtocol
70
{
70
{
71
public:
71
public:
72
  /**
73
   * \brief Get the type ID.
74
   * \return the object TypeId
75
   */
72
  static TypeId GetTypeId (void);
76
  static TypeId GetTypeId (void);
73
/**
77
  /**
74
 * \brief Construct an empty Ipv4GlobalRouting routing protocol,
78
   * \brief Construct an empty Ipv4GlobalRouting routing protocol,
75
 *
79
   *
76
 * The Ipv4GlobalRouting class supports host and network unicast routes.
80
   * The Ipv4GlobalRouting class supports host and network unicast routes.
77
 * This method initializes the lists containing these routes to empty.
81
   * This method initializes the lists containing these routes to empty.
78
 *
82
   *
79
 * \see Ipv4GlobalRouting
83
   * \see Ipv4GlobalRouting
80
 */
84
   */
81
  Ipv4GlobalRouting ();
85
  Ipv4GlobalRouting ();
82
  virtual ~Ipv4GlobalRouting ();
86
  virtual ~Ipv4GlobalRouting ();
83
87
 Lines 94-224    Link Here 
94
  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
98
  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
95
  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
99
  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
96
100
97
/**
101
  /**
98
 * \brief Add a host route to the global routing table.
102
   * \brief Add a host route to the global routing table.
99
 *
103
   *
100
 * \param dest The Ipv4Address destination for this route.
104
   * \param dest The Ipv4Address destination for this route.
101
 * \param nextHop The Ipv4Address of the next hop in the route.
105
   * \param nextHop The Ipv4Address of the next hop in the route.
102
 * \param interface The network interface index used to send packets to the
106
   * \param interface The network interface index used to send packets to the
103
 * destination.
107
   * destination.
104
 *
108
   *
105
 * \see Ipv4Address
109
   * \see Ipv4Address
106
 */
110
   */
107
  void AddHostRouteTo (Ipv4Address dest, 
111
  void AddHostRouteTo (Ipv4Address dest, 
108
                       Ipv4Address nextHop, 
112
                       Ipv4Address nextHop, 
109
                       uint32_t interface);
113
                       uint32_t interface);
110
/**
114
  /**
111
 * \brief Add a host route to the global routing table.
115
   * \brief Add a host route to the global routing table.
112
 *
116
   *
113
 * \param dest The Ipv4Address destination for this route.
117
   * \param dest The Ipv4Address destination for this route.
114
 * \param interface The network interface index used to send packets to the
118
   * \param interface The network interface index used to send packets to the
115
 * destination.
119
   * destination.
116
 *
120
   *
117
 * \see Ipv4Address
121
   * \see Ipv4Address
118
 */
122
   */
119
  void AddHostRouteTo (Ipv4Address dest, 
123
  void AddHostRouteTo (Ipv4Address dest, 
120
                       uint32_t interface);
124
                       uint32_t interface);
121
125
122
/**
126
  /**
123
 * \brief Add a network route to the global routing table.
127
   * \brief Add a network route to the global routing table.
124
 *
128
   *
125
 * \param network The Ipv4Address network for this route.
129
   * \param network The Ipv4Address network for this route.
126
 * \param networkMask The Ipv4Mask to extract the network.
130
   * \param networkMask The Ipv4Mask to extract the network.
127
 * \param nextHop The next hop in the route to the destination network.
131
   * \param nextHop The next hop in the route to the destination network.
128
 * \param interface The network interface index used to send packets to the
132
   * \param interface The network interface index used to send packets to the
129
 * destination.
133
   * destination.
130
 *
134
   *
131
 * \see Ipv4Address
135
   * \see Ipv4Address
132
 */
136
   */
133
  void AddNetworkRouteTo (Ipv4Address network, 
137
  void AddNetworkRouteTo (Ipv4Address network, 
134
                          Ipv4Mask networkMask, 
138
                          Ipv4Mask networkMask, 
135
                          Ipv4Address nextHop, 
139
                          Ipv4Address nextHop, 
136
                          uint32_t interface);
140
                          uint32_t interface);
137
141
138
/**
142
  /**
139
 * \brief Add a network route to the global routing table.
143
   * \brief Add a network route to the global routing table.
140
 *
144
   *
141
 * \param network The Ipv4Address network for this route.
145
   * \param network The Ipv4Address network for this route.
142
 * \param networkMask The Ipv4Mask to extract the network.
146
   * \param networkMask The Ipv4Mask to extract the network.
143
 * \param interface The network interface index used to send packets to the
147
   * \param interface The network interface index used to send packets to the
144
 * destination.
148
   * destination.
145
 *
149
   *
146
 * \see Ipv4Address
150
   * \see Ipv4Address
147
 */
151
   */
148
  void AddNetworkRouteTo (Ipv4Address network, 
152
  void AddNetworkRouteTo (Ipv4Address network, 
149
                          Ipv4Mask networkMask, 
153
                          Ipv4Mask networkMask, 
150
                          uint32_t interface);
154
                          uint32_t interface);
151
155
152
/**
156
  /**
153
 * \brief Add an external route to the global routing table.
157
   * \brief Add an external route to the global routing table.
154
 *
158
   *
155
 * \param network The Ipv4Address network for this route.
159
   * \param network The Ipv4Address network for this route.
156
 * \param networkMask The Ipv4Mask to extract the network.
160
   * \param networkMask The Ipv4Mask to extract the network.
157
 * \param nextHop The next hop Ipv4Address
161
   * \param nextHop The next hop Ipv4Address
158
 * \param interface The network interface index used to send packets to the
162
   * \param interface The network interface index used to send packets to the
159
 * destination.
163
   * destination.
160
 */
164
   */
161
  void AddASExternalRouteTo (Ipv4Address network,
165
  void AddASExternalRouteTo (Ipv4Address network,
162
                             Ipv4Mask networkMask,
166
                             Ipv4Mask networkMask,
163
                             Ipv4Address nextHop,
167
                             Ipv4Address nextHop,
164
                             uint32_t interface);
168
                             uint32_t interface);
165
169
166
/**
170
  /**
167
 * \brief Get the number of individual unicast routes that have been added
171
   * \brief Get the number of individual unicast routes that have been added
168
 * to the routing table.
172
   * to the routing table.
169
 *
173
   *
170
 * \warning The default route counts as one of the routes.
174
   * \warning The default route counts as one of the routes.
171
 */
175
   * \returns the number of routes
176
   */
172
  uint32_t GetNRoutes (void) const;
177
  uint32_t GetNRoutes (void) const;
173
178
174
/**
179
  /**
175
 * \brief Get a route from the global unicast routing table.
180
   * \brief Get a route from the global unicast routing table.
176
 *
181
   *
177
 * Externally, the unicast global routing table appears simply as a table with
182
   * Externally, the unicast global routing table appears simply as a table with
178
 * n entries.  The one subtlety of note is that if a default route has been set
183
   * n entries.  The one subtlety of note is that if a default route has been set
179
 * it will appear as the zeroth entry in the table.  This means that if you
184
   * it will appear as the zeroth entry in the table.  This means that if you
180
 * add only a default route, the table will have one entry that can be accessed
185
   * add only a default route, the table will have one entry that can be accessed
181
 * either by explicitly calling GetDefaultRoute () or by calling GetRoute (0).
186
   * either by explicitly calling GetDefaultRoute () or by calling GetRoute (0).
182
 * 
187
   *
183
 * Similarly, if the default route has been set, calling RemoveRoute (0) will
188
   * Similarly, if the default route has been set, calling RemoveRoute (0) will
184
 * remove the default route.
189
   * remove the default route.
185
 *
190
   *
186
 * \param i The index (into the routing table) of the route to retrieve.  If
191
   * \param i The index (into the routing table) of the route to retrieve.  If
187
 * the default route has been set, it will occupy index zero.
192
   * the default route has been set, it will occupy index zero.
188
 * \return If route is set, a pointer to that Ipv4RoutingTableEntry is returned, otherwise
193
   * \return If route is set, a pointer to that Ipv4RoutingTableEntry is returned, otherwise
189
 * a zero pointer is returned.
194
   * a zero pointer is returned.
190
 *
195
   *
191
 * \see Ipv4RoutingTableEntry
196
   * \see Ipv4RoutingTableEntry
192
 * \see Ipv4GlobalRouting::RemoveRoute
197
   * \see Ipv4GlobalRouting::RemoveRoute
193
 */
198
   */
194
  Ipv4RoutingTableEntry *GetRoute (uint32_t i) const;
199
  Ipv4RoutingTableEntry *GetRoute (uint32_t i) const;
195
200
196
/**
201
  /**
197
 * \brief Remove a route from the global unicast routing table.
202
   * \brief Remove a route from the global unicast routing table.
198
 *
203
   *
199
 * Externally, the unicast global routing table appears simply as a table with
204
   * Externally, the unicast global routing table appears simply as a table with
200
 * n entries.  The one subtlety of note is that if a default route has been set
205
   * n entries.  The one subtlety of note is that if a default route has been set
201
 * it will appear as the zeroth entry in the table.  This means that if the
206
   * it will appear as the zeroth entry in the table.  This means that if the
202
 * default route has been set, calling RemoveRoute (0) will remove the
207
   * default route has been set, calling RemoveRoute (0) will remove the
203
 * default route.
208
   * default route.
204
 *
209
   *
205
 * \param i The index (into the routing table) of the route to remove.  If
210
   * \param i The index (into the routing table) of the route to remove.  If
206
 * the default route has been set, it will occupy index zero.
211
   * the default route has been set, it will occupy index zero.
207
 *
212
   *
208
 * \see Ipv4RoutingTableEntry
213
   * \see Ipv4RoutingTableEntry
209
 * \see Ipv4GlobalRouting::GetRoute
214
   * \see Ipv4GlobalRouting::GetRoute
210
 * \see Ipv4GlobalRouting::AddRoute
215
   * \see Ipv4GlobalRouting::AddRoute
211
 */
216
   */
212
  void RemoveRoute (uint32_t i);
217
  void RemoveRoute (uint32_t i);
213
218
214
 /**
219
  /**
215
  * Assign a fixed random variable stream number to the random variables
220
   * Assign a fixed random variable stream number to the random variables
216
  * used by this model.  Return the number of streams (possibly zero) that
221
   * used by this model.  Return the number of streams (possibly zero) that
217
  * have been assigned.
222
   * have been assigned.
218
  *
223
   *
219
  * \param stream first stream index to use
224
   * \param stream first stream index to use
220
  * \return the number of stream indices assigned by this model
225
   * \return the number of stream indices assigned by this model
221
  */
226
   */
222
  int64_t AssignStreams (int64_t stream);
227
  int64_t AssignStreams (int64_t stream);
223
228
224
protected:
229
protected:
 Lines 232-254    Link Here 
232
  /// A uniform random number generator for randomly routing packets among ECMP 
237
  /// A uniform random number generator for randomly routing packets among ECMP 
233
  Ptr<UniformRandomVariable> m_rand;
238
  Ptr<UniformRandomVariable> m_rand;
234
239
240
  /// container of Ipv4RoutingTableEntry (routes to hosts)
235
  typedef std::list<Ipv4RoutingTableEntry *> HostRoutes;
241
  typedef std::list<Ipv4RoutingTableEntry *> HostRoutes;
242
  /// const iterator of container of Ipv4RoutingTableEntry (routes to hosts)
236
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator HostRoutesCI;
243
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator HostRoutesCI;
244
  /// iterator of container of Ipv4RoutingTableEntry (routes to hosts)
237
  typedef std::list<Ipv4RoutingTableEntry *>::iterator HostRoutesI;
245
  typedef std::list<Ipv4RoutingTableEntry *>::iterator HostRoutesI;
246
247
  /// container of Ipv4RoutingTableEntry (routes to networks)
238
  typedef std::list<Ipv4RoutingTableEntry *> NetworkRoutes;
248
  typedef std::list<Ipv4RoutingTableEntry *> NetworkRoutes;
249
  /// const iterator of container of Ipv4RoutingTableEntry (routes to networks)
239
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator NetworkRoutesCI;
250
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator NetworkRoutesCI;
251
  /// iterator of container of Ipv4RoutingTableEntry (routes to networks)
240
  typedef std::list<Ipv4RoutingTableEntry *>::iterator NetworkRoutesI;
252
  typedef std::list<Ipv4RoutingTableEntry *>::iterator NetworkRoutesI;
253
254
  /// container of Ipv4RoutingTableEntry (routes to external AS)
241
  typedef std::list<Ipv4RoutingTableEntry *> ASExternalRoutes;
255
  typedef std::list<Ipv4RoutingTableEntry *> ASExternalRoutes;
256
  /// const iterator of container of Ipv4RoutingTableEntry (routes to external AS)
242
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator ASExternalRoutesCI;
257
  typedef std::list<Ipv4RoutingTableEntry *>::const_iterator ASExternalRoutesCI;
258
  /// iterator of container of Ipv4RoutingTableEntry (routes to external AS)
243
  typedef std::list<Ipv4RoutingTableEntry *>::iterator ASExternalRoutesI;
259
  typedef std::list<Ipv4RoutingTableEntry *>::iterator ASExternalRoutesI;
244
260
245
  Ptr<Ipv4Route> LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif = 0);
261
  Ptr<Ipv4Route> LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif = 0);
246
262
247
  HostRoutes m_hostRoutes;
263
  HostRoutes m_hostRoutes;             //!< Routes to hosts
248
  NetworkRoutes m_networkRoutes;
264
  NetworkRoutes m_networkRoutes;       //!< Routes to networks
249
  ASExternalRoutes m_ASexternalRoutes; // External routes imported
265
  ASExternalRoutes m_ASexternalRoutes; //!< External routes imported
250
266
251
  Ptr<Ipv4> m_ipv4;
267
  Ptr<Ipv4> m_ipv4; //!< associated IPv4 instance
252
};
268
};
253
269
254
} // Namespace ns3
270
} // Namespace ns3
(-)a/src/internet/model/ipv4-header.h (-13 / +20 lines)
 Lines 172-177    Link Here 
172
   */
172
   */
173
  DscpType GetDscp (void) const;
173
  DscpType GetDscp (void) const;
174
  /**
174
  /**
175
   * \param dscp the dscp
175
   * \returns std::string of DSCPType
176
   * \returns std::string of DSCPType
176
   */
177
   */
177
  std::string DscpTypeToString (DscpType dscp) const;
178
  std::string DscpTypeToString (DscpType dscp) const;
 Lines 180-185    Link Here 
180
   */
181
   */
181
  EcnType GetEcn (void) const;
182
  EcnType GetEcn (void) const;
182
  /**
183
  /**
184
   * \param ecn the ECNType
183
   * \returns std::string of ECNType
185
   * \returns std::string of ECNType
184
   */
186
   */
185
  std::string EcnTypeToString (EcnType ecn) const;
187
  std::string EcnTypeToString (EcnType ecn) const;
 Lines 220-225    Link Here 
220
   */
222
   */
221
  bool IsChecksumOk (void) const;
223
  bool IsChecksumOk (void) const;
222
224
225
  /**
226
   * \brief Get the type ID.
227
   * \return the object TypeId
228
   */
223
  static TypeId GetTypeId (void);
229
  static TypeId GetTypeId (void);
224
  virtual TypeId GetInstanceTypeId (void) const;
230
  virtual TypeId GetInstanceTypeId (void) const;
225
  virtual void Print (std::ostream &os) const;
231
  virtual void Print (std::ostream &os) const;
 Lines 228-252    Link Here 
228
  virtual uint32_t Deserialize (Buffer::Iterator start);
234
  virtual uint32_t Deserialize (Buffer::Iterator start);
229
private:
235
private:
230
236
237
  /// flags related to IP fragmentation
231
  enum FlagsE {
238
  enum FlagsE {
232
    DONT_FRAGMENT = (1<<0),
239
    DONT_FRAGMENT = (1<<0),
233
    MORE_FRAGMENTS = (1<<1)
240
    MORE_FRAGMENTS = (1<<1)
234
  };
241
  };
235
242
236
  bool m_calcChecksum;
243
  bool m_calcChecksum; //!< true if the checksum must be calculated
237
244
238
  uint16_t m_payloadSize;
245
  uint16_t m_payloadSize; //!< payload size
239
  uint16_t m_identification;
246
  uint16_t m_identification; //!< identification
240
  uint32_t m_tos : 8; //Also used as DSCP + ECN value
247
  uint32_t m_tos : 8; //!< TOS, also used as DSCP + ECN value
241
  uint32_t m_ttl : 8;
248
  uint32_t m_ttl : 8; //!< TTL
242
  uint32_t m_protocol : 8;
249
  uint32_t m_protocol : 8;  //!< Protocol
243
  uint32_t m_flags : 3;
250
  uint32_t m_flags : 3; //!< flags
244
  uint16_t m_fragmentOffset;
251
  uint16_t m_fragmentOffset;  //!< Fragment offset
245
  Ipv4Address m_source;
252
  Ipv4Address m_source; //!< source address
246
  Ipv4Address m_destination;
253
  Ipv4Address m_destination; //!< destination address
247
  uint16_t m_checksum;
254
  uint16_t m_checksum; //!< checksum
248
  bool m_goodChecksum;
255
  bool m_goodChecksum; //!< true if checksum is correct
249
  uint16_t m_headerSize;
256
  uint16_t m_headerSize; //!< IP header size
250
};
257
};
251
258
252
} // namespace ns3
259
} // namespace ns3
(-)a/src/internet/model/ipv4-interface-address.h (-7 / +88 lines)
 Lines 42-47    Link Here 
42
class Ipv4InterfaceAddress 
42
class Ipv4InterfaceAddress 
43
{
43
{
44
public:
44
public:
45
  /**
46
   * \enum InterfaceAddressScope_e
47
   * \brief Address scope.
48
   */
45
  enum InterfaceAddressScope_e {
49
  enum InterfaceAddressScope_e {
46
    HOST,
50
    HOST,
47
    LINK,
51
    LINK,
 Lines 49-87    Link Here 
49
  };
53
  };
50
54
51
  Ipv4InterfaceAddress ();
55
  Ipv4InterfaceAddress ();
52
  // Configure m_local, m_mask, and m_broadcast from the below constructor
56
57
  /**
58
   * \brief Configure local address, mask and broadcast address
59
   * \param local the local address
60
   * \param mask the network mask
61
   */
53
  Ipv4InterfaceAddress (Ipv4Address local, Ipv4Mask mask);
62
  Ipv4InterfaceAddress (Ipv4Address local, Ipv4Mask mask);
63
  /**
64
   * Copy constructor
65
   * \param o the object to copy
66
   */
54
  Ipv4InterfaceAddress (const Ipv4InterfaceAddress &o);
67
  Ipv4InterfaceAddress (const Ipv4InterfaceAddress &o);
55
68
69
  /**
70
   * \brief Set local address
71
   * \param local the address
72
   */
56
  void SetLocal (Ipv4Address local);
73
  void SetLocal (Ipv4Address local);
74
  /**
75
   * \brief Get the local address
76
   * \returns the local address
77
   */
57
  Ipv4Address GetLocal (void) const;
78
  Ipv4Address GetLocal (void) const;
79
  /**
80
   * \brief Set the network mask
81
   * \param mask the network mask
82
   */
58
  void SetMask (Ipv4Mask mask);
83
  void SetMask (Ipv4Mask mask);
84
  /**
85
   * \brief Get the network mask
86
   * \returns the network mask
87
   */
59
  Ipv4Mask GetMask (void) const;
88
  Ipv4Mask GetMask (void) const;
89
  /**
90
   * \brief Set the broadcast address
91
   * \param broadcast the broadcast address
92
   */
60
  void SetBroadcast (Ipv4Address broadcast);
93
  void SetBroadcast (Ipv4Address broadcast);
94
  /**
95
   * \brief Get the broadcast address
96
   * \returns the broadcast address
97
   */
61
  Ipv4Address GetBroadcast (void) const;
98
  Ipv4Address GetBroadcast (void) const;
62
 
99
 
100
  /**
101
   * \brief Set the scope.
102
   * \param scope the scope of address
103
   */
63
  void SetScope (Ipv4InterfaceAddress::InterfaceAddressScope_e scope);
104
  void SetScope (Ipv4InterfaceAddress::InterfaceAddressScope_e scope);
105
106
  /**
107
   * \brief Get address scope.
108
   * \return scope
109
   */
64
  Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope (void) const;
110
  Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope (void) const;
65
111
112
  /**
113
   * \brief Check if the address is a secondary address
114
   *
115
   * Secondary address is used for multihoming
116
   * \returns true if the address is secondary
117
   */
66
  bool IsSecondary (void) const;
118
  bool IsSecondary (void) const;
119
120
  /**
121
   * \brief Make the address secondary (used for multihoming)
122
   */
67
  void SetSecondary (void);
123
  void SetSecondary (void);
124
  /**
125
   * \brief Make the address primary
126
   */
68
  void SetPrimary (void);
127
  void SetPrimary (void);
69
128
70
private:
129
private:
71
130
72
  Ipv4Address m_local;     // Interface address
131
  Ipv4Address m_local;     //!< Interface address
73
  // Note:  m_peer may be added in future when necessary
132
  // Note:  m_peer may be added in future when necessary
74
  // Ipv4Address m_peer;      // Peer destination address (in Linux:  m_address)
133
  // Ipv4Address m_peer;   // Peer destination address (in Linux:  m_address)
75
  Ipv4Mask m_mask;         // Network mask
134
  Ipv4Mask m_mask;         //!< Network mask
76
  Ipv4Address m_broadcast; // Broadcast address
135
  Ipv4Address m_broadcast; //!< Broadcast address
77
136
78
  InterfaceAddressScope_e m_scope;
137
  InterfaceAddressScope_e m_scope; //!< Address scope
79
  bool m_secondary;        // For use in multihoming
138
  bool m_secondary;        //!< For use in multihoming
80
139
140
  /**
141
   * \brief Equal to operator.
142
   *
143
   * \param a the first operand
144
   * \param b the first operand
145
   * \returns true if the operands are equal
146
   */
81
  friend bool operator == (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b);
147
  friend bool operator == (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b);
148
149
  /**
150
   * \brief Not equal to operator.
151
   *
152
   * \param a the first operand
153
   * \param b the first operand
154
   * \returns true if the operands are not equal
155
   */
82
  friend bool operator != (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b);
156
  friend bool operator != (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b);
83
};
157
};
84
158
159
/**
160
 * \brief Stream insertion operator.
161
 *
162
 * \param os the reference to the output stream
163
 * \param addr the Ipv4InterfaceAddress
164
 * \returns the reference to the output stream
165
 */
85
std::ostream& operator<< (std::ostream& os, const Ipv4InterfaceAddress &addr);
166
std::ostream& operator<< (std::ostream& os, const Ipv4InterfaceAddress &addr);
86
167
87
inline bool operator == (const Ipv4InterfaceAddress &a, const Ipv4InterfaceAddress &b)
168
inline bool operator == (const Ipv4InterfaceAddress &a, const Ipv4InterfaceAddress &b)
(-)a/src/internet/model/ipv4-interface.h (-9 / +43 lines)
 Lines 43-62    Link Here 
43
 * specific information (addresses) about an interface.
43
 * specific information (addresses) about an interface.
44
 *
44
 *
45
 * By default, Ipv4 interface are created in the "down" state
45
 * By default, Ipv4 interface are created in the "down" state
46
 * no IP addresses.  Before becoming useable, the user must 
46
 * no IP addresses.  Before becoming usable, the user must
47
 * add an address of some type and invoke Setup on them.
47
 * add an address of some type and invoke Setup on them.
48
 */
48
 */
49
class Ipv4Interface  : public Object
49
class Ipv4Interface  : public Object
50
{
50
{
51
public:
51
public:
52
  /**
53
   * \brief Get the type ID
54
   * \return type ID
55
   */
52
  static TypeId GetTypeId (void);
56
  static TypeId GetTypeId (void);
53
57
54
  Ipv4Interface ();
58
  Ipv4Interface ();
55
  virtual ~Ipv4Interface();
59
  virtual ~Ipv4Interface();
56
60
61
  /**
62
   * \brief Set node associated with interface.
63
   * \param node node
64
   */
57
  void SetNode (Ptr<Node> node); 
65
  void SetNode (Ptr<Node> node); 
66
  /**
67
   * \brief Set the NetDevice.
68
   * \param device NetDevice
69
   */
58
  void SetDevice (Ptr<NetDevice> device);
70
  void SetDevice (Ptr<NetDevice> device);
59
  void SetArpCache (Ptr<ArpCache>);
71
  /**
72
   * \brief Set ARP cache used by this interface
73
   * \param arpCache the ARP cache
74
   */
75
  void SetArpCache (Ptr<ArpCache> arpCache);
60
76
61
  /**
77
  /**
62
   * \returns the underlying NetDevice. This method cannot return zero.
78
   * \returns the underlying NetDevice. This method cannot return zero.
 Lines 164-181    Link Here 
164
protected:
180
protected:
165
  virtual void DoDispose (void);
181
  virtual void DoDispose (void);
166
private:
182
private:
183
  /**
184
   * \brief Initialize interface.
185
   */
167
  void DoSetup (void);
186
  void DoSetup (void);
187
188
189
  /**
190
   * \brief Container for the Ipv4InterfaceAddresses.
191
   */
168
  typedef std::list<Ipv4InterfaceAddress> Ipv4InterfaceAddressList;
192
  typedef std::list<Ipv4InterfaceAddress> Ipv4InterfaceAddressList;
193
194
  /**
195
   * \brief Container Iterator for the Ipv4InterfaceAddresses.
196
   */
169
  typedef std::list<Ipv4InterfaceAddress>::const_iterator Ipv4InterfaceAddressListCI;
197
  typedef std::list<Ipv4InterfaceAddress>::const_iterator Ipv4InterfaceAddressListCI;
198
199
  /**
200
   * \brief Const Container Iterator for the Ipv4InterfaceAddresses.
201
   */
170
  typedef std::list<Ipv4InterfaceAddress>::iterator Ipv4InterfaceAddressListI;
202
  typedef std::list<Ipv4InterfaceAddress>::iterator Ipv4InterfaceAddressListI;
171
203
172
  bool m_ifup;
204
173
  bool m_forwarding;  // IN_DEV_FORWARD
205
174
  uint16_t m_metric;
206
  bool m_ifup; //!< The state of this interface
175
  Ipv4InterfaceAddressList m_ifaddrs;
207
  bool m_forwarding;  //!< Forwarding state.
176
  Ptr<Node> m_node;
208
  uint16_t m_metric;  //!< Interface metric
177
  Ptr<NetDevice> m_device;
209
  Ipv4InterfaceAddressList m_ifaddrs; //!< Address list
178
  Ptr<ArpCache> m_cache; 
210
  Ptr<Node> m_node; //!< The associated node
211
  Ptr<NetDevice> m_device; //!< The associated NetDevice
212
  Ptr<ArpCache> m_cache; //!< ARP cache
179
};
213
};
180
214
181
} // namespace ns3
215
} // namespace ns3
(-)a/src/internet/model/ipv4-l3-protocol.cc (-3 / +3 lines)
 Lines 688-696    Link Here 
688
    }
688
    }
689
}
689
}
690
690
691
/// \todo when should we set ip_id?   check whether we are incrementing
691
// \todo when should we set ip_id?   check whether we are incrementing
692
/// m_identification on packets that may later be dropped in this stack
692
// m_identification on packets that may later be dropped in this stack
693
/// and whether that deviates from Linux
693
// and whether that deviates from Linux
694
Ipv4Header
694
Ipv4Header
695
Ipv4L3Protocol::BuildHeader (
695
Ipv4L3Protocol::BuildHeader (
696
  Ipv4Address source,
696
  Ipv4Address source,
(-)a/src/internet/model/ipv4-l3-protocol.h (-19 / +117 lines)
 Lines 77-84    Link Here 
77
class Ipv4L3Protocol : public Ipv4
77
class Ipv4L3Protocol : public Ipv4
78
{
78
{
79
public:
79
public:
80
  /**
81
   * \brief Get the type ID.
82
   * \return the object TypeId
83
   */
80
  static TypeId GetTypeId (void);
84
  static TypeId GetTypeId (void);
81
  static const uint16_t PROT_NUMBER;
85
  static const uint16_t PROT_NUMBER; //!< Protocol number (0x0800)
82
86
83
  Ipv4L3Protocol();
87
  Ipv4L3Protocol();
84
  virtual ~Ipv4L3Protocol ();
88
  virtual ~Ipv4L3Protocol ();
 Lines 97-102    Link Here 
97
    DROP_FRAGMENT_TIMEOUT /**< Fragment timeout exceeded */
101
    DROP_FRAGMENT_TIMEOUT /**< Fragment timeout exceeded */
98
  };
102
  };
99
103
104
  /**
105
   * \brief Set node associated with this stack.
106
   * \param node node to set
107
   */
100
  void SetNode (Ptr<Node> node);
108
  void SetNode (Ptr<Node> node);
101
109
102
  // functions defined in base class Ipv4
110
  // functions defined in base class Ipv4
 Lines 182-187    Link Here 
182
  void SendWithHeader (Ptr<Packet> packet, Ipv4Header ipHeader, Ptr<Ipv4Route> route);
190
  void SendWithHeader (Ptr<Packet> packet, Ipv4Header ipHeader, Ptr<Ipv4Route> route);
183
191
184
  uint32_t AddInterface (Ptr<NetDevice> device);
192
  uint32_t AddInterface (Ptr<NetDevice> device);
193
  /**
194
   * \brief Get an interface.
195
   * \param i interface index
196
   * \return IPv4 interface pointer
197
   */
185
  Ptr<Ipv4Interface> GetInterface (uint32_t i) const;
198
  Ptr<Ipv4Interface> GetInterface (uint32_t i) const;
186
  uint32_t GetNInterfaces (void) const;
199
  uint32_t GetNInterfaces (void) const;
187
200
 Lines 220-226    Link Here 
220
  virtual void NotifyNewAggregate ();
233
  virtual void NotifyNewAggregate ();
221
private:
234
private:
222
  friend class Ipv4L3ProtocolTestCase;
235
  friend class Ipv4L3ProtocolTestCase;
236
237
  /**
238
   * \brief Copy constructor.
239
   *
240
   * Defined but not implemented to avoid misuse
241
   */
223
  Ipv4L3Protocol(const Ipv4L3Protocol &);
242
  Ipv4L3Protocol(const Ipv4L3Protocol &);
243
244
  /**
245
   * \brief Copy constructor.
246
   *
247
   * Defined but not implemented to avoid misuse
248
   * \returns the copied object
249
   */
224
  Ipv4L3Protocol &operator = (const Ipv4L3Protocol &);
250
  Ipv4L3Protocol &operator = (const Ipv4L3Protocol &);
225
251
226
  // class Ipv4 attributes
252
  // class Ipv4 attributes
 Lines 229-234    Link Here 
229
  virtual void SetWeakEsModel (bool model);
255
  virtual void SetWeakEsModel (bool model);
230
  virtual bool GetWeakEsModel (void) const;
256
  virtual bool GetWeakEsModel (void) const;
231
257
258
  /**
259
   * \brief Construct an IPv4 header.
260
   * \param source source IPv4 address
261
   * \param destination destination IPv4 address
262
   * \param protocol L4 protocol
263
   * \param payloadSize payload size
264
   * \param ttl Time to Live
265
   * \param tos Type of Service
266
   * \param mayFragment true if the packet can be fragmented
267
   * \return newly created IPv4 header
268
   */
232
  Ipv4Header BuildHeader (
269
  Ipv4Header BuildHeader (
233
    Ipv4Address source,
270
    Ipv4Address source,
234
    Ipv4Address destination,
271
    Ipv4Address destination,
 Lines 238-262    Link Here 
238
    uint8_t tos,
275
    uint8_t tos,
239
    bool mayFragment);
276
    bool mayFragment);
240
277
278
  /**
279
   * \brief Send packet with route.
280
   * \param route route
281
   * \param packet packet to send
282
   * \param ipHeader IPv4 header to add to the packet
283
   */
241
  void
284
  void
242
  SendRealOut (Ptr<Ipv4Route> route,
285
  SendRealOut (Ptr<Ipv4Route> route,
243
               Ptr<Packet> packet,
286
               Ptr<Packet> packet,
244
               Ipv4Header const &ipHeader);
287
               Ipv4Header const &ipHeader);
245
288
289
  /**
290
   * \brief Forward a packet.
291
   * \param rtentry route
292
   * \param p packet to forward
293
   * \param header IPv4 header to add to the packet
294
   */
246
  void 
295
  void 
247
  IpForward (Ptr<Ipv4Route> rtentry, 
296
  IpForward (Ptr<Ipv4Route> rtentry, 
248
             Ptr<const Packet> p, 
297
             Ptr<const Packet> p, 
249
             const Ipv4Header &header);
298
             const Ipv4Header &header);
250
299
300
  /**
301
   * \brief Forward a multicast packet.
302
   * \param mrtentry route
303
   * \param p packet to forward
304
   * \param header IPv6 header to add to the packet
305
   */
251
  void
306
  void
252
  IpMulticastForward (Ptr<Ipv4MulticastRoute> mrtentry, 
307
  IpMulticastForward (Ptr<Ipv4MulticastRoute> mrtentry, 
253
                      Ptr<const Packet> p, 
308
                      Ptr<const Packet> p, 
254
                      const Ipv4Header &header);
309
                      const Ipv4Header &header);
255
310
311
  /**
312
   * \brief Deliver a packet.
313
   * \param p packet delivered
314
   * \param ip IPv4 header
315
   * \param iif input interface packet was received
316
   */
256
  void LocalDeliver (Ptr<const Packet> p, Ipv4Header const&ip, uint32_t iif);
317
  void LocalDeliver (Ptr<const Packet> p, Ipv4Header const&ip, uint32_t iif);
318
319
  /**
320
   * \brief Fallback when no route is found.
321
   * \param p packet
322
   * \param ipHeader IPv4 header
323
   * \param sockErrno error number
324
   */
257
  void RouteInputError (Ptr<const Packet> p, const Ipv4Header & ipHeader, Socket::SocketErrno sockErrno);
325
  void RouteInputError (Ptr<const Packet> p, const Ipv4Header & ipHeader, Socket::SocketErrno sockErrno);
258
326
327
  /**
328
   * \brief Add an IPv4 interface to the stack.
329
   * \param interface interface to add
330
   * \return index of newly added interface
331
   */
259
  uint32_t AddIpv4Interface (Ptr<Ipv4Interface> interface);
332
  uint32_t AddIpv4Interface (Ptr<Ipv4Interface> interface);
333
334
  /**
335
   * \brief Setup loopback interface.
336
   */
260
  void SetupLoopback (void);
337
  void SetupLoopback (void);
261
338
262
  /**
339
  /**
 Lines 264-269    Link Here 
264
   * \return Icmpv4L4Protocol pointer
341
   * \return Icmpv4L4Protocol pointer
265
   */
342
   */
266
  Ptr<Icmpv4L4Protocol> GetIcmp (void) const;
343
  Ptr<Icmpv4L4Protocol> GetIcmp (void) const;
344
345
  /**
346
   * \brief Check if an IPv4 address is unicast.
347
   * \param ad address
348
   * \param interfaceMask the network mask
349
   * \return true if the address is unicast
350
   */
267
  bool IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const;
351
  bool IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const;
268
352
269
  /**
353
  /**
 Lines 277-283    Link Here 
277
  /**
361
  /**
278
   * \brief Process a packet fragment
362
   * \brief Process a packet fragment
279
   * \param packet the packet
363
   * \param packet the packet
280
   * \param fragmentSize the size of the fragment
364
   * \param ipHeader the IP header
281
   * \param iif Input Interface
365
   * \param iif Input Interface
282
   * \return true is the fragment completed the packet
366
   * \return true is the fragment completed the packet
283
   */
367
   */
 Lines 291-322    Link Here 
291
   */
375
   */
292
  void HandleFragmentsTimeout ( std::pair<uint64_t, uint32_t> key, Ipv4Header & ipHeader, uint32_t iif);
376
  void HandleFragmentsTimeout ( std::pair<uint64_t, uint32_t> key, Ipv4Header & ipHeader, uint32_t iif);
293
377
378
  /**
379
   * \brief Container of the IPv4 Interfaces.
380
   */
294
  typedef std::vector<Ptr<Ipv4Interface> > Ipv4InterfaceList;
381
  typedef std::vector<Ptr<Ipv4Interface> > Ipv4InterfaceList;
382
  /**
383
   * \brief Container of the IPv4 Raw Sockets.
384
   */
295
  typedef std::list<Ptr<Ipv4RawSocketImpl> > SocketList;
385
  typedef std::list<Ptr<Ipv4RawSocketImpl> > SocketList;
296
  typedef std::list<Ptr<IpL4Protocol> > L4List_t;
386
  /**
387
   * \brief Container of the IPv4 L4 instances.
388
   */
389
   typedef std::list<Ptr<IpL4Protocol> > L4List_t;
297
390
298
  bool m_ipForward;
391
  bool m_ipForward;      //!< Forwarding packets (i.e. router mode) state.
299
  bool m_weakEsModel;
392
  bool m_weakEsModel;    //!< Weak ES model state
300
  L4List_t m_protocols;
393
  L4List_t m_protocols;  //!< List of transport protocol.
301
  Ipv4InterfaceList m_interfaces;
394
  Ipv4InterfaceList m_interfaces; //!< List of IPv4 interfaces.
302
  uint8_t m_defaultTos;
395
  uint8_t m_defaultTos;  //!< Default TOS
303
  uint8_t m_defaultTtl;
396
  uint8_t m_defaultTtl;  //!< Default TTL
304
  uint16_t m_identification;
397
  uint16_t m_identification; //!< Identification
305
  Ptr<Node> m_node;
398
  Ptr<Node> m_node; //!< Node attached to stack.
306
399
400
  /// Trace of sent packets
307
  TracedCallback<const Ipv4Header &, Ptr<const Packet>, uint32_t> m_sendOutgoingTrace;
401
  TracedCallback<const Ipv4Header &, Ptr<const Packet>, uint32_t> m_sendOutgoingTrace;
402
  /// Trace of unicast forwarded packets
308
  TracedCallback<const Ipv4Header &, Ptr<const Packet>, uint32_t> m_unicastForwardTrace;
403
  TracedCallback<const Ipv4Header &, Ptr<const Packet>, uint32_t> m_unicastForwardTrace;
404
  /// Trace of locally delivered packets
309
  TracedCallback<const Ipv4Header &, Ptr<const Packet>, uint32_t> m_localDeliverTrace;
405
  TracedCallback<const Ipv4Header &, Ptr<const Packet>, uint32_t> m_localDeliverTrace;
310
406
311
  // The following two traces pass a packet with an IP header
407
  // The following two traces pass a packet with an IP header
408
  /// Trace of transmitted packets
312
  TracedCallback<Ptr<const Packet>, Ptr<Ipv4>,  uint32_t> m_txTrace;
409
  TracedCallback<Ptr<const Packet>, Ptr<Ipv4>,  uint32_t> m_txTrace;
410
  /// Trace of received packets
313
  TracedCallback<Ptr<const Packet>, Ptr<Ipv4>, uint32_t> m_rxTrace;
411
  TracedCallback<Ptr<const Packet>, Ptr<Ipv4>, uint32_t> m_rxTrace;
314
  // <ip-header, payload, reason, ifindex> (ifindex not valid if reason is DROP_NO_ROUTE)
412
  // <ip-header, payload, reason, ifindex> (ifindex not valid if reason is DROP_NO_ROUTE)
413
  /// Trace of dropped packets
315
  TracedCallback<const Ipv4Header &, Ptr<const Packet>, DropReason, Ptr<Ipv4>, uint32_t> m_dropTrace;
414
  TracedCallback<const Ipv4Header &, Ptr<const Packet>, DropReason, Ptr<Ipv4>, uint32_t> m_dropTrace;
316
415
317
  Ptr<Ipv4RoutingProtocol> m_routingProtocol;
416
  Ptr<Ipv4RoutingProtocol> m_routingProtocol; //!< Routing protocol associated with the stack
318
417
319
  SocketList m_sockets;
418
  SocketList m_sockets; //!< List of IPv4 raw sockets.
320
419
321
  /**
420
  /**
322
   * \class Fragments
421
   * \class Fragments
 Lines 374-388    Link Here 
374
473
375
  };
474
  };
376
475
476
  /// Container of fragments, stored as pairs(src+dst addr, src+dst port) / fragment
377
  typedef std::map< std::pair<uint64_t, uint32_t>, Ptr<Fragments> > MapFragments_t;
477
  typedef std::map< std::pair<uint64_t, uint32_t>, Ptr<Fragments> > MapFragments_t;
478
  /// Container of fragment timeout event, stored as pairs(src+dst addr, src+dst port) / EventId
378
  typedef std::map< std::pair<uint64_t, uint32_t>, EventId > MapFragmentsTimers_t;
479
  typedef std::map< std::pair<uint64_t, uint32_t>, EventId > MapFragmentsTimers_t;
379
480
380
  /**
481
  MapFragments_t       m_fragments; //!< Fragmented packets.
381
   * \brief The hash of fragmented packets.
482
  Time                 m_fragmentExpirationTimeout; //!< Expiration timeout
382
   */
483
  MapFragmentsTimers_t m_fragmentsTimers; //!< Expiration events.
383
  MapFragments_t       m_fragments;
384
  Time                 m_fragmentExpirationTimeout;
385
  MapFragmentsTimers_t m_fragmentsTimers;
386
484
387
};
485
};
388
486
(-)a/src/internet/model/ipv4-list-routing.h (-2 / +20 lines)
 Lines 45-50    Link Here 
45
class Ipv4ListRouting : public Ipv4RoutingProtocol
45
class Ipv4ListRouting : public Ipv4RoutingProtocol
46
{
46
{
47
public:
47
public:
48
  /**
49
   * \brief Get the type ID of this class.
50
   * \return type ID
51
   */
48
  static TypeId GetTypeId (void);
52
  static TypeId GetTypeId (void);
49
53
50
  Ipv4ListRouting ();
54
  Ipv4ListRouting ();
 Lines 92-102    Link Here 
92
  void DoDispose (void);
96
  void DoDispose (void);
93
  void DoInitialize (void);
97
  void DoInitialize (void);
94
private:
98
private:
99
  /**
100
   * \brief Container identifying an IPv4 Routing Protocol entry in the list.
101
   */
95
  typedef std::pair<int16_t, Ptr<Ipv4RoutingProtocol> > Ipv4RoutingProtocolEntry;
102
  typedef std::pair<int16_t, Ptr<Ipv4RoutingProtocol> > Ipv4RoutingProtocolEntry;
103
  /**
104
   * \brief Container of the IPv4 Routing Protocols.
105
   */
96
  typedef std::list<Ipv4RoutingProtocolEntry> Ipv4RoutingProtocolList;
106
  typedef std::list<Ipv4RoutingProtocolEntry> Ipv4RoutingProtocolList;
97
  Ipv4RoutingProtocolList m_routingProtocols;
107
  Ipv4RoutingProtocolList m_routingProtocols; //!<  List of routing protocols.
108
109
  /**
110
   * \brief Compare two routing protocols.
111
   * \param a first object to compare
112
   * \param b second object to compare
113
   * \return true if they are the same, false otherwise
114
   */
98
  static bool Compare (const Ipv4RoutingProtocolEntry& a, const Ipv4RoutingProtocolEntry& b);
115
  static bool Compare (const Ipv4RoutingProtocolEntry& a, const Ipv4RoutingProtocolEntry& b);
99
  Ptr<Ipv4> m_ipv4;
116
  Ptr<Ipv4> m_ipv4; //!< Ipv4 this protocol is associated with.
117
100
118
101
};
119
};
102
120
(-)a/src/internet/model/ipv4-packet-info-tag.h (-13 / +57 lines)
 Lines 43-65    Link Here 
43
{
43
{
44
public:
44
public:
45
  Ipv4PacketInfoTag ();
45
  Ipv4PacketInfoTag ();
46
  // Implemented, but not used in the stack yet
46
47
  /**
48
   * \brief Set the tag's address
49
   *
50
   * \param addr the address
51
   */
47
  void SetAddress (Ipv4Address addr);
52
  void SetAddress (Ipv4Address addr);
48
  // Implemented, but not used in the stack yet
53
54
  /**
55
   * \brief Get the tag's address
56
   *
57
   * \returns the address
58
   */
49
  Ipv4Address GetAddress (void) const;
59
  Ipv4Address GetAddress (void) const;
50
  // This corresponds to "ipi_spec_dst" in struct in_pktinfo.
60
  /**
51
  // Implemented, but not used in the stack yet
61
   * \brief Set the tag's \a local address
62
   *
63
   * This corresponds to "ipi_spec_dst" in struct in_pktinfo.
64
   * Implemented, but not used in the stack yet
65
   * \param addr the address
66
   */
52
  void SetLocalAddress (Ipv4Address addr);
67
  void SetLocalAddress (Ipv4Address addr);
53
  // This corresponds to "ipi_spec_dst" in struct in_pktinfo.
68
  /**
54
  // Implemented, but not used in the stack yet
69
   * \brief Get the tag's \a local address
70
   *
71
   * This corresponds to "ipi_spec_dst" in struct in_pktinfo.
72
   * Implemented, but not used in the stack yet
73
   * \returns the address
74
   */
55
  Ipv4Address GetLocalAddress (void) const;
75
  Ipv4Address GetLocalAddress (void) const;
76
77
  /**
78
   * \brief Set the tag's receiving interface
79
   *
80
   * \param ifindex the interface index
81
   */
56
  void SetRecvIf (uint32_t ifindex);
82
  void SetRecvIf (uint32_t ifindex);
83
  /**
84
   * \brief Get the tag's receiving interface
85
   *
86
   * \returns the interface index
87
   */
57
  uint32_t GetRecvIf (void) const;
88
  uint32_t GetRecvIf (void) const;
58
  // Implemented, but not used in the stack yet
89
90
  /**
91
   * \brief Set the tag's Time to Live
92
   * Implemented, but not used in the stack yet
93
   * \param ttl the TTL
94
   */
59
  void SetTtl (uint8_t ttl);
95
  void SetTtl (uint8_t ttl);
60
  // Implemented, but not used in the stack yet
96
  /**
97
   * \brief Get the tag's Time to Live
98
   * Implemented, but not used in the stack yet
99
   * \returns the TTL
100
   */
61
  uint8_t GetTtl (void) const;
101
  uint8_t GetTtl (void) const;
62
102
103
  /**
104
   * \brief Get the type ID.
105
   * \return the object TypeId
106
   */
63
  static TypeId GetTypeId (void);
107
  static TypeId GetTypeId (void);
64
  virtual TypeId GetInstanceTypeId (void) const;
108
  virtual TypeId GetInstanceTypeId (void) const;
65
  virtual uint32_t GetSerializedSize (void) const;
109
  virtual uint32_t GetSerializedSize (void) const;
 Lines 77-88    Link Here 
77
  //                                   address */
121
  //                                   address */
78
  // };
122
  // };
79
123
80
  Ipv4Address m_addr;
124
  Ipv4Address m_addr;     //!< Header destination address
81
  Ipv4Address m_spec_dst;
125
  Ipv4Address m_spec_dst; //!< Local address
82
  uint32_t m_ifindex;
126
  uint32_t m_ifindex;     //!< interface index
83
127
84
  // Uset for IP_RECVTTL, though not implemented yet.
128
  // Used for IP_RECVTTL, though not implemented yet.
85
  uint8_t m_ttl;
129
  uint8_t m_ttl; //!< Time to Live
86
};
130
};
87
} // namespace ns3
131
} // namespace ns3
88
132
(-)a/src/internet/model/ipv4-packet-probe.h (+6 lines)
 Lines 47-52    Link Here 
47
class Ipv4PacketProbe : public Probe
47
class Ipv4PacketProbe : public Probe
48
{
48
{
49
public:
49
public:
50
  /**
51
   * \brief Get the type ID.
52
   * \return the object TypeId
53
   */
50
  static TypeId GetTypeId ();
54
  static TypeId GetTypeId ();
51
  Ipv4PacketProbe ();
55
  Ipv4PacketProbe ();
52
  virtual ~Ipv4PacketProbe ();
56
  virtual ~Ipv4PacketProbe ();
 Lines 102-108    Link Here 
102
   */
106
   */
103
  void TraceSink (Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface);
107
  void TraceSink (Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface);
104
108
109
  /// Traced Callback: the packet, the Ipv4 object and the interface.
105
  TracedCallback<Ptr<const Packet>, Ptr<Ipv4>, uint32_t> m_output;
110
  TracedCallback<Ptr<const Packet>, Ptr<Ipv4>, uint32_t> m_output;
111
  /// Traced Callback: the previous packet's size and the actual packet's size.
106
  TracedCallback<uint32_t, uint32_t> m_outputBytes;
112
  TracedCallback<uint32_t, uint32_t> m_outputBytes;
107
113
108
  /// The traced packet.
114
  /// The traced packet.
(-)a/src/internet/model/ipv4-raw-socket-factory-impl.h (+6 lines)
 Lines 25-30    Link Here 
25
25
26
namespace ns3 {
26
namespace ns3 {
27
27
28
/**
29
 * \ingroup socket
30
 *
31
 * \class Ipv4RawSocketFactoryImpl
32
 * \brief Implementation of IPv4 raw socket factory.
33
 */
28
class Ipv4RawSocketFactoryImpl : public Ipv4RawSocketFactory
34
class Ipv4RawSocketFactoryImpl : public Ipv4RawSocketFactory
29
{
35
{
30
public:
36
public:
(-)a/src/internet/model/ipv4-raw-socket-factory.h (+4 lines)
 Lines 37-42    Link Here 
37
class Ipv4RawSocketFactory : public SocketFactory
37
class Ipv4RawSocketFactory : public SocketFactory
38
{
38
{
39
public:
39
public:
40
  /**
41
   * \brief Get the type ID.
42
   * \return the object TypeId
43
   */
40
  static TypeId GetTypeId (void);
44
  static TypeId GetTypeId (void);
41
45
42
};
46
};
(-)a/src/internet/model/ipv4-raw-socket-impl.h (-14 / +55 lines)
 Lines 13-29    Link Here 
13
class NetDevice;
13
class NetDevice;
14
class Node;
14
class Node;
15
15
16
/**
17
 * \class Ipv4RawSocketImpl
18
 * \brief IPv4 raw socket.
19
 * \ingroup socket
20
 *
21
 * A RAW Socket typically is used to access specific IP layers not usually
22
 * available through L4 sockets, e.g., ICMP. The implementer should take
23
 * particular care to define the Ipv4RawSocketImpl Attributes, and in
24
 * particular the Protocol attribute.
25
 */
16
class Ipv4RawSocketImpl : public Socket
26
class Ipv4RawSocketImpl : public Socket
17
{
27
{
18
public:
28
public:
29
  /**
30
   * \brief Get the type ID of this class.
31
   * \return type ID
32
   */
19
  static TypeId GetTypeId (void);
33
  static TypeId GetTypeId (void);
20
34
21
  Ipv4RawSocketImpl ();
35
  Ipv4RawSocketImpl ();
22
36
37
  /**
38
   * \brief Set the node associated with this socket.
39
   * \param node node to set
40
   */
23
  void SetNode (Ptr<Node> node);
41
  void SetNode (Ptr<Node> node);
24
42
25
  virtual enum Socket::SocketErrno GetErrno (void) const;
43
  virtual enum Socket::SocketErrno GetErrno () const;
44
45
  /**
46
   * \brief Get socket type (NS3_SOCK_RAW)
47
   * \return socket type
48
   */
26
  virtual enum Socket::SocketType GetSocketType (void) const;
49
  virtual enum Socket::SocketType GetSocketType (void) const;
50
27
  virtual Ptr<Node> GetNode (void) const;
51
  virtual Ptr<Node> GetNode (void) const;
28
  virtual int Bind (const Address &address);
52
  virtual int Bind (const Address &address);
29
  virtual int Bind ();
53
  virtual int Bind ();
 Lines 43-49    Link Here 
43
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
67
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
44
                                Address &fromAddress);
68
                                Address &fromAddress);
45
69
70
71
  /**
72
   * \brief Set protocol field.
73
   * \param protocol protocol to set
74
   */
46
  void SetProtocol (uint16_t protocol);
75
  void SetProtocol (uint16_t protocol);
76
77
  /**
78
   * \brief Forward up to receive method.
79
   * \param p packet
80
   * \param ipHeader IPv4 header
81
   * \param incomingInterface incoming interface
82
   * \return true if forwarded, false otherwise
83
   */
47
  bool ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4Interface> incomingInterface);
84
  bool ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4Interface> incomingInterface);
48
  virtual bool SetAllowBroadcast (bool allowBroadcast);
85
  virtual bool SetAllowBroadcast (bool allowBroadcast);
49
  virtual bool GetAllowBroadcast () const;
86
  virtual bool GetAllowBroadcast () const;
 Lines 51-72    Link Here 
51
private:
88
private:
52
  virtual void DoDispose (void);
89
  virtual void DoDispose (void);
53
90
91
  /**
92
   * \struct Data
93
   * \brief IPv4 raw data and additional information.
94
   */
54
  struct Data {
95
  struct Data {
55
    Ptr<Packet> packet;
96
    Ptr<Packet> packet;  /**< Packet data */
56
    Ipv4Address fromIp;
97
    Ipv4Address fromIp;  /**< Source address */
57
    uint16_t fromProtocol;
98
    uint16_t fromProtocol;   /**< Protocol used */
58
  };
99
  };
59
100
60
  enum Socket::SocketErrno m_err;
101
  enum Socket::SocketErrno m_err;   //!< Last error number.
61
  Ptr<Node> m_node;
102
  Ptr<Node> m_node;                 //!< Node
62
  Ipv4Address m_src;
103
  Ipv4Address m_src;                //!< Source address.
63
  Ipv4Address m_dst;
104
  Ipv4Address m_dst;                //!< Destination address.
64
  uint16_t m_protocol;
105
  uint16_t m_protocol;              //!< Protocol.
65
  std::list<struct Data> m_recv;
106
  std::list<struct Data> m_recv;    //!< Packet waiting to be processed.
66
  bool m_shutdownSend;
107
  bool m_shutdownSend;              //!< Flag to shutdown send capability.
67
  bool m_shutdownRecv;
108
  bool m_shutdownRecv;              //!< Flag to shutdown receive capability.
68
  uint32_t m_icmpFilter;
109
  uint32_t m_icmpFilter;            //!< ICMPv4 filter specification
69
  bool m_iphdrincl;
110
  bool m_iphdrincl;                 //!< Include IP Header information (a.k.a setsockopt (IP_HDRINCL))
70
};
111
};
71
112
72
} // namespace ns3
113
} // namespace ns3
(-)a/src/internet/model/ipv4-route.h (-10 / +17 lines)
 Lines 89-103    Link Here 
89
#endif
89
#endif
90
90
91
private:
91
private:
92
  Ipv4Address m_dest;
92
  Ipv4Address m_dest;             //!< Destination address.
93
  Ipv4Address m_source;
93
  Ipv4Address m_source;           //!< Source address.
94
  Ipv4Address m_gateway;
94
  Ipv4Address m_gateway;          //!< Gateway address.
95
  Ptr<NetDevice> m_outputDevice;
95
  Ptr<NetDevice> m_outputDevice;  //!< Output device.
96
#ifdef NOTYET
96
#ifdef NOTYET
97
  uint32_t m_inputIfIndex;
97
  uint32_t m_inputIfIndex;
98
#endif
98
#endif
99
};
99
};
100
100
101
/**
102
 * \brief Stream insertion operator.
103
 *
104
 * \param os the reference to the output stream
105
 * \param route the Ipv4 route
106
 * \returns the reference to the output stream
107
 */
101
std::ostream& operator<< (std::ostream& os, Ipv4Route const& route);
108
std::ostream& operator<< (std::ostream& os, Ipv4Route const& route);
102
109
103
/**
110
/**
 Lines 154-167    Link Here 
154
   */
161
   */
155
  std::map<uint32_t, uint32_t> GetOutputTtlMap () const;
162
  std::map<uint32_t, uint32_t> GetOutputTtlMap () const;
156
163
157
  static const uint32_t MAX_INTERFACES = 16;  // Maximum number of multicast interfaces on a router
164
  static const uint32_t MAX_INTERFACES = 16;  //!< Maximum number of multicast interfaces on a router
158
  static const uint32_t MAX_TTL = 255;  // Maximum time-to-live (TTL)
165
  static const uint32_t MAX_TTL = 255;  //!< Maximum time-to-live (TTL)
159
166
160
private:
167
private:
161
  Ipv4Address m_group;      // Group 
168
  Ipv4Address m_group;      //!< Group
162
  Ipv4Address m_origin;     // Source of packet
169
  Ipv4Address m_origin;     //!< Source of packet
163
  uint32_t m_parent;        // Source interface
170
  uint32_t m_parent;        //!< Source interface
164
  std::map<uint32_t, uint32_t> m_ttls;
171
  std::map<uint32_t, uint32_t> m_ttls; //!< Time to Live container
165
};
172
};
166
173
167
} // namespace ns3
174
} // namespace ns3
(-)a/src/internet/model/ipv4-routing-table-entry.h (-8 / +53 lines)
 Lines 135-159    Link Here 
135
                                                   uint32_t interface);
135
                                                   uint32_t interface);
136
136
137
private:
137
private:
138
  /**
139
   * \brief Constructor.
140
   * \param network network address
141
   * \param mask network mask
142
   * \param gateway the gateway
143
   * \param interface the interface index
144
   */
138
  Ipv4RoutingTableEntry (Ipv4Address network,
145
  Ipv4RoutingTableEntry (Ipv4Address network,
139
                         Ipv4Mask mask,
146
                         Ipv4Mask mask,
140
                         Ipv4Address gateway,
147
                         Ipv4Address gateway,
141
                         uint32_t interface);
148
                         uint32_t interface);
149
  /**
150
   * \brief Constructor.
151
   * \param dest destination address
152
   * \param mask network mask
153
   * \param interface the interface index
154
   */
142
  Ipv4RoutingTableEntry (Ipv4Address dest,
155
  Ipv4RoutingTableEntry (Ipv4Address dest,
143
                         Ipv4Mask mask,
156
                         Ipv4Mask mask,
144
                         uint32_t interface);
157
                         uint32_t interface);
158
  /**
159
   * \brief Constructor.
160
   * \param dest destination address
161
   * \param gateway the gateway
162
   * \param interface the interface index
163
   */
145
  Ipv4RoutingTableEntry (Ipv4Address dest,
164
  Ipv4RoutingTableEntry (Ipv4Address dest,
146
                         Ipv4Address gateway,
165
                         Ipv4Address gateway,
147
                         uint32_t interface);
166
                         uint32_t interface);
167
  /**
168
   * \brief Constructor.
169
   * \param dest destination address
170
   * \param interface the interface index
171
   */
148
  Ipv4RoutingTableEntry (Ipv4Address dest,
172
  Ipv4RoutingTableEntry (Ipv4Address dest,
149
                         uint32_t interface);
173
                         uint32_t interface);
150
174
151
  Ipv4Address m_dest;
175
  Ipv4Address m_dest;         //!< destination address
152
  Ipv4Mask m_destNetworkMask;
176
  Ipv4Mask m_destNetworkMask; //!< destination network mask
153
  Ipv4Address m_gateway;
177
  Ipv4Address m_gateway;      //!< gateway
154
  uint32_t m_interface;
178
  uint32_t m_interface;       //!< output interface
155
};
179
};
156
180
181
/**
182
 * \brief Stream insertion operator.
183
 *
184
 * \param os the reference to the output stream
185
 * \param route the Ipv4 routing table entry
186
 * \returns the reference to the output stream
187
 */
157
std::ostream& operator<< (std::ostream& os, Ipv4RoutingTableEntry const& route);
188
std::ostream& operator<< (std::ostream& os, Ipv4RoutingTableEntry const& route);
158
189
159
/**
190
/**
 Lines 215-229    Link Here 
215
                                                              std::vector<uint32_t> outputInterfaces);
246
                                                              std::vector<uint32_t> outputInterfaces);
216
247
217
private:
248
private:
249
  /**
250
   * \brief Constructor.
251
   * \param origin source address
252
   * \param group destination address
253
   * \param inputInterface input interface
254
   * \param outputInterfaces output interfaces
255
   */
218
  Ipv4MulticastRoutingTableEntry (Ipv4Address origin, Ipv4Address group, 
256
  Ipv4MulticastRoutingTableEntry (Ipv4Address origin, Ipv4Address group, 
219
                                  uint32_t inputInterface, std::vector<uint32_t> outputInterfaces);
257
                                  uint32_t inputInterface, std::vector<uint32_t> outputInterfaces);
220
258
221
  Ipv4Address m_origin;
259
  Ipv4Address m_origin;   //!< source address
222
  Ipv4Address m_group;
260
  Ipv4Address m_group;    //!< destination address
223
  uint32_t m_inputInterface;
261
  uint32_t m_inputInterface;    //!< input interface
224
  std::vector<uint32_t> m_outputInterfaces;
262
  std::vector<uint32_t> m_outputInterfaces;   //!< output interfaces
225
};
263
};
226
264
265
/**
266
 * \brief Stream insertion operator.
267
 *
268
 * \param os the reference to the output stream
269
 * \param route the Ipv4 multicast routing table entry
270
 * \returns the reference to the output stream
271
 */
227
std::ostream& operator<< (std::ostream& os, Ipv4MulticastRoutingTableEntry const& route);
272
std::ostream& operator<< (std::ostream& os, Ipv4MulticastRoutingTableEntry const& route);
228
273
229
} // namespace ns3
274
} // namespace ns3
(-)a/src/internet/model/ipv4-static-routing.h (+46 lines)
 Lines 69-74    Link Here 
69
class Ipv4StaticRouting : public Ipv4RoutingProtocol
69
class Ipv4StaticRouting : public Ipv4RoutingProtocol
70
{
70
{
71
public:
71
public:
72
  /**
73
   * \brief The interface Id associated with this class.
74
   * \return type identifier
75
   */
72
  static TypeId GetTypeId (void);
76
  static TypeId GetTypeId (void);
73
77
74
  Ipv4StaticRouting ();
78
  Ipv4StaticRouting ();
 Lines 177-182    Link Here 
177
 * to the routing table.
181
 * to the routing table.
178
 *
182
 *
179
 * \warning The default route counts as one of the routes.
183
 * \warning The default route counts as one of the routes.
184
 * \return number of entries
180
 */
185
 */
181
  uint32_t GetNRoutes (void) const;
186
  uint32_t GetNRoutes (void) const;
182
187
 Lines 308-313    Link Here 
308
 * to the routing table.
313
 * to the routing table.
309
 *
314
 *
310
 * \warning The default multicast route counts as one of the routes.
315
 * \warning The default multicast route counts as one of the routes.
316
 * \return number of entries
311
 */
317
 */
312
  uint32_t GetNMulticastRoutes (void) const;
318
  uint32_t GetNMulticastRoutes (void) const;
313
319
 Lines 375-397    Link Here 
375
  virtual void DoDispose (void);
381
  virtual void DoDispose (void);
376
382
377
private:
383
private:
384
  /// Container for the network routes
378
  typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> > NetworkRoutes;
385
  typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> > NetworkRoutes;
386
387
  /// Const Iterator for container for the network routes
379
  typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >::const_iterator NetworkRoutesCI;
388
  typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >::const_iterator NetworkRoutesCI;
389
390
  /// Iterator for container for the network routes
380
  typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >::iterator NetworkRoutesI;
391
  typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >::iterator NetworkRoutesI;
381
392
393
  /// Container for the multicast routes
382
  typedef std::list<Ipv4MulticastRoutingTableEntry *> MulticastRoutes;
394
  typedef std::list<Ipv4MulticastRoutingTableEntry *> MulticastRoutes;
395
396
  /// Const Iterator for container for the multicast routes
383
  typedef std::list<Ipv4MulticastRoutingTableEntry *>::const_iterator MulticastRoutesCI;
397
  typedef std::list<Ipv4MulticastRoutingTableEntry *>::const_iterator MulticastRoutesCI;
398
399
  /// Iterator for container for the multicast routes
384
  typedef std::list<Ipv4MulticastRoutingTableEntry *>::iterator MulticastRoutesI;
400
  typedef std::list<Ipv4MulticastRoutingTableEntry *>::iterator MulticastRoutesI;
385
401
402
  /**
403
   * \brief Lookup in the forwarding table for destination.
404
   * \param dest destination address
405
   * \param oif output interface if any (put 0 otherwise)
406
   * \return Ipv4Route to route the packet to reach dest address
407
   */
386
  Ptr<Ipv4Route> LookupStatic (Ipv4Address dest, Ptr<NetDevice> oif = 0);
408
  Ptr<Ipv4Route> LookupStatic (Ipv4Address dest, Ptr<NetDevice> oif = 0);
409
410
  /**
411
   * \brief Lookup in the multicast forwarding table for destination.
412
   * \param origin source address
413
   * \param group group multicast address
414
   * \param interface interface index
415
   * \return Ipv4MulticastRoute to route the packet to reach dest address
416
   */
387
  Ptr<Ipv4MulticastRoute> LookupStatic (Ipv4Address origin, Ipv4Address group,
417
  Ptr<Ipv4MulticastRoute> LookupStatic (Ipv4Address origin, Ipv4Address group,
388
                                        uint32_t interface);
418
                                        uint32_t interface);
389
419
420
  /**
421
   * \brief Choose the source address to use with destination address.
422
   * \param interface interface index
423
   * \param dest IPv4 destination address
424
   * \return IPv4 source address to use
425
   */
390
  Ipv4Address SourceAddressSelection (uint32_t interface, Ipv4Address dest);
426
  Ipv4Address SourceAddressSelection (uint32_t interface, Ipv4Address dest);
391
427
428
  /**
429
   * \brief the forwarding table for network.
430
   */
392
  NetworkRoutes m_networkRoutes;
431
  NetworkRoutes m_networkRoutes;
432
433
  /**
434
   * \brief the forwarding table for multicast.
435
   */
393
  MulticastRoutes m_multicastRoutes;
436
  MulticastRoutes m_multicastRoutes;
394
437
438
  /**
439
   * \brief Ipv4 reference.
440
   */
395
  Ptr<Ipv4> m_ipv4;
441
  Ptr<Ipv4> m_ipv4;
396
};
442
};
397
443
(-)a/src/internet/model/ipv4.h (-1 / +28 lines)
 Lines 75-80    Link Here 
75
class Ipv4 : public Object
75
class Ipv4 : public Object
76
{
76
{
77
public:
77
public:
78
  /**
79
   * \brief Get the type ID.
80
   * \return the object TypeId
81
   */
78
  static TypeId GetTypeId (void);
82
  static TypeId GetTypeId (void);
79
  Ipv4 ();
83
  Ipv4 ();
80
  virtual ~Ipv4 ();
84
  virtual ~Ipv4 ();
 Lines 167-172    Link Here 
167
   *
171
   *
168
   * \param address The IP address being considered
172
   * \param address The IP address being considered
169
   * \param iif The incoming Ipv4 interface index
173
   * \param iif The incoming Ipv4 interface index
174
   * \returns true if the address is associated with the interface index
170
   *
175
   *
171
   * This method can be used to determine whether a received packet has
176
   * This method can be used to determine whether a received packet has
172
   * an acceptable address for local delivery on the host.  The address
177
   * an acceptable address for local delivery on the host.  The address
 Lines 378-390    Link Here 
378
  virtual void DeleteRawSocket (Ptr<Socket> socket) = 0;
383
  virtual void DeleteRawSocket (Ptr<Socket> socket) = 0;
379
384
380
385
381
  static const uint32_t IF_ANY = 0xffffffff;
386
  static const uint32_t IF_ANY = 0xffffffff; //!< interface wildcard, meaning any interface
382
387
383
private:
388
private:
384
  // Indirect the Ipv4 attributes through private pure virtual methods
389
  // Indirect the Ipv4 attributes through private pure virtual methods
390
391
  /**
392
   * \brief Set or unset the IP forwarding state
393
   * \param forward the forwarding state
394
   */
385
  virtual void SetIpForward (bool forward) = 0;
395
  virtual void SetIpForward (bool forward) = 0;
396
  /**
397
   * \brief Get the IP forwarding state
398
   * \returns true if IP is in forwarding state
399
   */
386
  virtual bool GetIpForward (void) const = 0;
400
  virtual bool GetIpForward (void) const = 0;
401
402
  /**
403
   * \brief Set or unset the Weak Es Model
404
   *
405
   * RFC1122 term for whether host accepts datagram with a dest. address on another interface
406
   * \param model true for Weak Es Model
407
   */
387
  virtual void SetWeakEsModel (bool model) = 0;
408
  virtual void SetWeakEsModel (bool model) = 0;
409
  /**
410
   * \brief Get the Weak Es Model status
411
   *
412
   * RFC1122 term for whether host accepts datagram with a dest. address on another interface
413
   * \returns true for Weak Es Model activated
414
   */
388
  virtual bool GetWeakEsModel (void) const = 0;
415
  virtual bool GetWeakEsModel (void) const = 0;
389
};
416
};
390
417
(-)a/src/internet/model/ipv6-address-generator.h (-1 / +1 lines)
 Lines 51-57    Link Here 
51
 * but can also be a pseudo-random value (\RFC{3041}).  This implementation
51
 * but can also be a pseudo-random value (\RFC{3041}).  This implementation
52
 * does not generate EUI-64-based interface IDs.
52
 * does not generate EUI-64-based interface IDs.
53
 *
53
 *
54
 * BEWARE: this class acts as a Singleton.
54
 * \note BEWARE: this class acts as a Singleton.
55
 * In other terms, two different instances of Ipv6AddressGenerator will
55
 * In other terms, two different instances of Ipv6AddressGenerator will
56
 * pick IPv6 numbers from the same pool. Changing the network in one of them
56
 * pick IPv6 numbers from the same pool. Changing the network in one of them
57
 * will also change the network in the other instances.
57
 * will also change the network in the other instances.
(-)a/src/internet/model/ipv6-end-point-demux.h (-8 / +1 lines)
 Lines 47-60    Link Here 
47
   */
47
   */
48
  typedef std::list<Ipv6EndPoint *>::iterator EndPointsI;
48
  typedef std::list<Ipv6EndPoint *>::iterator EndPointsI;
49
49
50
  /**
51
   * \brief Constructor.
52
   */
53
  Ipv6EndPointDemux ();
50
  Ipv6EndPointDemux ();
54
55
  /**
56
   * \brief Destructor.
57
   */
58
  ~Ipv6EndPointDemux ();
51
  ~Ipv6EndPointDemux ();
59
52
60
  /**
53
  /**
 Lines 79-85    Link Here 
79
   * \param src source address to test
72
   * \param src source address to test
80
   * \param sport source port to test
73
   * \param sport source port to test
81
   * \param incomingInterface the incoming interface
74
   * \param incomingInterface the incoming interface
82
   * \return list en IPv6EndPoints (could be 0 element)
75
   * \return list of IPv6EndPoints (could be 0 element)
83
   */
76
   */
84
  EndPoints Lookup (Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport, Ptr<Ipv6Interface> incomingInterface);
77
  EndPoints Lookup (Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport, Ptr<Ipv6Interface> incomingInterface);
85
78
(-)a/src/internet/model/ipv6-end-point.h (-8 / +17 lines)
 Lines 35-42    Link Here 
35
class Packet;
35
class Packet;
36
36
37
/**
37
/**
38
 * \class Ipv6EndPoint
38
 * \brief A representation of an internet IPv6 endpoint/connection
39
 * \brief An IPv6 end point, four tuples identification.
39
 *
40
 * This class provides an internet four-tuple (source and destination ports
41
 * and addresses).  These are used in the ns3::Ipv6EndPointDemux as targets
42
 * of lookups.  The class also has a callback for notification to higher
43
 * layers that a packet from a lower layer was received.  In the ns3
44
 * internet-stack, these notifications are automatically registered to be
45
 * received by the corresponding socket.
40
 */
46
 */
41
class Ipv6EndPoint
47
class Ipv6EndPoint
42
{
48
{
 Lines 48-56    Link Here 
48
   */
54
   */
49
  Ipv6EndPoint (Ipv6Address addr, uint16_t port);
55
  Ipv6EndPoint (Ipv6Address addr, uint16_t port);
50
56
51
  /**
52
   * \brief Destructor.
53
   */
54
  ~Ipv6EndPoint ();
57
  ~Ipv6EndPoint ();
55
58
56
  /**
59
  /**
 Lines 113-119    Link Here 
113
   * the socket can not receive any packets as a result.
116
   * the socket can not receive any packets as a result.
114
   *
117
   *
115
   * \param netdevice Pointer to Netdevice of desired interface
118
   * \param netdevice Pointer to Netdevice of desired interface
116
   * \returns nothing
117
   */
119
   */
118
  void BindToNetDevice (Ptr<NetDevice> netdevice);
120
  void BindToNetDevice (Ptr<NetDevice> netdevice);
119
121
 Lines 148-153    Link Here 
148
150
149
  /**
151
  /**
150
   * \brief Forward the packet to the upper level.
152
   * \brief Forward the packet to the upper level.
153
   *
154
   * Called from an L4Protocol implementation to notify an endpoint of a
155
   * packet reception.
156
   *
151
   * \param p the packet
157
   * \param p the packet
152
   * \param header the packet header
158
   * \param header the packet header
153
   * \param port source port
159
   * \param port source port
 Lines 155-162    Link Here 
155
  void ForwardUp (Ptr<Packet> p, Ipv6Header header, uint16_t port);
161
  void ForwardUp (Ptr<Packet> p, Ipv6Header header, uint16_t port);
156
162
157
  /**
163
  /**
158
   * \brief Function called from an L4Protocol implementation
164
   * \brief Forward the ICMP packet to the upper level.
159
   * to notify an endpoint of an icmp message reception.
165
   *
166
   * Called from an L4Protocol implementation to notify an endpoint of
167
   * an icmp message reception.
168
   *
160
   * \param src source IPv6 address
169
   * \param src source IPv6 address
161
   * \param ttl time-to-live
170
   * \param ttl time-to-live
162
   * \param type ICMPv6 type
171
   * \param type ICMPv6 type
(-)a/src/internet/model/ipv6-interface-address.h (-1 / +1 lines)
 Lines 53-59    Link Here 
53
53
54
  /**
54
  /**
55
   * \enum Scope_e
55
   * \enum Scope_e
56
   * \brief Scope of address.
56
   * \brief Address scope.
57
   */
57
   */
58
  enum Scope_e
58
  enum Scope_e
59
  {
59
  {
(-)a/src/internet/model/ipv6-interface.h (-2 / +2 lines)
 Lines 42-48    Link Here 
42
 * \brief The IPv6 representation of a network interface
42
 * \brief The IPv6 representation of a network interface
43
 *
43
 *
44
 * By default IPv6 interfaces are created in the "down" state
44
 * By default IPv6 interfaces are created in the "down" state
45
 * with IP "fe80::1" and a /64 prefix. Before becoming useable,
45
 * with IP "fe80::1" and a /64 prefix. Before becoming usable,
46
 * the user must invoke SetUp on them once the final IPv6 address
46
 * the user must invoke SetUp on them once the final IPv6 address
47
 * and mask has been set.
47
 * and mask has been set.
48
 */
48
 */
 Lines 268-274    Link Here 
268
  typedef std::list<Ipv6InterfaceAddress>::iterator Ipv6InterfaceAddressListI;
268
  typedef std::list<Ipv6InterfaceAddress>::iterator Ipv6InterfaceAddressListI;
269
269
270
  /**
270
  /**
271
   * \brief Const Container Itareator for the Ipv6InterfaceAddresses.
271
   * \brief Const Container Iterator for the Ipv6InterfaceAddresses.
272
   */
272
   */
273
  typedef std::list<Ipv6InterfaceAddress>::const_iterator Ipv6InterfaceAddressListCI;
273
  typedef std::list<Ipv6InterfaceAddress>::const_iterator Ipv6InterfaceAddressListCI;
274
274
(-)a/src/internet/model/ipv6-l3-protocol.h (-6 / +8 lines)
 Lines 94-100    Link Here 
94
  virtual ~Ipv6L3Protocol ();
94
  virtual ~Ipv6L3Protocol ();
95
95
96
  /**
96
  /**
97
   * \brief Set node for this stack.
97
   * \brief Set node associated with this stack.
98
   * \param node node to set
98
   * \param node node to set
99
   */
99
   */
100
  void SetNode (Ptr<Node> node);
100
  void SetNode (Ptr<Node> node);
 Lines 427-442    Link Here 
427
427
428
  /**
428
  /**
429
   * \brief Copy constructor.
429
   * \brief Copy constructor.
430
   * \param o object to copy
430
   *
431
   * Defined but not implemented to avoid misuse
431
   */
432
   */
432
  Ipv6L3Protocol (const Ipv6L3Protocol& o);
433
  Ipv6L3Protocol (const Ipv6L3Protocol&);
433
434
434
  /**
435
  /**
435
   * \brief Copy constructor.
436
   * \brief Copy constructor.
436
   * \param o object to copy
437
   *
438
   * Defined but not implemented to avoid misuse
437
   * \returns the copied object
439
   * \returns the copied object
438
   */
440
   */
439
  Ipv6L3Protocol &operator = (const Ipv6L3Protocol& o);
441
  Ipv6L3Protocol &operator = (const Ipv6L3Protocol&);
440
442
441
  /**
443
  /**
442
   * \brief Construct an IPv6 header.
444
   * \brief Construct an IPv6 header.
 Lines 469-475    Link Here 
469
  void IpForward (Ptr<const NetDevice> idev, Ptr<Ipv6Route> rtentry, Ptr<const Packet> p, const Ipv6Header& header);
471
  void IpForward (Ptr<const NetDevice> idev, Ptr<Ipv6Route> rtentry, Ptr<const Packet> p, const Ipv6Header& header);
470
472
471
  /**
473
  /**
472
   * \brief Forward a packet in multicast.
474
   * \brief Forward a multicast packet.
473
   * \param idev Pointer to ingress network device
475
   * \param idev Pointer to ingress network device
474
   * \param mrtentry route 
476
   * \param mrtentry route 
475
   * \param p packet to forward
477
   * \param p packet to forward
(-)a/src/internet/model/ipv6-list-routing.h (-9 / +2 lines)
 Lines 136-150    Link Here 
136
   */
136
   */
137
  static bool Compare (const Ipv6RoutingProtocolEntry& a, const Ipv6RoutingProtocolEntry& b);
137
  static bool Compare (const Ipv6RoutingProtocolEntry& a, const Ipv6RoutingProtocolEntry& b);
138
138
139
  /**
139
  Ipv6RoutingProtocolList m_routingProtocols; //!<  List of routing protocols.
140
   * \brief List of routing protocols.
140
  Ptr<Ipv6> m_ipv6;  //!< Ipv6 this protocol is associated with.
141
   */
142
  Ipv6RoutingProtocolList m_routingProtocols;
143
144
  /**
145
   * \brief Ipv6 reference.
146
   */
147
  Ptr<Ipv6> m_ipv6;
148
};
141
};
149
142
150
} // namespace ns3
143
} // namespace ns3
(-)a/src/internet/model/ipv6-raw-socket-factory-impl.h (+2 lines)
 Lines 27-32    Link Here 
27
{
27
{
28
28
29
/**
29
/**
30
 * \ingroup socket
31
 *
30
 * \class Ipv6RawSocketFactoryImpl
32
 * \class Ipv6RawSocketFactoryImpl
31
 * \brief Implementation of IPv6 raw socket factory.
33
 * \brief Implementation of IPv6 raw socket factory.
32
 */
34
 */
(-)a/src/internet/model/ipv6-raw-socket-impl.h (-96 / +2 lines)
 Lines 36-41    Link Here 
36
/**
36
/**
37
 * \class Ipv6RawSocketImpl
37
 * \class Ipv6RawSocketImpl
38
 * \brief IPv6 raw socket.
38
 * \brief IPv6 raw socket.
39
 * \ingroup socket
39
 *
40
 *
40
 * A RAW Socket typically is used to access specific IP layers not usually
41
 * A RAW Socket typically is used to access specific IP layers not usually
41
 * available through L4 sockets, e.g., ICMP. The implementer should take
42
 * available through L4 sockets, e.g., ICMP. The implementer should take
 Lines 70-95    Link Here 
70
   */
71
   */
71
  static TypeId GetTypeId ();
72
  static TypeId GetTypeId ();
72
73
73
  /**
74
   * \brief Constructor.
75
   */
76
  Ipv6RawSocketImpl ();
74
  Ipv6RawSocketImpl ();
77
78
  /**
79
   * \brief Destructor.
80
   */
81
  virtual ~Ipv6RawSocketImpl ();
75
  virtual ~Ipv6RawSocketImpl ();
82
76
83
  /**
77
  /**
84
   * \brief Set the node.
78
   * \brief Set the node associated with this socket.
85
   * \param node node to set
79
   * \param node node to set
86
   */
80
   */
87
  void SetNode (Ptr<Node> node);
81
  void SetNode (Ptr<Node> node);
88
82
89
  /**
90
   * \brief Get last error number.
91
   * \return error number
92
   */
93
  virtual enum Socket::SocketErrno GetErrno () const;
83
  virtual enum Socket::SocketErrno GetErrno () const;
94
84
95
  /**
85
  /**
 Lines 98-205    Link Here 
98
   */
88
   */
99
  virtual enum Socket::SocketType GetSocketType () const;
89
  virtual enum Socket::SocketType GetSocketType () const;
100
90
101
  /**
102
   * \brief Get node.
103
   * \return node associated with this raw socket.
104
   */
105
  virtual Ptr<Node> GetNode () const;
91
  virtual Ptr<Node> GetNode () const;
106
92
107
  /**
108
   * \brief Bind the socket to address.
109
   * \param address bind to this address
110
   * \return 0 if success, -1 otherwise
111
   */
112
  virtual int Bind (const Address& address);
93
  virtual int Bind (const Address& address);
113
114
  /**
115
   * \brief Bind socket.
116
   * \return 0 if success, -1 otherwise
117
   */
118
  virtual int Bind ();
94
  virtual int Bind ();
119
  virtual int Bind6 ();
95
  virtual int Bind6 ();
120
96
121
  /**
122
   * \brief Get socket address.
123
   * \param address socket address if method success
124
   * \return 0 if success, -1 otherwise
125
   */
126
  virtual int GetSockName (Address& address) const;
97
  virtual int GetSockName (Address& address) const;
127
98
128
  /**
129
   * \brief Close the socket.
130
   * \return 0 if success, -1 otherwise
131
   */
132
  virtual int Close ();
99
  virtual int Close ();
133
134
  /**
135
   * \brief Shutdown send capability.
136
   * \return 0 if success, -1 otherwise
137
   */
138
  virtual int ShutdownSend ();
100
  virtual int ShutdownSend ();
139
140
  /**
141
   * \brief Shutdown receive capability.
142
   * \return 0 if success, -1 otherwise
143
   */
144
  virtual int ShutdownRecv ();
101
  virtual int ShutdownRecv ();
145
146
  /**
147
   * \brief Connect to address.
148
   * \param address address
149
   * \return 0 if success, -1 otherwise
150
   */
151
  virtual int Connect (const Address& address);
102
  virtual int Connect (const Address& address);
152
153
  /**
154
   * \brief Listen.
155
   * \return 0 if success, -1 otherwise
156
   */
157
  virtual int Listen ();
103
  virtual int Listen ();
158
159
  /**
160
   * \brief Get TX size available.
161
   * \return TX size
162
   */
163
  virtual uint32_t GetTxAvailable () const;
104
  virtual uint32_t GetTxAvailable () const;
164
165
  /**
166
   * \brief Get RX size available.
167
   * \return RX size
168
   */
169
  virtual uint32_t GetRxAvailable () const;
105
  virtual uint32_t GetRxAvailable () const;
170
171
  /**
172
   * \brief Send a packet.
173
   * \param p packet to send
174
   * \param flags additionnal flags
175
   * \return 0 if success, -1 otherwise
176
   */
177
  virtual int Send (Ptr<Packet> p, uint32_t flags);
106
  virtual int Send (Ptr<Packet> p, uint32_t flags);
178
179
  /**
180
   * \brief Send a packet.
181
   * \param p packet to send
182
   * \param flags additionnal flags
183
   * \param toAddress destination address
184
   * \return 0 if success, -1 otherwise
185
   */
186
  virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address& toAddress);
107
  virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address& toAddress);
187
188
  /**
189
   * \brief Receive packet.
190
   * \param maxSize maximum size
191
   * \param flags additionnal flags
192
   * \return packet received
193
   */
194
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
108
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
195
196
  /**
197
   * \brief Receive packet.
198
   * \param maxSize maximum size
199
   * \param flags additionnal flags
200
   * \param fromAddress source address
201
   * \return packet received
202
   */
203
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress);
109
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress);
204
110
205
  /**
111
  /**
(-)a/src/internet/model/ipv6-routing-table-entry.h (-12 / +12 lines)
 Lines 261-272    Link Here 
261
};
261
};
262
262
263
/**
263
/**
264
* \brief Stream insertion operator.
264
 * \brief Stream insertion operator.
265
*
265
 *
266
* \param os the reference to the output stream
266
 * \param os the reference to the output stream
267
* \param route the Ipv6 routing table entry
267
 * \param route the Ipv6 routing table entry
268
* \returns the reference to the output stream
268
 * \returns the reference to the output stream
269
*/
269
 */
270
std::ostream& operator<< (std::ostream& os, Ipv6RoutingTableEntry const& route);
270
std::ostream& operator<< (std::ostream& os, Ipv6RoutingTableEntry const& route);
271
271
272
/**
272
/**
 Lines 372-383    Link Here 
372
};
372
};
373
373
374
/**
374
/**
375
* \brief Stream insertion operator.
375
 * \brief Stream insertion operator.
376
*
376
 *
377
* \param os the reference to the output stream
377
 * \param os the reference to the output stream
378
* \param route the Ipv6 multicast routing table entry
378
 * \param route the Ipv6 multicast routing table entry
379
* \returns the reference to the output stream
379
 * \returns the reference to the output stream
380
*/
380
 */
381
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoutingTableEntry const& route);
381
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoutingTableEntry const& route);
382
382
383
} /* namespace ns3 */
383
} /* namespace ns3 */
(-)a/src/internet/model/ipv6-static-routing.h (-8 / +14 lines)
 Lines 48-56    Link Here 
48
/**
48
/**
49
 * \ingroup ipv6StaticRouting
49
 * \ingroup ipv6StaticRouting
50
 * \class Ipv6StaticRouting
50
 * \class Ipv6StaticRouting
51
 * \brief Static routing protocol for IP version 6 stack.
51
 *
52
 * \brief Static routing protocol for IP version 6 stacks.
53
 *
54
 * This class provides a basic set of methods for inserting static
55
 * unicast and multicast routes into the Ipv6 routing system.
56
 * This particular protocol is designed to be inserted into an
57
 * Ipv6ListRouting protocol but can be used also as a standalone
58
 * protocol.
59
 *
60
 * The Ipv6StaticRouting class inherits from the abstract base class
61
 * Ipv6RoutingProtocol that defines the interface methods that a routing
62
 * protocol must support.
63
 *
52
 * \see Ipv6RoutingProtocol
64
 * \see Ipv6RoutingProtocol
53
 * \see Ipv6ListRouting
65
 * \see Ipv6ListRouting
66
 * \see Ipv6ListRouting::AddRoutingProtocol
54
 */
67
 */
55
class Ipv6StaticRouting : public Ipv6RoutingProtocol
68
class Ipv6StaticRouting : public Ipv6RoutingProtocol
56
{
69
{
 Lines 61-74    Link Here 
61
   */
74
   */
62
  static TypeId GetTypeId ();
75
  static TypeId GetTypeId ();
63
76
64
  /**
65
   * \brief Constructor.
66
   */
67
  Ipv6StaticRouting ();
77
  Ipv6StaticRouting ();
68
69
  /**
70
   * \brief Destructor.
71
   */
72
  virtual ~Ipv6StaticRouting ();
78
  virtual ~Ipv6StaticRouting ();
73
79
74
  /**
80
  /**
(-)a/src/internet/model/loopback-net-device.h (-4 / +25 lines)
 Lines 38-43    Link Here 
38
class LoopbackNetDevice : public NetDevice
38
class LoopbackNetDevice : public NetDevice
39
{
39
{
40
public:
40
public:
41
  /**
42
   * \brief Get the type ID.
43
   * \return the object TypeId
44
   */
41
  static TypeId GetTypeId (void);
45
  static TypeId GetTypeId (void);
42
  LoopbackNetDevice ();
46
  LoopbackNetDevice ();
43
47
 Lines 72-84    Link Here 
72
protected:
76
protected:
73
  virtual void DoDispose (void);
77
  virtual void DoDispose (void);
74
private:
78
private:
79
  /**
80
   * Receive a packet from tge Loopback NetDevice.
81
   *
82
   * \param packet a reference to the received packet
83
   * \param protocol the protocol
84
   * \param to destination address
85
   * \param from source address
86
   */
75
  void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
87
  void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
88
89
  /**
90
   * The callback used to notify higher layers that a packet has been received.
91
   */
76
  NetDevice::ReceiveCallback m_rxCallback;
92
  NetDevice::ReceiveCallback m_rxCallback;
93
94
  /**
95
   * The callback used to notify higher layers that a packet has been received in promiscuous mode.
96
   */
77
  NetDevice::PromiscReceiveCallback m_promiscCallback;
97
  NetDevice::PromiscReceiveCallback m_promiscCallback;
78
  Ptr<Node> m_node;
98
79
  uint16_t m_mtu;
99
  Ptr<Node> m_node; //!< the node this NetDevice is associated with
80
  uint32_t m_ifIndex;
100
  uint16_t m_mtu; //!< device MTU
81
  Mac48Address m_address;
101
  uint32_t m_ifIndex; //!< interface index
102
  Mac48Address m_address; //!< NetDevice MAC address
82
};
103
};
83
104
84
} // namespace ns3
105
} // namespace ns3
(-)a/src/internet/model/ndisc-cache.h (-5 / +14 lines)
 Lines 412-431    Link Here 
412
  };
412
  };
413
413
414
private:
414
private:
415
  /**
416
   * \brief Neighbor Discovery Cache container
417
   */
415
  typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash> Cache;
418
  typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash> Cache;
419
  /**
420
   * \brief Neighbor Discovery Cache container iterator
421
   */
416
  typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash>::iterator CacheI;
422
  typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash>::iterator CacheI;
417
423
418
  /**
424
  /**
419
   * \brief Copy constructor.
425
   * \brief Copy constructor.
420
   * \param a cache to copy
426
   *
427
   * Not implemented to avoid misuse
421
   */
428
   */
422
  NdiscCache (NdiscCache const &a);
429
  NdiscCache (NdiscCache const &);
423
430
424
  /**
431
  /**
425
   * \brief Equal operator.
432
   * \brief Copy constructor.
426
   * \param a cache to copy
433
   *
434
   * Not implemented to avoid misuse
435
   * \returns
427
   */
436
   */
428
  NdiscCache& operator= (NdiscCache const &a);
437
  NdiscCache& operator= (NdiscCache const &);
429
438
430
  /**
439
  /**
431
   * \brief Dispose this object.
440
   * \brief Dispose this object.
(-)a/src/internet/model/nsc-sysctl.cc (-1 / +11 lines)
 Lines 23-31    Link Here 
23
23
24
namespace ns3 {
24
namespace ns3 {
25
25
26
/**
27
 * \ingroup nsctcp
28
 *
29
 * This object represent the underlying nsc stack attributes and
30
 * provide a ns-3-like system to access them though sysctls
31
 */
26
class NscStackStringAccessor : public AttributeAccessor
32
class NscStackStringAccessor : public AttributeAccessor
27
{
33
{
28
public:
34
public:
35
  /**
36
   * \brief Constructor
37
   * \param name name of the attribute
38
   */
29
  NscStackStringAccessor (std::string name) : m_name (name) {}
39
  NscStackStringAccessor (std::string name) : m_name (name) {}
30
40
31
  virtual bool Set (ObjectBase * object, const AttributeValue &val) const;
41
  virtual bool Set (ObjectBase * object, const AttributeValue &val) const;
 Lines 33-39    Link Here 
33
  virtual bool HasGetter (void) const;
43
  virtual bool HasGetter (void) const;
34
  virtual bool HasSetter (void) const;
44
  virtual bool HasSetter (void) const;
35
private:
45
private:
36
  std::string m_name;
46
  std::string m_name; //!< name of the attribute
37
};
47
};
38
48
39
bool NscStackStringAccessor::HasGetter (void) const
49
bool NscStackStringAccessor::HasGetter (void) const
(-)a/src/internet/model/nsc-sysctl.h (-4 / +26 lines)
 Lines 25-44    Link Here 
25
25
26
namespace ns3 {
26
namespace ns3 {
27
27
28
// This object represents the underlying nsc stack,
28
/**
29
// which is aggregated to a Node object, and which provides access to the
29
 * \ingroup nsctcp
30
// sysctls of the nsc stack through attributes.
30
 *
31
 * This object represents the underlying nsc stack,
32
 * which is aggregated to a Node object, and which provides access to the
33
 * sysctls of the nsc stack through attributes.
34
 */
31
class Ns3NscStack : public Object
35
class Ns3NscStack : public Object
32
{
36
{
33
public:
37
public:
38
  /**
39
   * \brief Get the type ID.
40
   * \return the object TypeId
41
   */
34
  static TypeId GetTypeId (void);
42
  static TypeId GetTypeId (void);
35
  virtual TypeId GetInstanceTypeId (void) const;
43
  virtual TypeId GetInstanceTypeId (void) const;
44
  /**
45
   * \brief Set the underlying stack
46
   * \param stack the stack
47
   */
36
  void SetStack (INetStack *stack) { m_stack = stack; }
48
  void SetStack (INetStack *stack) { m_stack = stack; }
37
49
38
private:
50
private:
39
  friend class NscStackStringAccessor;
51
  friend class NscStackStringAccessor;
52
  /**
53
   * \brief Set an attribute
54
   * \param name the attribute name
55
   * \param value the attribute value
56
   */
40
  void Set (std::string name, std::string value);
57
  void Set (std::string name, std::string value);
58
  /**
59
   * \brief Get an attribute
60
   * \param name the attribute name
61
   * \returns the attribute value
62
   */
41
  std::string Get (std::string name) const;
63
  std::string Get (std::string name) const;
42
  INetStack *m_stack;
64
  INetStack *m_stack; //!< the underlying stack
43
};
65
};
44
} // namespace ns3
66
} // namespace ns3
(-)a/src/internet/model/nsc-tcp-l4-protocol.cc (-4 / +40 lines)
 Lines 55-70    Link Here 
55
/* see http://www.iana.org/assignments/protocol-numbers */
55
/* see http://www.iana.org/assignments/protocol-numbers */
56
const uint8_t NscTcpL4Protocol::PROT_NUMBER = 6;
56
const uint8_t NscTcpL4Protocol::PROT_NUMBER = 6;
57
57
58
/**
59
 * \ingroup nsctcp
60
 * \brief Nsc interface implementation class.
61
 */
58
class NscInterfaceImpl : public ISendCallback, public IInterruptCallback 
62
class NscInterfaceImpl : public ISendCallback, public IInterruptCallback 
59
{
63
{
60
public:
64
public:
65
  /**
66
   * Constructor
67
   * \param prot the NSC TCP protocol
68
   */
61
  NscInterfaceImpl (Ptr<NscTcpL4Protocol> prot);
69
  NscInterfaceImpl (Ptr<NscTcpL4Protocol> prot);
62
private:
70
private:
71
  /**
72
   * \brief Invoked by NSCs 'ethernet driver' to re-inject a packet into ns-3.
73
   *
74
   * A packet is an octet soup consisting of an IP Header, TCP Header
75
   * and user payload, if any
76
   *
77
   * \param data the data
78
   * \param datalen the data length
79
   */
63
  virtual void send_callback (const void *data, int datalen);
80
  virtual void send_callback (const void *data, int datalen);
81
  /**
82
   * \brief Called by the NSC stack whenever something of interest has happened
83
   *
84
   * Examples: when data arrives on a socket, a listen socket
85
   * has a new connection pending, etc.
86
   */
64
  virtual void wakeup ();
87
  virtual void wakeup ();
88
  /**
89
   * \brief Called by the Linux stack RNG initialization
90
   *
91
   * Its also used by the cradle code to add a timestamp to
92
   * printk/printf/debug output.
93
   */
65
  virtual void gettime (unsigned int *, unsigned int *);
94
  virtual void gettime (unsigned int *, unsigned int *);
66
private:
95
private:
67
  Ptr<NscTcpL4Protocol> m_prot;
96
  Ptr<NscTcpL4Protocol> m_prot; //!< the NSC TCP protocol
68
};
97
};
69
98
70
NscInterfaceImpl::NscInterfaceImpl (Ptr<NscTcpL4Protocol> prot)
99
NscInterfaceImpl::NscInterfaceImpl (Ptr<NscTcpL4Protocol> prot)
 Lines 113-121    Link Here 
113
  return tid;
142
  return tid;
114
}
143
}
115
144
145
/**
146
 * \brief External Random number generator
147
 *
148
 * \todo make it random...
149
 *
150
 * \returns a random number
151
 */
116
int external_rand ()
152
int external_rand ()
117
{
153
{
118
  return 1;   /// \todo
154
  return 1;
119
}
155
}
120
156
121
NscTcpL4Protocol::NscTcpL4Protocol ()
157
NscTcpL4Protocol::NscTcpL4Protocol ()
 Lines 385-391    Link Here 
385
421
386
void NscTcpL4Protocol::wakeup ()
422
void NscTcpL4Protocol::wakeup ()
387
{
423
{
388
  /// \todo
424
  // \todo
389
  // this should schedule a timer to read from all tcp sockets now... this is
425
  // this should schedule a timer to read from all tcp sockets now... this is
390
  // an indication that data might be waiting on the socket
426
  // an indication that data might be waiting on the socket
391
427
 Lines 451-457    Link Here 
451
          // IP address of the subnet but this was found to fail for
487
          // IP address of the subnet but this was found to fail for
452
          // some use cases in /30 subnets.
488
          // some use cases in /30 subnets.
453
489
454
          /// \todo \bugid{1398} NSC's limitation to single-interface nodes
490
          // \todo \bugid{1398} NSC's limitation to single-interface nodes
455
          m_nscStack->add_default_gateway (addrOss.str ().c_str ());
491
          m_nscStack->add_default_gateway (addrOss.str ().c_str ());
456
        }
492
        }
457
    }
493
    }
(-)a/src/internet/model/nsc-tcp-l4-protocol.h (-33 / +116 lines)
 Lines 45-62    Link Here 
45
 */
45
 */
46
class NscTcpL4Protocol : public IpL4Protocol {
46
class NscTcpL4Protocol : public IpL4Protocol {
47
public:
47
public:
48
  static const uint8_t PROT_NUMBER;
48
  static const uint8_t PROT_NUMBER; //!< protocol number (0x6)
49
  /**
50
   * \brief Get the type ID.
51
   * \return the object TypeId
52
   */
49
  static TypeId GetTypeId (void);
53
  static TypeId GetTypeId (void);
50
  /**
54
51
   * \brief Constructor
52
   */
53
  NscTcpL4Protocol ();
55
  NscTcpL4Protocol ();
54
  virtual ~NscTcpL4Protocol ();
56
  virtual ~NscTcpL4Protocol ();
55
57
58
  /**
59
   * Set node associated with this stack
60
   * \param node the node
61
   */
56
  void SetNode (Ptr<Node> node);
62
  void SetNode (Ptr<Node> node);
63
64
  /**
65
   * Set the NSC library to be used
66
   * \param lib the library path
67
   */
57
  void SetNscLibrary (const std::string &lib);
68
  void SetNscLibrary (const std::string &lib);
69
70
  /**
71
   * Get the NSC library being used
72
   * \returns the library path
73
   */
58
  std::string GetNscLibrary (void) const;
74
  std::string GetNscLibrary (void) const;
59
  virtual int GetProtocolNumber (void) const;
75
  virtual int GetProtocolNumber (void) const;
76
77
  /**
78
   * Get the NSC version
79
   * \returns the NSC version
80
   */
60
  virtual int GetVersion (void) const;
81
  virtual int GetVersion (void) const;
61
82
62
  /**
83
  /**
 Lines 65-91    Link Here 
65
   */
86
   */
66
  Ptr<Socket> CreateSocket (void);
87
  Ptr<Socket> CreateSocket (void);
67
88
89
  /**
90
   * \brief Allocate an IPv4 Endpoint
91
   * \return the Endpoint
92
   */
68
  Ipv4EndPoint *Allocate (void);
93
  Ipv4EndPoint *Allocate (void);
94
  /**
95
   * \brief Allocate an IPv4 Endpoint
96
   * \param address address to use
97
   * \return the Endpoint
98
   */
69
  Ipv4EndPoint *Allocate (Ipv4Address address);
99
  Ipv4EndPoint *Allocate (Ipv4Address address);
100
  /**
101
   * \brief Allocate an IPv4 Endpoint
102
   * \param port port to use
103
   * \return the Endpoint
104
   */
70
  Ipv4EndPoint *Allocate (uint16_t port);
105
  Ipv4EndPoint *Allocate (uint16_t port);
106
  /**
107
   * \brief Allocate an IPv4 Endpoint
108
   * \param address address to use
109
   * \param port port to use
110
   * \return the Endpoint
111
   */
71
  Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
112
  Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
113
  /**
114
   * \brief Allocate an IPv4 Endpoint
115
   * \param localAddress local address to use
116
   * \param localPort local port to use
117
   * \param peerAddress remote address to use
118
   * \param peerPort remote port to use
119
   * \return the Endpoint
120
   */
72
  Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
121
  Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
73
                          Ipv4Address peerAddress, uint16_t peerPort);
122
                          Ipv4Address peerAddress, uint16_t peerPort);
74
123
124
125
  /**
126
   * \brief Remove an IPv4 Endpoint.
127
   * \param endPoint the end point to remove
128
   */
75
  void DeAllocate (Ipv4EndPoint *endPoint);
129
  void DeAllocate (Ipv4EndPoint *endPoint);
76
130
77
  /**
78
   * \brief Receive a packet up the protocol stack
79
   * \param p The Packet to dump the contents into
80
   * \param header IPv4 Header information
81
   * \param incomingInterface The Ipv4Interface it was received on
82
   */
83
  virtual IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
131
  virtual IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
84
                                            Ipv4Header const &header,
132
                                          Ipv4Header const &header,
85
                                            Ptr<Ipv4Interface> incomingInterface);
133
                                          Ptr<Ipv4Interface> incomingInterface);
86
  virtual IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
134
  virtual IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
87
                                                 Ipv6Header const &header,
135
                                          Ipv6Header const &header,
88
                                                 Ptr<Ipv6Interface> interface);
136
                                          Ptr<Ipv6Interface> interface);
89
137
90
  // From IpL4Protocol
138
  // From IpL4Protocol
91
  virtual void SetDownTarget (IpL4Protocol::DownTargetCallback cb);
139
  virtual void SetDownTarget (IpL4Protocol::DownTargetCallback cb);
 Lines 97-134    Link Here 
97
  virtual void DoDispose (void);
145
  virtual void DoDispose (void);
98
  virtual void NotifyNewAggregate ();
146
  virtual void NotifyNewAggregate ();
99
private:
147
private:
148
  /**
149
   * \brief Copy constructor
150
   *
151
   * Defined and not implemented to avoid misuse
152
   */
100
  NscTcpL4Protocol (NscTcpL4Protocol const &);
153
  NscTcpL4Protocol (NscTcpL4Protocol const &);
154
  /**
155
   * \brief Copy constructor
156
   *
157
   * Defined and not implemented to avoid misuse
158
   * \returns
159
   */
101
  NscTcpL4Protocol& operator= (NscTcpL4Protocol const &);
160
  NscTcpL4Protocol& operator= (NscTcpL4Protocol const &);
102
161
103
  // NSC callbacks.
162
  // NSC callbacks.
104
  // NSC invokes these hooks to interact with the simulator.
163
  // NSC invokes these hooks to interact with the simulator.
105
  // In any case, these methods are only to be called by NSC.
164
  // In any case, these methods are only to be called by NSC.
106
  //
165
107
  // send_callback is invoked by NSCs 'ethernet driver' to re-inject
166
  /**
108
  // a packet (i.e. an octet soup consisting of an IP Header, TCP Header
167
   * \brief Invoked by NSCs 'ethernet driver' to re-inject a packet into ns-3.
109
  // and user payload, if any), into ns-3.
168
   *
169
   * A packet is an octet soup consisting of an IP Header, TCP Header
170
   * and user payload, if any
171
   *
172
   * \param data the data
173
   * \param datalen the data length
174
   */
110
  void send_callback (const void *data, int datalen);
175
  void send_callback (const void *data, int datalen);
111
  // This is called by the NSC stack whenever something of interest
176
  /**
112
  // has happened, e.g. when data arrives on a socket, a listen socket
177
   * \brief Called by the NSC stack whenever something of interest has happened
113
  // has a new connection pending, etc.
178
   *
179
   * Examples: when data arrives on a socket, a listen socket
180
   * has a new connection pending, etc.
181
   */
114
  void wakeup ();
182
  void wakeup ();
115
  // This is called by the Linux stack RNG initialization.
183
  /**
116
  // Its also used by the cradle code to add a timestamp to
184
   * \brief Called by the Linux stack RNG initialization
117
  // printk/printf/debug output.
185
   *
186
   * Its also used by the cradle code to add a timestamp to
187
   * printk/printf/debug output.
188
   * \param sec seconds
189
   * \param usec microseconds
190
   */
118
  void gettime (unsigned int *sec, unsigned int *usec);
191
  void gettime (unsigned int *sec, unsigned int *usec);
192
  /**
193
   * \brief Add an interface
194
   *
195
   * Actually NSC only supports one interface per node (\bugid{1398})
196
   */
119
  void AddInterface (void);
197
  void AddInterface (void);
198
199
  /**
200
   * \brief Provide a "soft" interrupt to NSC
201
   */
120
  void SoftInterrupt (void);
202
  void SoftInterrupt (void);
121
  friend class NscInterfaceImpl;
203
  friend class NscInterfaceImpl;
122
  friend class NscTcpSocketImpl;
204
  friend class NscTcpSocketImpl;
123
  Ptr<Node> m_node;
205
124
  Ipv4EndPointDemux *m_endPoints;
206
  Ptr<Node> m_node; //!< the node this stack is associated with
125
  INetStack* m_nscStack;
207
  Ipv4EndPointDemux *m_endPoints; //!< A list of IPv4 end points.
126
  NscInterfaceImpl *m_nscInterface;
208
  INetStack* m_nscStack; //!< the NSC stack.
127
  void *m_dlopenHandle;
209
  NscInterfaceImpl *m_nscInterface; //!< the NSC Interface.
128
  std::string m_nscLibrary;
210
  void *m_dlopenHandle; //!< dynamic library handle.
129
  Timer m_softTimer;
211
  std::string m_nscLibrary; //!< path to the NSC library.
130
  std::vector<Ptr<NscTcpSocketImpl> > m_sockets;
212
  Timer m_softTimer; //!< Soft interrupt timer
131
  IpL4Protocol::DownTargetCallback m_downTarget;
213
  std::vector<Ptr<NscTcpSocketImpl> > m_sockets; //!< list of sockets
214
  IpL4Protocol::DownTargetCallback m_downTarget; //!< Callback to send packets over IPv4
132
};
215
};
133
216
134
} // namespace ns3
217
} // namespace ns3
(-)a/src/internet/model/nsc-tcp-socket-factory-impl.h (-1 / +5 lines)
 Lines 47-52    Link Here 
47
  NscTcpSocketFactoryImpl ();
47
  NscTcpSocketFactoryImpl ();
48
  virtual ~NscTcpSocketFactoryImpl ();
48
  virtual ~NscTcpSocketFactoryImpl ();
49
49
50
  /**
51
   * \brief Set the associated TCP L4 protocol.
52
   * \param tcp the TCP L4 protocol
53
   */
50
  void SetTcp (Ptr<NscTcpL4Protocol> tcp);
54
  void SetTcp (Ptr<NscTcpL4Protocol> tcp);
51
55
52
  virtual Ptr<Socket> CreateSocket (void);
56
  virtual Ptr<Socket> CreateSocket (void);
 Lines 54-60    Link Here 
54
protected:
58
protected:
55
  virtual void DoDispose (void);
59
  virtual void DoDispose (void);
56
private:
60
private:
57
  Ptr<NscTcpL4Protocol> m_tcp;
61
  Ptr<NscTcpL4Protocol> m_tcp; //!< the associated TCP L4 protocol
58
};
62
};
59
63
60
} // namespace ns3
64
} // namespace ns3
(-)a/src/internet/model/nsc-tcp-socket-impl.h (-35 / +113 lines)
 Lines 53-67    Link Here 
53
class NscTcpSocketImpl : public TcpSocket
53
class NscTcpSocketImpl : public TcpSocket
54
{
54
{
55
public:
55
public:
56
  /**
57
   * \brief Get the type ID.
58
   * \return the object TypeId
59
   */
56
  static TypeId GetTypeId (void);
60
  static TypeId GetTypeId (void);
57
  /**
61
  /**
58
   * Create an unbound tcp socket.
62
   * Create an unbound tcp socket.
59
   */
63
   */
60
  NscTcpSocketImpl ();
64
  NscTcpSocketImpl ();
65
66
  /**
67
   * Clone a TCP socket, for use upon receiving a connection request in LISTEN state
68
   *
69
   * \param sock the original Tcp Socket
70
   */
61
  NscTcpSocketImpl (const NscTcpSocketImpl& sock);
71
  NscTcpSocketImpl (const NscTcpSocketImpl& sock);
62
  virtual ~NscTcpSocketImpl ();
72
  virtual ~NscTcpSocketImpl ();
63
73
74
  /**
75
   * \brief Set the associated node.
76
   * \param node the node
77
   */
64
  void SetNode (Ptr<Node> node);
78
  void SetNode (Ptr<Node> node);
79
80
  /**
81
   * \brief Set the associated TCP L4 protocol.
82
   * \param tcp the TCP L4 protocol
83
   */
65
  void SetTcp (Ptr<NscTcpL4Protocol> tcp);
84
  void SetTcp (Ptr<NscTcpL4Protocol> tcp);
66
85
67
  virtual enum SocketErrno GetErrno (void) const;
86
  virtual enum SocketErrno GetErrno (void) const;
 Lines 87-108    Link Here 
87
  virtual bool GetAllowBroadcast () const;
106
  virtual bool GetAllowBroadcast () const;
88
107
89
private:
108
private:
109
  /**
110
   * \brief Called by NscTcpSocketImpl::ForwardUp()
111
   *
112
   * Actually performs the ForwardUp operations
113
   */
90
  void NSCWakeup (void);
114
  void NSCWakeup (void);
91
  friend class Tcp;
115
  friend class Tcp;
92
  // invoked by Tcp class
116
  // invoked by Tcp class
117
  /**
118
   * Finish the binding process
119
   * \returns 0 on success, -1 on failure
120
   */
93
  int FinishBind (void);
121
  int FinishBind (void);
122
  /**
123
   * \brief Called by the L3 protocol when it received a packet to pass on to TCP.
124
   *
125
   * \param p the incoming packet
126
   * \param header the packet's IPv4 header
127
   * \param port the incoming port
128
   * \param incomingInterface the incoming interface
129
   */
94
  void ForwardUp (Ptr<Packet> p, Ipv4Header header, uint16_t port, 
130
  void ForwardUp (Ptr<Packet> p, Ipv4Header header, uint16_t port, 
95
                  Ptr<Ipv4Interface> incomingInterface);
131
                  Ptr<Ipv4Interface> incomingInterface);
132
  /**
133
   * \brief Kill this socket by zeroing its attributes (IPv4)
134
   *
135
   * This is a callback function configured to m_endpoint in
136
   * SetupCallback(), invoked when the endpoint is destroyed.
137
   */
96
  void Destroy (void);
138
  void Destroy (void);
97
  //methods for state
139
  //methods for state
140
  /**
141
   * \brief Send all the pending data
142
   * \returns true on success
143
   */
98
  bool SendPendingData (void);
144
  bool SendPendingData (void);
145
  /**
146
   * \brief Read all the pending data
147
   * \returns true on success
148
   */
99
  bool ReadPendingData (void);
149
  bool ReadPendingData (void);
150
  /**
151
   * \brief Accept an incoming connection
152
   * \returns true on success
153
   */
100
  bool Accept (void);
154
  bool Accept (void);
155
  /**
156
   * \brief Complete the Fork operations (after a connection has been accepted)
157
   */
101
  void CompleteFork (void);
158
  void CompleteFork (void);
159
160
  /**
161
   * \brief Called when a connection is in Established state
162
   */
102
  void ConnectionSucceeded ();
163
  void ConnectionSucceeded ();
103
164
104
  // Manage data tx/rx
165
  // Manage data tx/rx
105
  /// \todo This should be virtual and overridden
166
  // \todo This should be virtual and overridden
167
  /**
168
   * \brief Copy self
169
   * \returns a copy of self
170
   */
106
  Ptr<NscTcpSocketImpl> Copy ();
171
  Ptr<NscTcpSocketImpl> Copy ();
107
172
108
  // attribute related
173
  // attribute related
 Lines 112-118    Link Here 
112
  virtual uint32_t GetRcvBufSize (void) const;
177
  virtual uint32_t GetRcvBufSize (void) const;
113
  virtual void SetSegSize (uint32_t size);
178
  virtual void SetSegSize (uint32_t size);
114
  virtual uint32_t GetSegSize (void) const;
179
  virtual uint32_t GetSegSize (void) const;
180
  /**
181
   * \brief Set the Advertised Window size
182
   * \param window the window size
183
   */
115
  virtual void SetAdvWin (uint32_t window);
184
  virtual void SetAdvWin (uint32_t window);
185
  /**
186
   * \brief Get the Advertised Window size
187
   * \returns the window size
188
   */
116
  virtual uint32_t GetAdvWin (void) const;
189
  virtual uint32_t GetAdvWin (void) const;
117
  virtual void SetSSThresh (uint32_t threshold);
190
  virtual void SetSSThresh (uint32_t threshold);
118
  virtual uint32_t GetSSThresh (void) const;
191
  virtual uint32_t GetSSThresh (void) const;
 Lines 131-187    Link Here 
131
  virtual void SetPersistTimeout (Time timeout);
204
  virtual void SetPersistTimeout (Time timeout);
132
  virtual Time GetPersistTimeout (void) const;
205
  virtual Time GetPersistTimeout (void) const;
133
206
207
  /**
208
   * \brief Translate between a NSC error and a ns-3 error code
209
   * \param err NSC error
210
   * \returns ns-3 error code
211
   */
134
  enum Socket::SocketErrno GetNativeNs3Errno (int err) const;
212
  enum Socket::SocketErrno GetNativeNs3Errno (int err) const;
135
  uint32_t m_delAckMaxCount;
213
  uint32_t m_delAckMaxCount;  //!< Number of packet to fire an ACK before delay timeout
136
  Time m_delAckTimeout;
214
  Time m_delAckTimeout;       //!< Time to delay an ACK
137
  bool m_noDelay;
215
  bool m_noDelay;             //!< Disable ACk delay
138
216
139
  Ipv4EndPoint *m_endPoint;
217
  Ipv4EndPoint *m_endPoint;     //!< the IPv4 endpoint
140
  Ptr<Node> m_node;
218
  Ptr<Node> m_node;             //!< the associated node
141
  Ptr<NscTcpL4Protocol> m_tcp;
219
  Ptr<NscTcpL4Protocol> m_tcp;  //!< the associated TCP L4 protocol
142
  Ipv4Address m_remoteAddress;
220
  Ipv4Address m_remoteAddress;  //!< peer IP address
143
  uint16_t m_remotePort;
221
  uint16_t m_remotePort;        //!< peer port
144
  //these two are so that the socket/endpoint cloning works
222
  //these two are so that the socket/endpoint cloning works
145
  Ipv4Address m_localAddress;
223
  Ipv4Address m_localAddress;   //!< local address
146
  uint16_t m_localPort;
224
  uint16_t m_localPort;         //!< local port
147
  InetSocketAddress m_peerAddress;
225
  InetSocketAddress m_peerAddress; //!< peer IP and port
148
  enum SocketErrno m_errno;
226
  enum SocketErrno m_errno;     //!< last error number
149
  bool m_shutdownSend;
227
  bool m_shutdownSend;          //!< Send no longer allowed
150
  bool m_shutdownRecv;
228
  bool m_shutdownRecv;          //!< Receive no longer allowed
151
  bool m_connected;
229
  bool m_connected;             //!< Connection established
152
230
153
  //manage the state information
231
  //manage the state information
154
  TracedValue<TcpStates_t> m_state;
232
  TracedValue<TcpStates_t> m_state; //!< state information
155
  bool m_closeOnEmpty;
233
  bool m_closeOnEmpty;              //!< true if socket will close when buffer is empty
156
234
157
  //needed to queue data when in SYN_SENT state
235
  //needed to queue data when in SYN_SENT state
158
  std::queue<Ptr<Packet> > m_txBuffer;
236
  std::queue<Ptr<Packet> > m_txBuffer; //!< transmission buffer
159
  uint32_t m_txBufferSize;
237
  uint32_t m_txBufferSize;             //!< transmission buffer size
160
238
161
  // Window management
239
  // Window management
162
  uint32_t                       m_segmentSize;          //SegmentSize
240
  uint32_t                       m_segmentSize;          //!< SegmentSize
163
  uint32_t                       m_rxWindowSize;
241
  uint32_t                       m_rxWindowSize;         //!< Receive window size
164
  uint32_t                       m_advertisedWindowSize; //Window to advertise
242
  uint32_t                       m_advertisedWindowSize; //!< Window to advertise
165
  TracedValue<uint32_t>          m_cWnd;                 //Congestion window
243
  TracedValue<uint32_t>          m_cWnd;                 //!< Congestion window
166
  uint32_t                       m_ssThresh;             //Slow Start Threshold
244
  uint32_t                       m_ssThresh;             //!< Slow Start Threshold
167
  uint32_t                       m_initialCWnd;          //Initial cWnd value
245
  uint32_t                       m_initialCWnd;          //!< Initial cWnd value
168
246
169
  // Round trip time estimation
247
  // Round trip time estimation
170
  Time m_lastMeasuredRtt;
248
  Time m_lastMeasuredRtt; //!< Last measured RTT
171
249
172
  // Timer-related members
250
  // Timer-related members
173
  Time              m_cnTimeout; 
251
  Time              m_cnTimeout;       //!< Timeout for connection retry
174
  uint32_t          m_cnCount;
252
  uint32_t          m_cnCount;         //!< Count of remaining connection retries
175
  Time              m_persistTimeout; 
253
  Time              m_persistTimeout;  //!< Time between sending 1-byte probes
176
254
177
  // Temporary queue for delivering data to application
255
  // Temporary queue for delivering data to application
178
  std::queue<Ptr<Packet> > m_deliveryQueue;
256
  std::queue<Ptr<Packet> > m_deliveryQueue; //!< receive buffer
179
  uint32_t m_rxAvailable;
257
  uint32_t m_rxAvailable;                   //!< receive buffer available size
180
  INetStreamSocket* m_nscTcpSocket;
258
  INetStreamSocket* m_nscTcpSocket;         //!< the real NSC TCP socket
181
259
182
  // Attributes
260
  // Attributes
183
  uint32_t m_sndBufSize;   // buffer limit for the outgoing queue
261
  uint32_t m_sndBufSize;   //!< buffer limit for the outgoing queue
184
  uint32_t m_rcvBufSize;   // maximum receive socket buffer size
262
  uint32_t m_rcvBufSize;   //!< maximum receive socket buffer size
185
};
263
};
186
264
187
} // namespace ns3
265
} // namespace ns3
(-)a/src/internet/model/pending-data.h (-17 / +89 lines)
 Lines 41-57    Link Here 
41
class PendingData {
41
class PendingData {
42
public:
42
public:
43
  PendingData ();
43
  PendingData ();
44
  /**
45
   * Constructor
46
   * \param s size
47
   * \param d data
48
   * \param msg message size
49
   * \param resp response size
50
   */
44
  PendingData (uint32_t s, uint8_t* d = NULL, uint32_t msg = 0, uint32_t resp = 0);
51
  PendingData (uint32_t s, uint8_t* d = NULL, uint32_t msg = 0, uint32_t resp = 0);
45
  PendingData (const std::string&); // Construct from string
52
  /**
46
  PendingData (uint8_t*, uint32_t&, Packet*); // Construct from serialized buffer
53
   * Constructor from string
47
  PendingData (const PendingData&);   // Copy constructor
54
   * \param s string
55
   */
56
  PendingData (const std::string& s); // Construct from string
57
  // not implemented ?
58
  // PendingData (uint8_t*, uint32_t&, Packet*); // Construct from serialized buffer
59
  /**
60
   * Copy constructor
61
   * \param o object to copy
62
   */
63
  PendingData (const PendingData& o);   // Copy constructor
48
  virtual ~PendingData ();     // Destructor
64
  virtual ~PendingData ();     // Destructor
65
66
  /**
67
   * Returns the size of the pending data
68
   * \returns size of pending data
69
   */
49
  uint32_t Size () const { return size; }
70
  uint32_t Size () const { return size; }
50
  // Serialization
71
  // Serialization
51
  uint8_t*  Serialize (uint8_t*, uint32_t&); // Serialize to a buffer
72
  // not implemented ?
52
  uint8_t*  Construct (uint8_t*, uint32_t&); // Construct from buffer
73
  // uint8_t*  Serialize (uint8_t*, uint32_t&); // Serialize to a buffer
53
  virtual void Clear (); // Remove all associated data
74
  // not implemented ?
54
  virtual void Add (uint32_t s, const uint8_t* d = 0); // Add some data to end
75
  // uint8_t*  Construct (uint8_t*, uint32_t&); // Construct from buffer
76
77
  /**
78
   * \brief Remove all associated data
79
   */
80
  virtual void Clear ();
81
82
  /**
83
   * \brief Add some data to end
84
   * \param s the data size.
85
   * \param d the data to store.
86
   */
87
  virtual void Add (uint32_t s, const uint8_t* d = 0); //
88
  /**
89
   * \brief Add some data to end
90
   * \param p packet containing the data.
91
   */
55
  virtual void Add (Ptr<Packet> p);
92
  virtual void Add (Ptr<Packet> p);
56
  /**
93
  /**
57
   * This method returns the number of bytes in the PendingData buffer
94
   * This method returns the number of bytes in the PendingData buffer
 Lines 89-97    Link Here 
89
   * \return seqOffset-seqFront
126
   * \return seqOffset-seqFront
90
   */
127
   */
91
  virtual uint32_t OffsetFromSeq (const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset);
128
  virtual uint32_t OffsetFromSeq (const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset);
92
  virtual Ptr<Packet> CopyFromOffset (uint32_t, uint32_t);  // Size, offset, ret packet
129
93
  // Copy data, size, offset specified by sequence difference
130
  /**
94
  virtual Ptr<Packet> CopyFromSeq (uint32_t, const SequenceNumber32&, const SequenceNumber32&);
131
   * \brief Copy data starting from a give offset
132
   * \param s size of data to copy
133
   * \param o offset
134
   * \returns a packet containing the requested data
135
   */
136
  virtual Ptr<Packet> CopyFromOffset  (uint32_t s, uint32_t o);  // Size, offset, ret packet
137
  /**
138
   * \brief Copy data starting from a give offset
139
   * \param s size of data to copy
140
   * \param f Front sequence
141
   * \param o Offset sequence
142
   *
143
   * \see PendingData::OffsetFromSeq()
144
   * \returns a packet containing the requested data
145
   */
146
  virtual Ptr<Packet> CopyFromSeq (uint32_t s, const SequenceNumber32& f, const SequenceNumber32& o);
95
  /**
147
  /**
96
   * Permits object to clear any pending data between seqFront and 
148
   * Permits object to clear any pending data between seqFront and 
97
   * seqOffset - 1).  Callers should check the return value to determine
149
   * seqOffset - 1).  Callers should check the return value to determine
 Lines 102-116    Link Here 
102
   * \return number of bytes from the front that were removed from the buffer
154
   * \return number of bytes from the front that were removed from the buffer
103
   */
155
   */
104
  virtual uint32_t RemoveToSeq (const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset);
156
  virtual uint32_t RemoveToSeq (const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset);
105
  PendingData*   Copy () const;          // Create a copy of this header
157
106
  PendingData*   CopyS (uint32_t);         // Copy with new size
158
  /**
107
  PendingData*   CopySD (uint32_t, uint8_t*); // Copy with new size, new data
159
   * \brief Create a copy of self
160
   * \returns copy of pending data
161
   */
162
  PendingData*   Copy () const;
163
  /**
164
   * \brief Create a copy of self with new size
165
   *
166
   * Assumes no associated data
167
   * \param s new size
168
   * \returns copy of pending data
169
   */
170
  PendingData*   CopyS (uint32_t s);         // Copy
171
  /**
172
   * \brief Create a copy of self with new size, new data
173
   *
174
   * Assumes no associated data
175
   * \param s new size
176
   * \param d new data
177
   * \returns copy of pending data
178
   */
179
  PendingData*   CopySD (uint32_t s, uint8_t* d);
108
public:
180
public:
109
  uint32_t size;        // Number of data bytes
181
  uint32_t size;        //!< Number of data bytes
110
  std::vector<Ptr<Packet> > data;         // Corresponding data (may be null)
182
  std::vector<Ptr<Packet> > data;         //!< Corresponding data (may be null)
111
  // The next two fields allow simulated applications to exchange some info
183
  // The next two fields allow simulated applications to exchange some info
112
  uint32_t msgSize;     // Total size of message
184
  uint32_t msgSize;     //!< Total size of message
113
  uint32_t responseSize; // Size of response requested
185
  uint32_t responseSize; //!< Size of response requested
114
};
186
};
115
187
116
} //namepsace ns3
188
} //namepsace ns3
(-)a/src/internet/model/rtt-estimator.h (-17 / +48 lines)
 Lines 39-53    Link Here 
39
 */
39
 */
40
class RttHistory {
40
class RttHistory {
41
public:
41
public:
42
  /**
43
   * \brief Constructor - builds an RttHistory with the given parameters
44
   * \param s First sequence number in packet sent
45
   * \param c Number of bytes sent
46
   * \param t Time this one was sent
47
   */
42
  RttHistory (SequenceNumber32 s, uint32_t c, Time t);
48
  RttHistory (SequenceNumber32 s, uint32_t c, Time t);
49
  /**
50
   * \brief Copy constructor
51
   * \param h the object to copy
52
   */
43
  RttHistory (const RttHistory& h); // Copy constructor
53
  RttHistory (const RttHistory& h); // Copy constructor
44
public:
54
public:
45
  SequenceNumber32  seq;  // First sequence number in packet sent
55
  SequenceNumber32  seq;  //!< First sequence number in packet sent
46
  uint32_t        count;  // Number of bytes sent
56
  uint32_t        count;  //!< Number of bytes sent
47
  Time            time;   // Time this one was sent
57
  Time            time;   //!< Time this one was sent
48
  bool            retx;   // True if this has been retransmitted
58
  bool            retx;   //!< True if this has been retransmitted
49
};
59
};
50
60
61
/// Container for RttHistory objects
51
typedef std::deque<RttHistory> RttHistory_t;
62
typedef std::deque<RttHistory> RttHistory_t;
52
63
53
/**
64
/**
 Lines 57-66    Link Here 
57
 */
68
 */
58
class RttEstimator : public Object {
69
class RttEstimator : public Object {
59
public:
70
public:
71
  /**
72
   * \brief Get the type ID.
73
   * \return the object TypeId
74
   */
60
  static TypeId GetTypeId (void);
75
  static TypeId GetTypeId (void);
61
76
62
  RttEstimator();
77
  RttEstimator();
63
  RttEstimator (const RttEstimator&); 
78
  /**
79
   * \brief Copy constructor
80
   * \param r the object to copy
81
   */
82
  RttEstimator (const RttEstimator& r);
64
83
65
  virtual ~RttEstimator();
84
  virtual ~RttEstimator();
66
85
 Lines 97-102    Link Here 
97
   */
116
   */
98
  virtual Time RetransmitTimeout () = 0;
117
  virtual Time RetransmitTimeout () = 0;
99
118
119
  /**
120
   * \brief Copy object
121
   * \returns a copy of itself
122
   */
100
  virtual Ptr<RttEstimator> Copy () const = 0;
123
  virtual Ptr<RttEstimator> Copy () const = 0;
101
124
102
  /**
125
  /**
 Lines 139-154    Link Here 
139
  Time GetCurrentEstimate (void) const;
162
  Time GetCurrentEstimate (void) const;
140
163
141
private:
164
private:
142
  SequenceNumber32 m_next;    // Next expected sequence to be sent
165
  SequenceNumber32 m_next;    //!< Next expected sequence to be sent
143
  RttHistory_t m_history;     // List of sent packet
166
  RttHistory_t m_history;     //!< List of sent packet
144
  uint16_t m_maxMultiplier;
167
  uint16_t m_maxMultiplier;   //!< Maximum RTO Multiplier
145
  Time m_initialEstimatedRtt;
168
  Time m_initialEstimatedRtt; //!< Initial RTT estimation
146
169
147
protected:
170
protected:
148
  Time         m_currentEstimatedRtt;     // Current estimate
171
  Time         m_currentEstimatedRtt;     //!< Current estimate
149
  Time         m_minRto;                  // minimum value of the timeout
172
  Time         m_minRto;                  //!< minimum value of the timeout
150
  uint32_t     m_nSamples;                // Number of samples
173
  uint32_t     m_nSamples;                //!< Number of samples
151
  uint16_t     m_multiplier;              // RTO Multiplier
174
  uint16_t     m_multiplier;              //!< RTO Multiplier
152
};
175
};
153
176
154
/**
177
/**
 Lines 163-173    Link Here 
163
 */
186
 */
164
class RttMeanDeviation : public RttEstimator {
187
class RttMeanDeviation : public RttEstimator {
165
public:
188
public:
189
  /**
190
   * \brief Get the type ID.
191
   * \return the object TypeId
192
   */
166
  static TypeId GetTypeId (void);
193
  static TypeId GetTypeId (void);
167
194
168
  RttMeanDeviation ();
195
  RttMeanDeviation ();
169
196
170
  RttMeanDeviation (const RttMeanDeviation&);
197
  /**
198
   * \brief Copy constructor
199
   * \param r the object to copy
200
   */
201
  RttMeanDeviation (const RttMeanDeviation& r);
171
202
172
  virtual TypeId GetInstanceTypeId (void) const;
203
  virtual TypeId GetInstanceTypeId (void) const;
173
204
 Lines 186-192    Link Here 
186
  Ptr<RttEstimator> Copy () const;
217
  Ptr<RttEstimator> Copy () const;
187
218
188
  /**
219
  /**
189
   * \brief Resets sthe estimator.
220
   * \brief Resets the estimator.
190
   */
221
   */
191
  void Reset ();
222
  void Reset ();
192
223
 Lines 197-204    Link Here 
197
  void Gain (double g);
228
  void Gain (double g);
198
229
199
private:
230
private:
200
  double       m_gain;       // Filter gain
231
  double       m_gain;       //!< Filter gain
201
  Time         m_variance;   // Current variance
232
  Time         m_variance;   //!< Current variance
202
};
233
};
203
} // namespace ns3
234
} // namespace ns3
204
235
(-)a/src/internet/model/sim_interface.h (-24 / +250 lines)
 Lines 24-72    Link Here 
24
24
25
#define NSC_VERSION 0x000500
25
#define NSC_VERSION 0x000500
26
26
27
/**
28
 * \ingroup nsctcp
29
 * \brief Struct interface to NSC stack
30
 */
27
struct INetStack
31
struct INetStack
28
{
32
{
29
  virtual ~INetStack() {}
33
  virtual ~INetStack() {}
30
34
35
  /**
36
   * \brief Initialize the stack
37
   * \param hz timer_interrupt frequency
38
   */
31
  virtual void init (int hz) = 0;
39
  virtual void init (int hz) = 0;
32
40
41
  /**
42
   * \brief Deliver complete packet to the NSC network stack
43
   * \param if_id interface ID
44
   * \param data data
45
   * \param datalen data length
46
   */
33
  virtual void if_receive_packet (int if_id, const void *data, int datalen) = 0;
47
  virtual void if_receive_packet (int if_id, const void *data, int datalen) = 0;
34
48
  /**
49
   * \brief Send complete packet to the NSC network stack
50
   * \param data data
51
   * \param datalen data length
52
   */
35
  virtual void if_send_packet (const void *data, int datalen) = 0;
53
  virtual void if_send_packet (const void *data, int datalen) = 0;
54
  /**
55
   * \brief Signal the completion of send procedure to the NSC network stack
56
   * \param if_id interface ID
57
   */
36
  virtual void if_send_finish (int if_id) = 0;
58
  virtual void if_send_finish (int if_id) = 0;
37
59
60
  /**
61
   * \brief Attach an interface to the stack
62
   * \param addr address
63
   * \param mask network mask
64
   * \param mtu MTU
65
   */
38
  virtual void if_attach (const char *addr, const char *mask, int mtu) = 0;
66
  virtual void if_attach (const char *addr, const char *mask, int mtu) = 0;
67
  /**
68
   * \brief Add a default gateway to the interface
69
   * \param addr gateway address
70
   */
39
  virtual void add_default_gateway (const char *addr) = 0;
71
  virtual void add_default_gateway (const char *addr) = 0;
40
72
41
  /** Purely for debugging/diagnostic purposes. This returns the internal id
73
  /**
42
   * of the stack instance.
74
   * \brief Returns the internal id of the stack instance.
75
   *
76
   * Purely for debugging/diagnostic purposes.
77
   * \return internal stack id
43
   */
78
   */
44
  virtual int get_id () = 0;
79
  virtual int get_id () = 0;
45
80
46
  /** Should return a short one-word name of the stack. Eg. Linux 2.4.x ->
81
  /**
82
   * \brief Return a short one-word name of the stack
83
   *
84
   * Should return a short one-word name of the stack. Eg. Linux 2.4.x ->
47
   * linux24, FreeBSD 5.x -> freebsd5. This can be used to identify output
85
   * linux24, FreeBSD 5.x -> freebsd5. This can be used to identify output
48
   * from a stack, for example a packet trace file. */
86
   * from a stack, for example a packet trace file.
87
   * \return short one-word name of the stack
88
   */
49
  virtual const char *get_name () = 0;
89
  virtual const char *get_name () = 0;
50
90
51
  /** This is used so the simulator can call the stack timer_interrupt function
91
  /**
92
   * \brief Get the timer_interrupt frequency
93
   *
94
   * This is used so the simulator can call the stack timer_interrupt function
52
   * the correct amount of times per second. For example, lwip has a hz of 10,
95
   * the correct amount of times per second. For example, lwip has a hz of 10,
53
   * which it returns here to say that it's timer_interrupt should be called
96
   * which it returns here to say that it's timer_interrupt should be called
54
   * 10 times a second. FreeBSD uses 100, as does Linux 2.4, while Linux 2.6
97
   * 10 times a second. FreeBSD uses 100, as does Linux 2.4, while Linux 2.6
55
   * uses 1000. (This is often configurable in the kernel in question, also.)
98
   * uses 1000. (This is often configurable in the kernel in question, also.)
99
   *
100
   * \return frequency
56
   */
101
   */
57
  virtual int get_hz () = 0;
102
  virtual int get_hz () = 0;
58
103
104
  /**
105
   * \brief The stack timer_interrupt function
106
   */
59
  virtual void timer_interrupt () = 0;
107
  virtual void timer_interrupt () = 0;
108
109
  /**
110
   * \brief Increment the time ticks
111
   */
60
  virtual void increment_ticks () = 0;
112
  virtual void increment_ticks () = 0;
61
113
114
  /**
115
   * \brief Set the buffer size
116
   */
62
  virtual void buffer_size (int size) = 0;
117
  virtual void buffer_size (int size) = 0;
63
118
119
  /**
120
   * \brief Create a new UDP socket
121
   */
64
  virtual struct INetDatagramSocket *new_udp_socket () { return NULL; }
122
  virtual struct INetDatagramSocket *new_udp_socket () { return NULL; }
123
  /**
124
   * \brief Create a new TCP socket
125
   */
65
  virtual struct INetStreamSocket *new_tcp_socket () { return NULL; }
126
  virtual struct INetStreamSocket *new_tcp_socket () { return NULL; }
127
  /**
128
   * \brief Create a new SCTP socket
129
   */
66
  virtual struct INetStreamSocket *new_sctp_socket () { return NULL; }
130
  virtual struct INetStreamSocket *new_sctp_socket () { return NULL; }
67
131
68
  // The following I've made optional to implement for now. Eases
132
  // The following I've made optional to implement for now. Eases
69
  // integration of new features.
133
  // integration of new features.
134
  /**
135
   * \brief use sysctl to modify system parameters
136
   * \param sysctl_name name of the parameter to modify
137
   * \param oldval old value
138
   * \param oldlenp old value length
139
   * \param newval new value
140
   * \param newlen new value length
141
   * \returns
142
   */
70
  virtual int sysctl (const char *sysctl_name, void *oldval, size_t *oldlenp,
143
  virtual int sysctl (const char *sysctl_name, void *oldval, size_t *oldlenp,
71
                      void *newval, size_t newlen)
144
                      void *newval, size_t newlen)
72
  {
145
  {
 Lines 77-82    Link Here 
77
  // to convert the string-value to something that the stack can handle.
150
  // to convert the string-value to something that the stack can handle.
78
  // The idea here is that this is a front-end to the sysctl(2) call,
151
  // The idea here is that this is a front-end to the sysctl(2) call,
79
  // much like the sysctl(8) program.
152
  // much like the sysctl(8) program.
153
  /**
154
   * \brief Set system parameters using sysctl
155
   * \param name name of the parameter to modify
156
   * \param value new value
157
   * \returns
158
   */
80
  virtual int sysctl_set (const char *name, const char *value)
159
  virtual int sysctl_set (const char *name, const char *value)
81
  {
160
  {
82
    return -1;
161
    return -1;
 Lines 85-129    Link Here 
85
  // same as above, cradle code is expected to convert the sysctl value
164
  // same as above, cradle code is expected to convert the sysctl value
86
  // into a string.
165
  // into a string.
87
  // returns length of the string in value, i.e. retval > len: 'output truncated'.
166
  // returns length of the string in value, i.e. retval > len: 'output truncated'.
167
  /**
168
   * \brief Get system parameters using sysctl
169
   * \param name name of the parameter to modify
170
   * \param value value
171
   * \param len value length
172
   * \returns length of the string in value, i.e. retval > len: 'output truncated'.
173
   */
88
  virtual int sysctl_get (const char *name, char *value, size_t len)
174
  virtual int sysctl_get (const char *name, char *value, size_t len)
89
  {
175
  {
90
    return -1;
176
    return -1;
91
  }
177
  }
92
178
93
  // this tells the cradle code to put the name of sysctl number 'idx'
179
  /**
94
  // into name[].
180
   * \brief Tell the cradle code to put the name of sysctl number 'idx' into name[].
95
  // The idea is that this can be used to get a list of all available sysctls:
181
   *
96
  // char buf[256]
182
   * The idea is that this can be used to get a list of all available sysctls:
97
  // for (i=0; sysctl_getnum(i, buf, sizeof(buf)) > 0 ;i++)
183
   * \verbatim
98
  //    puts(buf);
184
     char buf[256]
99
  // returns -1 if idx is out of range and the length of the sysctl name otherwise.
185
     for (i=0; sysctl_getnum(i, buf, sizeof(buf)) > 0 ;i++)
186
        puts(buf);
187
     \endverbatim
188
   *
189
   * \param idx index
190
   * \param name sysctl name
191
   * \param len sysctl length
192
   * \returns -1 if idx is out of range and the length of the sysctl name otherwise.
193
   */
100
  virtual int sysctl_getnum (size_t idx, char *name, size_t len)
194
  virtual int sysctl_getnum (size_t idx, char *name, size_t len)
101
  {
195
  {
102
    return -1;
196
    return -1;
103
  }
197
  }
104
198
199
  /**
200
   * \brief Show the NSC configuration
201
   */
105
  virtual void show_config ()
202
  virtual void show_config ()
106
  {
203
  {
107
    ;
204
    ;
108
  }
205
  }
109
206
110
  /* Optional functions used to get and set variables for this stack */
207
  /**
208
   * \brief Optional function to get variables for this stack
209
   * \param var the variable
210
   * \param result the result
211
   * \param result_len result length
212
   * \returns true on success
213
   */
111
  virtual bool get_var (const char *var, char *result, int result_len)
214
  virtual bool get_var (const char *var, char *result, int result_len)
112
  {
215
  {
113
    return false;
216
    return false;
114
  }
217
  }
115
218
219
  /**
220
   * \brief Optional function to set variables for this stack
221
   * \param var the variable
222
   * \param val the new value
223
   * \returns true on success
224
   */
116
  virtual bool set_var (const char *var, const char *val)
225
  virtual bool set_var (const char *var, const char *val)
117
  {
226
  {
118
    return false;
227
    return false;
119
  }
228
  }
120
229
121
  /** The level of debugging or diagnostic information to print out. This
230
  /**
122
   * normally means kernel messages printed out during initialisation but
231
   * \brief Set the level of debugging or diagnostic information to print out.
123
   * may also include extra debugging messages that are part of NSC. */
232
   *
233
   * This normally means kernel messages printed out during initialisation but
234
   * may also include extra debugging messages that are part of NSC.
235
   *
236
   * \param level debugging/diagnostic level
237
   */
124
  virtual void set_diagnostic (int level) {}
238
  virtual void set_diagnostic (int level) {}
125
239
126
  /** Simple interface to support sending any textual command to a stack
240
  /**
241
   * \brief Simple interface to support sending any textual command to a stack
127
   *
242
   *
128
   * @returns 0 on success
243
   * @returns 0 on success
129
   */
244
   */
 Lines 133-194    Link Here 
133
  }
248
  }
134
};
249
};
135
250
251
/**
252
 * \ingroup nsctcp
253
 * \brief Struct interface to NSC Stream (i.e., TCP) Sockets
254
 */
136
struct INetStreamSocket
255
struct INetStreamSocket
137
{
256
{
138
  virtual ~INetStreamSocket() {}
257
  virtual ~INetStreamSocket() {}
139
258
259
  /**
260
   * \brief Connect to a remote peer
261
   */
140
  virtual void connect (const char *, int) = 0;
262
  virtual void connect (const char *, int) = 0;
263
  /**
264
   * \brief Disconnect from a remote peer
265
   */
141
  virtual void disconnect () = 0;
266
  virtual void disconnect () = 0;
267
  /**
268
   * \brief Put the socket in Listening state on a port
269
   */
142
  virtual void listen (int) = 0;
270
  virtual void listen (int) = 0;
271
  /**
272
   * \brief Accept an incoming connection
273
   */
143
  virtual int accept (INetStreamSocket **) = 0;
274
  virtual int accept (INetStreamSocket **) = 0;
275
  /**
276
   * \brief Send some data
277
   * \param data the data
278
   * \param datalen data length
279
   * \return the number of data sent or -1 on error
280
   */
144
  virtual int send_data (const void *data, int datalen) = 0;
281
  virtual int send_data (const void *data, int datalen) = 0;
282
  /**
283
   * \brief Read some data
284
   * \param buf the buffer to store the data
285
   * \param buflen buffer length
286
   * \return the number of data read or -1 on error
287
   */
145
  virtual int read_data (void *buf, int *buflen) = 0;
288
  virtual int read_data (void *buf, int *buflen) = 0;
146
  /* We need to pass the option name in as a string here. The reason for
289
  /**
290
   * \brief Set the socket options
291
   *
292
   * We need to pass the option name in as a string here. The reason for
147
   * this is that different operating systems you compile on will have
293
   * this is that different operating systems you compile on will have
148
   * different numbers defined for the constants SO_SNDBUF and so on. */
294
   * different numbers defined for the constants SO_SNDBUF and so on.
295
   *
296
   * \param optname name of the option
297
   * \param val option value
298
   * \param valsize size of the option value
299
   * \returns
300
   */
149
  virtual int setsockopt (char *optname, void *val, size_t valsize) = 0;
301
  virtual int setsockopt (char *optname, void *val, size_t valsize) = 0;
302
  /**
303
   * \brief Print the socket state
304
   */
150
  virtual void print_state (FILE *) = 0;
305
  virtual void print_state (FILE *) = 0;
306
  /**
307
   * \brief Check the connection state
308
   * \returns true if socket is in connected state
309
   */
151
  virtual bool is_connected () = 0;
310
  virtual bool is_connected () = 0;
311
  /**
312
   * \brief Check the listening state
313
   * \returns true if socket is in listening state
314
   */
152
  virtual bool is_listening () = 0;
315
  virtual bool is_listening () = 0;
153
316
  /**
317
   * \brief Get the peer name
318
   *
319
   * \note not implemented
320
   *
321
   * \param sa sockaddr structure to fill
322
   * \param salen sockaddr structure length
323
   * \returns -1 on error (always returns -1)
324
   */
154
  virtual int getpeername (struct sockaddr *sa, size_t *salen) {
325
  virtual int getpeername (struct sockaddr *sa, size_t *salen) {
155
    return -1;
326
    return -1;
156
  }
327
  }
328
  /**
329
   * \brief Get the socket local name
330
   *
331
   * \note not implemented
332
   *
333
   * \param sa sockaddr structure to fill
334
   * \param salen sockaddr structure length
335
   * \returns -1 on error (always returns -1)
336
   */
157
  virtual int getsockname (struct sockaddr *sa, size_t *salen) {
337
  virtual int getsockname (struct sockaddr *sa, size_t *salen) {
158
    return -1;
338
    return -1;
159
  }
339
  }
160
  /* Optional functions used to get and set variables for this TCP
340
  /**
161
   * connection. */
341
   * \brief Optional function used to get variables for this TCP connection.
342
   *
343
   * \note not implemented
344
   *
345
   * \param var variable requested
346
   * \param result result result
347
   * \param result_len result length
348
   * \return always false
349
   */
162
  virtual bool get_var (const char *var, char *result, int result_len)
350
  virtual bool get_var (const char *var, char *result, int result_len)
163
  {
351
  {
164
    return false;
352
    return false;
165
  }
353
  }
166
354
  /**
355
   * \brief Optional function used to set variables for this TCP connection.
356
   *
357
   * \note not implemented
358
   *
359
   * \param var variable to set
360
   * \param val value to set
361
   * \return always false
362
   */
167
  virtual bool set_var (const char *var, const char *val)
363
  virtual bool set_var (const char *var, const char *val)
168
  {
364
  {
169
    return false;
365
    return false;
170
  }
366
  }
171
};
367
};
172
368
369
/**
370
 * \ingroup nsctcp
371
 * \brief Struct interface to NSC Datagram (i.e., UDP) Sockets
372
 */
173
struct INetDatagramSocket
373
struct INetDatagramSocket
174
{
374
{
175
  virtual ~INetDatagramSocket() {}
375
  virtual ~INetDatagramSocket() {}
176
376
377
  /**
378
   * \brief Set the destination address and port
379
   */
177
  virtual void set_destination (const char *, int) = 0;
380
  virtual void set_destination (const char *, int) = 0;
381
  /**
382
   * \brief Send a datagram
383
   * \param data the data
384
   * \param datalen data length
385
   */
178
  virtual void send_data (const void *data, int datalen) = 0;
386
  virtual void send_data (const void *data, int datalen) = 0;
179
};
387
};
388
389
/**
390
 * \ingroup nsctcp
391
 * \brief Struct interface to NSC send capabilities
392
 */
180
struct ISendCallback
393
struct ISendCallback
181
{
394
{
182
  virtual ~ISendCallback() {}
395
  virtual ~ISendCallback() {}
183
396
397
  /**
398
   * \brief Invoked by NSCs 'ethernet driver' to re-inject a packet into ns-3.
399
   */
184
  virtual void send_callback (const void *data, int datalen) = 0;
400
  virtual void send_callback (const void *data, int datalen) = 0;
185
};
401
};
186
402
403
/**
404
 * \ingroup nsctcp
405
 * \brief Struct interface to NSC soft interrupt capabilities
406
 */
187
struct IInterruptCallback
407
struct IInterruptCallback
188
{
408
{
189
  virtual ~IInterruptCallback() {}
409
  virtual ~IInterruptCallback() {}
190
410
411
  /**
412
   * \brief Called by the NSC stack whenever something of interest has happened
413
   */
191
  virtual void wakeup () = 0;
414
  virtual void wakeup () = 0;
415
  /**
416
   * \brief Get the actual time
417
   */
192
  virtual void gettime (unsigned int *, unsigned int *) = 0;
418
  virtual void gettime (unsigned int *, unsigned int *) = 0;
193
};
419
};
194
420
(-)a/src/internet/model/tcp-header.h (-13 / +25 lines)
 Lines 175-183    Link Here 
175
                           Address destination,
175
                           Address destination,
176
                           uint8_t protocol);
176
                           uint8_t protocol);
177
177
178
  /**
179
   * \brief TCP flag field values
180
   */
178
  typedef enum { NONE = 0, FIN = 1, SYN = 2, RST = 4, PSH = 8, ACK = 16, 
181
  typedef enum { NONE = 0, FIN = 1, SYN = 2, RST = 4, PSH = 8, ACK = 16, 
179
                 URG = 32, ECE = 64, CWR = 128} Flags_t;
182
                 URG = 32, ECE = 64, CWR = 128} Flags_t;
180
183
184
  /**
185
   * \brief Get the type ID.
186
   * \return the object TypeId
187
   */
181
  static TypeId GetTypeId (void);
188
  static TypeId GetTypeId (void);
182
  virtual TypeId GetInstanceTypeId (void) const;
189
  virtual TypeId GetInstanceTypeId (void) const;
183
  virtual void Print (std::ostream &os) const;
190
  virtual void Print (std::ostream &os) const;
 Lines 192-213    Link Here 
192
  bool IsChecksumOk (void) const;
199
  bool IsChecksumOk (void) const;
193
200
194
private:
201
private:
202
  /**
203
   * \brief Calculate the header checksum
204
   * \param size packet size
205
   * \returns the checksum
206
   */
195
  uint16_t CalculateHeaderChecksum (uint16_t size) const;
207
  uint16_t CalculateHeaderChecksum (uint16_t size) const;
196
  uint16_t m_sourcePort;
208
  uint16_t m_sourcePort;        //!< Source port
197
  uint16_t m_destinationPort;
209
  uint16_t m_destinationPort;   //!< Destination port
198
  SequenceNumber32 m_sequenceNumber;
210
  SequenceNumber32 m_sequenceNumber;  //!< Sequence number
199
  SequenceNumber32 m_ackNumber;
211
  SequenceNumber32 m_ackNumber;       //!< ACK number
200
  uint8_t m_length; // really a uint4_t
212
  uint8_t m_length;             //!< Length (really a uint4_t)
201
  uint8_t m_flags;      // really a uint6_t
213
  uint8_t m_flags;              //!< Flags (really a uint6_t)
202
  uint16_t m_windowSize;
214
  uint16_t m_windowSize;        //!< Window size
203
  uint16_t m_urgentPointer;
215
  uint16_t m_urgentPointer;     //!< Urgent pointer
204
216
205
  Address m_source;
217
  Address m_source;       //!< Source IP address
206
  Address m_destination;
218
  Address m_destination;  //!< Destination IP address
207
  uint8_t m_protocol;
219
  uint8_t m_protocol;     //!< Protocol number
208
220
209
  bool m_calcChecksum;
221
  bool m_calcChecksum;    //!< Flag to calculate checksum
210
  bool m_goodChecksum;
222
  bool m_goodChecksum;    //!< Flag to indicate that checksum is correct
211
};
223
};
212
224
213
} // namespace ns3
225
} // namespace ns3
(-)a/src/internet/model/tcp-l4-protocol.h (-36 / +122 lines)
 Lines 55-97    Link Here 
55
55
56
class TcpL4Protocol : public IpL4Protocol {
56
class TcpL4Protocol : public IpL4Protocol {
57
public:
57
public:
58
  /**
59
   * \brief Get the type ID.
60
   * \return the object TypeId
61
   */
58
  static TypeId GetTypeId (void);
62
  static TypeId GetTypeId (void);
59
  static const uint8_t PROT_NUMBER;
63
  static const uint8_t PROT_NUMBER; //!< protocol number (0x6)
60
  /**
64
61
   * \brief Constructor
62
   */
63
  TcpL4Protocol ();
65
  TcpL4Protocol ();
64
  virtual ~TcpL4Protocol ();
66
  virtual ~TcpL4Protocol ();
65
67
68
  /**
69
   * Set node associated with this stack
70
   * \param node the node
71
   */
66
  void SetNode (Ptr<Node> node);
72
  void SetNode (Ptr<Node> node);
67
73
68
  virtual int GetProtocolNumber (void) const;
74
  virtual int GetProtocolNumber (void) const;
69
75
70
  /**
76
  /**
77
   * \brief Create a TCP socket
71
   * \return A smart Socket pointer to a TcpSocket allocated by this instance
78
   * \return A smart Socket pointer to a TcpSocket allocated by this instance
72
   * of the TCP protocol
79
   * of the TCP protocol
73
   */
80
   */
74
  Ptr<Socket> CreateSocket (void);
81
  Ptr<Socket> CreateSocket (void);
82
  /**
83
   * \brief Create a TCP socket
84
   * \return A smart Socket pointer to a TcpSocket allocated by this instance
85
   * of the TCP protocol
86
   *
87
   * \warning using a socketTypeId other than TCP is a bad idea.
88
   *
89
   * \param socketTypeId the socket TypeId
90
   */
75
  Ptr<Socket> CreateSocket (TypeId socketTypeId);
91
  Ptr<Socket> CreateSocket (TypeId socketTypeId);
76
92
93
  /**
94
   * \brief Allocate an IPv4 Endpoint
95
   * \return the Endpoint
96
   */
77
  Ipv4EndPoint *Allocate (void);
97
  Ipv4EndPoint *Allocate (void);
98
  /**
99
   * \brief Allocate an IPv4 Endpoint
100
   * \param address address to use
101
   * \return the Endpoint
102
   */
78
  Ipv4EndPoint *Allocate (Ipv4Address address);
103
  Ipv4EndPoint *Allocate (Ipv4Address address);
104
  /**
105
   * \brief Allocate an IPv4 Endpoint
106
   * \param port port to use
107
   * \return the Endpoint
108
   */
79
  Ipv4EndPoint *Allocate (uint16_t port);
109
  Ipv4EndPoint *Allocate (uint16_t port);
110
  /**
111
   * \brief Allocate an IPv4 Endpoint
112
   * \param address address to use
113
   * \param port port to use
114
   * \return the Endpoint
115
   */
80
  Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
116
  Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
117
  /**
118
   * \brief Allocate an IPv4 Endpoint
119
   * \param localAddress local address to use
120
   * \param localPort local port to use
121
   * \param peerAddress remote address to use
122
   * \param peerPort remote port to use
123
   * \return the Endpoint
124
   */
81
  Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
125
  Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
82
                          Ipv4Address peerAddress, uint16_t peerPort);
126
                          Ipv4Address peerAddress, uint16_t peerPort);
127
  /**
128
   * \brief Allocate an IPv6 Endpoint
129
   * \return the Endpoint
130
   */
83
  Ipv6EndPoint *Allocate6 (void);
131
  Ipv6EndPoint *Allocate6 (void);
132
  /**
133
   * \brief Allocate an IPv6 Endpoint
134
   * \param address address to use
135
   * \return the Endpoint
136
   */
84
  Ipv6EndPoint *Allocate6 (Ipv6Address address);
137
  Ipv6EndPoint *Allocate6 (Ipv6Address address);
138
  /**
139
   * \brief Allocate an IPv6 Endpoint
140
   * \param port port to use
141
   * \return the Endpoint
142
   */
85
  Ipv6EndPoint *Allocate6 (uint16_t port);
143
  Ipv6EndPoint *Allocate6 (uint16_t port);
144
  /**
145
   * \brief Allocate an IPv6 Endpoint
146
   * \param address address to use
147
   * \param port port to use
148
   * \return the Endpoint
149
   */
86
  Ipv6EndPoint *Allocate6 (Ipv6Address address, uint16_t port);
150
  Ipv6EndPoint *Allocate6 (Ipv6Address address, uint16_t port);
151
  /**
152
   * \brief Allocate an IPv6 Endpoint
153
   * \param localAddress local address to use
154
   * \param localPort local port to use
155
   * \param peerAddress remote address to use
156
   * \param peerPort remote port to use
157
   * \return the Endpoint
158
   */
87
  Ipv6EndPoint *Allocate6 (Ipv6Address localAddress, uint16_t localPort,
159
  Ipv6EndPoint *Allocate6 (Ipv6Address localAddress, uint16_t localPort,
88
                           Ipv6Address peerAddress, uint16_t peerPort);
160
                           Ipv6Address peerAddress, uint16_t peerPort);
89
161
162
  /**
163
   * \brief Remove an IPv4 Endpoint.
164
   * \param endPoint the end point to remove
165
   */
90
  void DeAllocate (Ipv4EndPoint *endPoint);
166
  void DeAllocate (Ipv4EndPoint *endPoint);
167
  /**
168
   * \brief Remove an IPv6 Endpoint.
169
   * \param endPoint the end point to remove
170
   */
91
  void DeAllocate (Ipv6EndPoint *endPoint);
171
  void DeAllocate (Ipv6EndPoint *endPoint);
92
172
93
  /**
173
  /**
94
   * \brief Send a packet via TCP
174
   * \brief Send a packet via TCP (IPv4)
95
   * \param packet The packet to send
175
   * \param packet The packet to send
96
   * \param saddr The source Ipv4Address
176
   * \param saddr The source Ipv4Address
97
   * \param daddr The destination Ipv4Address
177
   * \param daddr The destination Ipv4Address
 Lines 102-134    Link Here 
102
  void Send (Ptr<Packet> packet,
182
  void Send (Ptr<Packet> packet,
103
             Ipv4Address saddr, Ipv4Address daddr, 
183
             Ipv4Address saddr, Ipv4Address daddr, 
104
             uint16_t sport, uint16_t dport, Ptr<NetDevice> oif = 0);
184
             uint16_t sport, uint16_t dport, Ptr<NetDevice> oif = 0);
185
  /**
186
   * \brief Send a packet via TCP (IPv6)
187
   * \param packet The packet to send
188
   * \param saddr The source Ipv4Address
189
   * \param daddr The destination Ipv4Address
190
   * \param sport The source port number
191
   * \param dport The destination port number
192
   * \param oif The output interface bound. Defaults to null (unspecified).
193
   */
105
  void Send (Ptr<Packet> packet,
194
  void Send (Ptr<Packet> packet,
106
             Ipv6Address saddr, Ipv6Address daddr, 
195
             Ipv6Address saddr, Ipv6Address daddr, 
107
             uint16_t sport, uint16_t dport, Ptr<NetDevice> oif = 0);
196
             uint16_t sport, uint16_t dport, Ptr<NetDevice> oif = 0);
108
  /**
197
109
   * \brief Receive a packet up the protocol stack
198
110
   * \param p The Packet to dump the contents into
111
   * \param header IPv4 Header information
112
   * \param incomingInterface The Ipv4Interface it was received on
113
   */
114
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
199
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
115
                                                 Ipv4Header const &header,
200
                                               Ipv4Header const &header,
116
                                                 Ptr<Ipv4Interface> incomingInterface);
201
                                               Ptr<Ipv4Interface> incomingInterface);
117
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
202
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
118
                                                 Ipv6Header const &header,
203
                                               Ipv6Header const &header,
119
                                                 Ptr<Ipv6Interface> interface);
204
                                               Ptr<Ipv6Interface> incomingInterface);
120
205
121
  /**
122
   * \brief Receive an ICMP packet
123
   * \param icmpSource The IP address of the source of the packet.
124
   * \param icmpTtl The time to live from the IP header
125
   * \param icmpType The type of the message from the ICMP header
126
   * \param icmpCode The message code from the ICMP header
127
   * \param icmpInfo 32-bit integer carrying informational value of varying semantics.
128
   * \param payloadSource The IP source address from the IP header of the packet
129
   * \param payloadDestination The IP destination address from the IP header of the packet
130
   * \param payload Payload of the ICMP packet
131
   */
132
  virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
206
  virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
133
                            uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
207
                            uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
134
                            Ipv4Address payloadSource,Ipv4Address payloadDestination,
208
                            Ipv4Address payloadSource,Ipv4Address payloadDestination,
 Lines 153-175    Link Here 
153
   */
227
   */
154
  virtual void NotifyNewAggregate ();
228
  virtual void NotifyNewAggregate ();
155
private:
229
private:
156
  Ptr<Node> m_node;
230
  Ptr<Node> m_node; //!< the node this stack is associated with
157
  Ipv4EndPointDemux *m_endPoints;
231
  Ipv4EndPointDemux *m_endPoints; //!< A list of IPv4 end points.
158
  Ipv6EndPointDemux *m_endPoints6;
232
  Ipv6EndPointDemux *m_endPoints6; //!< A list of IPv6 end points.
159
  TypeId m_rttTypeId;
233
  TypeId m_rttTypeId; //!< The RTT Estimator TypeId
160
  TypeId m_socketTypeId;
234
  TypeId m_socketTypeId; //!< The socket TypeId
161
private:
235
private:
162
  friend class TcpSocketBase;
236
  friend class TcpSocketBase;
163
  void SendPacket (Ptr<Packet>, const TcpHeader &,
237
  void SendPacket (Ptr<Packet>, const TcpHeader &,
164
                   Ipv4Address, Ipv4Address, Ptr<NetDevice> oif = 0);
238
                   Ipv4Address, Ipv4Address, Ptr<NetDevice> oif = 0);
165
  void SendPacket (Ptr<Packet>, const TcpHeader &,
239
  void SendPacket (Ptr<Packet>, const TcpHeader &,
166
                   Ipv6Address, Ipv6Address, Ptr<NetDevice> oif = 0);
240
                   Ipv6Address, Ipv6Address, Ptr<NetDevice> oif = 0);
167
  TcpL4Protocol (const TcpL4Protocol &o);
168
  TcpL4Protocol &operator = (const TcpL4Protocol &o);
169
241
170
  std::vector<Ptr<TcpSocketBase> > m_sockets;
242
  /**
171
  IpL4Protocol::DownTargetCallback m_downTarget;
243
   * \brief Copy constructor
172
  IpL4Protocol::DownTargetCallback6 m_downTarget6;
244
   *
245
   * Defined and not implemented to avoid misuse
246
   */
247
  TcpL4Protocol (const TcpL4Protocol &);
248
  /**
249
   * \brief Copy constructor
250
   *
251
   * Defined and not implemented to avoid misuse
252
   * \returns
253
   */
254
  TcpL4Protocol &operator = (const TcpL4Protocol &);
255
256
  std::vector<Ptr<TcpSocketBase> > m_sockets;      //!< list of sockets
257
  IpL4Protocol::DownTargetCallback m_downTarget;   //!< Callback to send packets over IPv4
258
  IpL4Protocol::DownTargetCallback6 m_downTarget6; //!< Callback to send packets over IPv6
173
};
259
};
174
260
175
} // namespace ns3
261
} // namespace ns3
(-)a/src/internet/model/tcp-newreno.cc (-6 / +6 lines)
 Lines 81-87    Link Here 
81
{
81
{
82
}
82
}
83
83
84
/** We initialize m_cWnd from this function, after attributes initialized */
84
/* We initialize m_cWnd from this function, after attributes initialized */
85
int
85
int
86
TcpNewReno::Listen (void)
86
TcpNewReno::Listen (void)
87
{
87
{
 Lines 90-96    Link Here 
90
  return TcpSocketBase::Listen ();
90
  return TcpSocketBase::Listen ();
91
}
91
}
92
92
93
/** We initialize m_cWnd from this function, after attributes initialized */
93
/* We initialize m_cWnd from this function, after attributes initialized */
94
int
94
int
95
TcpNewReno::Connect (const Address & address)
95
TcpNewReno::Connect (const Address & address)
96
{
96
{
 Lines 99-105    Link Here 
99
  return TcpSocketBase::Connect (address);
99
  return TcpSocketBase::Connect (address);
100
}
100
}
101
101
102
/** Limit the size of in-flight data by cwnd and receiver's rxwin */
102
/* Limit the size of in-flight data by cwnd and receiver's rxwin */
103
uint32_t
103
uint32_t
104
TcpNewReno::Window (void)
104
TcpNewReno::Window (void)
105
{
105
{
 Lines 113-119    Link Here 
113
  return CopyObject<TcpNewReno> (this);
113
  return CopyObject<TcpNewReno> (this);
114
}
114
}
115
115
116
/** New ACK (up to seqnum seq) received. Increase cwnd and call TcpSocketBase::NewAck() */
116
/* New ACK (up to seqnum seq) received. Increase cwnd and call TcpSocketBase::NewAck() */
117
void
117
void
118
TcpNewReno::NewAck (const SequenceNumber32& seq)
118
TcpNewReno::NewAck (const SequenceNumber32& seq)
119
{
119
{
 Lines 158-164    Link Here 
158
  TcpSocketBase::NewAck (seq);
158
  TcpSocketBase::NewAck (seq);
159
}
159
}
160
160
161
/** Cut cwnd and enter fast recovery mode upon triple dupack */
161
/* Cut cwnd and enter fast recovery mode upon triple dupack */
162
void
162
void
163
TcpNewReno::DupAck (const TcpHeader& t, uint32_t count)
163
TcpNewReno::DupAck (const TcpHeader& t, uint32_t count)
164
{
164
{
 Lines 187-193    Link Here 
187
    };
187
    };
188
}
188
}
189
189
190
/** Retransmit timeout */
190
/* Retransmit timeout */
191
void
191
void
192
TcpNewReno::Retransmit (void)
192
TcpNewReno::Retransmit (void)
193
{
193
{
(-)a/src/internet/model/tcp-newreno.h (-8 / +19 lines)
 Lines 36-46    Link Here 
36
class TcpNewReno : public TcpSocketBase
36
class TcpNewReno : public TcpSocketBase
37
{
37
{
38
public:
38
public:
39
  /**
40
   * \brief Get the type ID.
41
   * \return the object TypeId
42
   */
39
  static TypeId GetTypeId (void);
43
  static TypeId GetTypeId (void);
40
  /**
44
  /**
41
   * Create an unbound tcp socket.
45
   * Create an unbound tcp socket.
42
   */
46
   */
43
  TcpNewReno (void);
47
  TcpNewReno (void);
48
  /**
49
   * \brief Copy constructor
50
   * \param sock the object to copy
51
   */
44
  TcpNewReno (const TcpNewReno& sock);
52
  TcpNewReno (const TcpNewReno& sock);
45
  virtual ~TcpNewReno (void);
53
  virtual ~TcpNewReno (void);
46
54
 Lines 62-77    Link Here 
62
  virtual void     SetInitialCwnd (uint32_t cwnd);
70
  virtual void     SetInitialCwnd (uint32_t cwnd);
63
  virtual uint32_t GetInitialCwnd (void) const;
71
  virtual uint32_t GetInitialCwnd (void) const;
64
private:
72
private:
65
  void InitializeCwnd (void);            // set m_cWnd when connection starts
73
  /**
74
   * \brief Set the congestion window when connection starts
75
   */
76
  void InitializeCwnd (void);
66
77
67
protected:
78
protected:
68
  TracedValue<uint32_t>  m_cWnd;         //< Congestion window
79
  TracedValue<uint32_t>  m_cWnd;         //!< Congestion window
69
  uint32_t               m_ssThresh;     //< Slow Start Threshold
80
  uint32_t               m_ssThresh;     //!< Slow Start Threshold
70
  uint32_t               m_initialCWnd;  //< Initial cWnd value
81
  uint32_t               m_initialCWnd;  //!< Initial cWnd value
71
  SequenceNumber32       m_recover;      //< Previous highest Tx seqnum for fast recovery
82
  SequenceNumber32       m_recover;      //!< Previous highest Tx seqnum for fast recovery
72
  uint32_t               m_retxThresh;   //< Fast Retransmit threshold
83
  uint32_t               m_retxThresh;   //!< Fast Retransmit threshold
73
  bool                   m_inFastRec;    //< currently in fast recovery
84
  bool                   m_inFastRec;    //!< currently in fast recovery
74
  bool                   m_limitedTx;    //< perform limited transmit
85
  bool                   m_limitedTx;    //!< perform limited transmit
75
};
86
};
76
87
77
} // namespace ns3
88
} // namespace ns3
(-)a/src/internet/model/tcp-reno.cc (-4 / +4 lines)
 Lines 73-79    Link Here 
73
{
73
{
74
}
74
}
75
75
76
/** We initialize m_cWnd from this function, after attributes initialized */
76
/* We initialize m_cWnd from this function, after attributes initialized */
77
int
77
int
78
TcpReno::Listen (void)
78
TcpReno::Listen (void)
79
{
79
{
 Lines 82-88    Link Here 
82
  return TcpSocketBase::Listen ();
82
  return TcpSocketBase::Listen ();
83
}
83
}
84
84
85
/** We initialize m_cWnd from this function, after attributes initialized */
85
/* We initialize m_cWnd from this function, after attributes initialized */
86
int
86
int
87
TcpReno::Connect (const Address & address)
87
TcpReno::Connect (const Address & address)
88
{
88
{
 Lines 91-97    Link Here 
91
  return TcpSocketBase::Connect (address);
91
  return TcpSocketBase::Connect (address);
92
}
92
}
93
93
94
/** Limit the size of in-flight data by cwnd and receiver's rxwin */
94
/* Limit the size of in-flight data by cwnd and receiver's rxwin */
95
uint32_t
95
uint32_t
96
TcpReno::Window (void)
96
TcpReno::Window (void)
97
{
97
{
 Lines 105-111    Link Here 
105
  return CopyObject<TcpReno> (this);
105
  return CopyObject<TcpReno> (this);
106
}
106
}
107
107
108
/** New ACK (up to seqnum seq) received. Increase cwnd and call TcpSocketBase::NewAck() */
108
/* New ACK (up to seqnum seq) received. Increase cwnd and call TcpSocketBase::NewAck() */
109
void
109
void
110
TcpReno::NewAck (const SequenceNumber32& seq)
110
TcpReno::NewAck (const SequenceNumber32& seq)
111
{
111
{
(-)a/src/internet/model/tcp-reno.h (-6 / +17 lines)
 Lines 38-48    Link Here 
38
class TcpReno : public TcpSocketBase
38
class TcpReno : public TcpSocketBase
39
{
39
{
40
public:
40
public:
41
  /**
42
   * \brief Get the type ID.
43
   * \return the object TypeId
44
   */
41
  static TypeId GetTypeId (void);
45
  static TypeId GetTypeId (void);
42
  /**
46
  /**
43
   * Create an unbound tcp socket.
47
   * Create an unbound tcp socket.
44
   */
48
   */
45
  TcpReno (void);
49
  TcpReno (void);
50
  /**
51
   * \brief Copy constructor
52
   * \param sock the object to copy
53
   */
46
  TcpReno (const TcpReno& sock);
54
  TcpReno (const TcpReno& sock);
47
  virtual ~TcpReno (void);
55
  virtual ~TcpReno (void);
48
56
 Lines 64-77    Link Here 
64
  virtual void     SetInitialCwnd (uint32_t cwnd);
72
  virtual void     SetInitialCwnd (uint32_t cwnd);
65
  virtual uint32_t GetInitialCwnd (void) const;
73
  virtual uint32_t GetInitialCwnd (void) const;
66
private:
74
private:
67
  void InitializeCwnd (void);            // set m_cWnd when connection starts
75
  /**
76
   * \brief Set the congestion window when connection starts
77
   */
78
  void InitializeCwnd (void);
68
79
69
protected:
80
protected:
70
  TracedValue<uint32_t>  m_cWnd;         //< Congestion window
81
  TracedValue<uint32_t>  m_cWnd;         //!< Congestion window
71
  uint32_t               m_ssThresh;     //< Slow Start Threshold
82
  uint32_t               m_ssThresh;     //!< Slow Start Threshold
72
  uint32_t               m_initialCWnd;  //< Initial cWnd value
83
  uint32_t               m_initialCWnd;  //!< Initial cWnd value
73
  uint32_t               m_retxThresh;   //< Fast Retransmit threshold
84
  uint32_t               m_retxThresh;   //!< Fast Retransmit threshold
74
  bool                   m_inFastRec;    //< currently in fast recovery
85
  bool                   m_inFastRec;    //!< currently in fast recovery
75
};
86
};
76
87
77
} // namespace ns3
88
} // namespace ns3
(-)a/src/internet/model/tcp-rfc793.h (+8 lines)
 Lines 39-49    Link Here 
39
class TcpRfc793 : public TcpSocketBase
39
class TcpRfc793 : public TcpSocketBase
40
{
40
{
41
public:
41
public:
42
  /**
43
   * \brief Get the type ID.
44
   * \return the object TypeId
45
   */
42
  static TypeId GetTypeId (void);
46
  static TypeId GetTypeId (void);
43
  /**
47
  /**
44
   * Create an unbound tcp socket.
48
   * Create an unbound tcp socket.
45
   */
49
   */
46
  TcpRfc793 (void);
50
  TcpRfc793 (void);
51
  /**
52
   * \brief Copy constructor
53
   * \param sock the object to copy
54
   */
47
  TcpRfc793 (const TcpRfc793& sock);
55
  TcpRfc793 (const TcpRfc793& sock);
48
  virtual ~TcpRfc793 (void);
56
  virtual ~TcpRfc793 (void);
49
57
(-)a/src/internet/model/tcp-rx-buffer.h (-8 / +60 lines)
 Lines 40-59    Link Here 
40
class TcpRxBuffer : public Object
40
class TcpRxBuffer : public Object
41
{
41
{
42
public:
42
public:
43
  /**
44
   * \brief Get the type ID.
45
   * \return the object TypeId
46
   */
43
  static TypeId GetTypeId (void);
47
  static TypeId GetTypeId (void);
48
  /**
49
   * \brief Constructor
50
   * \param n initial Sequence number to be received
51
   */
44
  TcpRxBuffer (uint32_t n = 0);
52
  TcpRxBuffer (uint32_t n = 0);
45
  virtual ~TcpRxBuffer ();
53
  virtual ~TcpRxBuffer ();
46
54
47
  // Accessors
55
  // Accessors
56
  /**
57
   * \brief Get Next Rx Sequence number
58
   * \returns Next Rx Sequence number
59
   */
48
  SequenceNumber32 NextRxSequence (void) const;
60
  SequenceNumber32 NextRxSequence (void) const;
61
  /**
62
   * \brief Get the lowest sequence number that this TcpRxBuffer cannot accept
63
   * \returns the lowest sequence number that this TcpRxBuffer cannot accept
64
   */
49
  SequenceNumber32 MaxRxSequence (void) const;
65
  SequenceNumber32 MaxRxSequence (void) const;
66
  /**
67
   * \brief Increment the Next Sequence number
68
   */
50
  void IncNextRxSequence (void);
69
  void IncNextRxSequence (void);
70
  /**
71
   * \brief Set the Next Sequence number
72
   * \param s the Sequence number
73
   */
51
  void SetNextRxSequence (const SequenceNumber32& s);
74
  void SetNextRxSequence (const SequenceNumber32& s);
75
  /**
76
   * \brief Set the FIN Sequence number (i.e., the one closing the connection)
77
   * \param s the Sequence number
78
   */
52
  void SetFinSequence (const SequenceNumber32& s);
79
  void SetFinSequence (const SequenceNumber32& s);
80
  /**
81
   * \brief Get the Maximum buffer size
82
   * \returns the Maximum buffer size
83
   */
53
  uint32_t MaxBufferSize (void) const;
84
  uint32_t MaxBufferSize (void) const;
85
  /**
86
   * \brief Set the Maximum buffer size
87
   * \param s the Maximum buffer size
88
   */
54
  void SetMaxBufferSize (uint32_t s);
89
  void SetMaxBufferSize (uint32_t s);
90
  /**
91
   * \brief Get the actual buffer occupancy
92
   * \returns buffer occupancy (in bytes)
93
   */
55
  uint32_t Size (void) const;
94
  uint32_t Size (void) const;
95
  /**
96
   * \brief Get the actual number of bytes available to be read
97
   * \returns size of available data (in bytes)
98
   */
56
  uint32_t Available () const;
99
  uint32_t Available () const;
100
  /**
101
   * \brief Check if the buffer did receive all the data (and the connection is closed)
102
   * \returns true if all data have been received
103
   */
57
  bool Finished (void);
104
  bool Finished (void);
58
105
59
  /**
106
  /**
 Lines 63-68    Link Here 
63
   * removing data from the buffer that overlaps the tail of the inputted
110
   * removing data from the buffer that overlaps the tail of the inputted
64
   * packet
111
   * packet
65
   *
112
   *
113
   * \param p packet
114
   * \param tcph packet's TCP header
66
   * \return True when success, false otherwise.
115
   * \return True when success, false otherwise.
67
   */
116
   */
68
  bool Add (Ptr<Packet> p, TcpHeader const& tcph);
117
  bool Add (Ptr<Packet> p, TcpHeader const& tcph);
 Lines 70-87    Link Here 
70
  /**
119
  /**
71
   * Extract data from the head of the buffer as indicated by nextRxSeq.
120
   * Extract data from the head of the buffer as indicated by nextRxSeq.
72
   * The extracted data is going to be forwarded to the application.
121
   * The extracted data is going to be forwarded to the application.
122
   *
123
   * \param maxSize maximum number of bytes to extract
124
   * \returns a packet
73
   */
125
   */
74
  Ptr<Packet> Extract (uint32_t maxSize);
126
  Ptr<Packet> Extract (uint32_t maxSize);
75
public:
127
public:
128
  /// container for data stored in the buffer
76
  typedef std::map<SequenceNumber32, Ptr<Packet> >::iterator BufIterator;
129
  typedef std::map<SequenceNumber32, Ptr<Packet> >::iterator BufIterator;
77
  TracedValue<SequenceNumber32> m_nextRxSeq; //< Seqnum of the first missing byte in data (RCV.NXT)
130
  TracedValue<SequenceNumber32> m_nextRxSeq; //!< Seqnum of the first missing byte in data (RCV.NXT)
78
  SequenceNumber32 m_finSeq;                 //< Seqnum of the FIN packet
131
  SequenceNumber32 m_finSeq;                 //!< Seqnum of the FIN packet
79
  bool m_gotFin;                             //< Did I received FIN packet?
132
  bool m_gotFin;                             //!< Did I received FIN packet?
80
  uint32_t m_size;                           //< Number of total data bytes in the buffer, not necessarily contiguous
133
  uint32_t m_size;                           //!< Number of total data bytes in the buffer, not necessarily contiguous
81
  uint32_t m_maxBuffer;                      //< Upper bound of the number of data bytes in buffer (RCV.WND)
134
  uint32_t m_maxBuffer;                      //!< Upper bound of the number of data bytes in buffer (RCV.WND)
82
  uint32_t m_availBytes;                     //< Number of bytes available to read, i.e. contiguous block at head
135
  uint32_t m_availBytes;                     //!< Number of bytes available to read, i.e. contiguous block at head
83
  std::map<SequenceNumber32, Ptr<Packet> > m_data;
136
  std::map<SequenceNumber32, Ptr<Packet> > m_data; //!< Corresponding data (may be null)
84
  //< Corresponding data (may be null)
85
};
137
};
86
138
87
} //namepsace ns3
139
} //namepsace ns3
(-)a/src/internet/model/tcp-socket-base.h (-4 / +4 lines)
 Lines 209-215    Link Here 
209
   * \brief Called by the L3 protocol when it received a packet to pass on to TCP.
209
   * \brief Called by the L3 protocol when it received a packet to pass on to TCP.
210
   *
210
   *
211
   * \param packet the incoming packet
211
   * \param packet the incoming packet
212
   * \param header the apcket's IPv4 header
212
   * \param header the packet's IPv4 header
213
   * \param port the incoming port
213
   * \param port the incoming port
214
   * \param incomingInterface the incoming interface
214
   * \param incomingInterface the incoming interface
215
   */
215
   */
 Lines 219-225    Link Here 
219
   * \brief Called by the L3 protocol when it received a packet to pass on to TCP.
219
   * \brief Called by the L3 protocol when it received a packet to pass on to TCP.
220
   *
220
   *
221
   * \param packet the incoming packet
221
   * \param packet the incoming packet
222
   * \param header the apcket's IPv6 header
222
   * \param header the packet's IPv6 header
223
   * \param port the incoming port
223
   * \param port the incoming port
224
   */
224
   */
225
  void ForwardUp6 (Ptr<Packet> packet, Ipv6Header header, uint16_t port);
225
  void ForwardUp6 (Ptr<Packet> packet, Ipv6Header header, uint16_t port);
 Lines 228-234    Link Here 
228
   * \brief Called by TcpSocketBase::ForwardUp().
228
   * \brief Called by TcpSocketBase::ForwardUp().
229
   *
229
   *
230
   * \param packet the incoming packet
230
   * \param packet the incoming packet
231
   * \param header the apcket's IPv4 header
231
   * \param header the packet's IPv4 header
232
   * \param port the incoming port
232
   * \param port the incoming port
233
   * \param incomingInterface the incoming interface
233
   * \param incomingInterface the incoming interface
234
   */
234
   */
 Lines 238-244    Link Here 
238
   * \brief Called by TcpSocketBase::ForwardUp6().
238
   * \brief Called by TcpSocketBase::ForwardUp6().
239
   *
239
   *
240
   * \param packet the incoming packet
240
   * \param packet the incoming packet
241
   * \param header the apcket's IPv6 header
241
   * \param header the packet's IPv6 header
242
   * \param port the incoming port
242
   * \param port the incoming port
243
   */
243
   */
244
  virtual void DoForwardUp (Ptr<Packet> packet, Ipv6Header header, uint16_t port);
244
  virtual void DoForwardUp (Ptr<Packet> packet, Ipv6Header header, uint16_t port);
(-)a/src/internet/model/tcp-tahoe.cc (-6 / +6 lines)
 Lines 72-78    Link Here 
72
{
72
{
73
}
73
}
74
74
75
/** We initialize m_cWnd from this function, after attributes initialized */
75
/* We initialize m_cWnd from this function, after attributes initialized */
76
int
76
int
77
TcpTahoe::Listen (void)
77
TcpTahoe::Listen (void)
78
{
78
{
 Lines 81-87    Link Here 
81
  return TcpSocketBase::Listen ();
81
  return TcpSocketBase::Listen ();
82
}
82
}
83
83
84
/** We initialize m_cWnd from this function, after attributes initialized */
84
/* We initialize m_cWnd from this function, after attributes initialized */
85
int
85
int
86
TcpTahoe::Connect (const Address & address)
86
TcpTahoe::Connect (const Address & address)
87
{
87
{
 Lines 90-96    Link Here 
90
  return TcpSocketBase::Connect (address);
90
  return TcpSocketBase::Connect (address);
91
}
91
}
92
92
93
/** Limit the size of in-flight data by cwnd and receiver's rxwin */
93
/* Limit the size of in-flight data by cwnd and receiver's rxwin */
94
uint32_t
94
uint32_t
95
TcpTahoe::Window (void)
95
TcpTahoe::Window (void)
96
{
96
{
 Lines 104-110    Link Here 
104
  return CopyObject<TcpTahoe> (this);
104
  return CopyObject<TcpTahoe> (this);
105
}
105
}
106
106
107
/** New ACK (up to seqnum seq) received. Increase cwnd and call TcpSocketBase::NewAck() */
107
/* New ACK (up to seqnum seq) received. Increase cwnd and call TcpSocketBase::NewAck() */
108
void
108
void
109
TcpTahoe::NewAck (SequenceNumber32 const& seq)
109
TcpTahoe::NewAck (SequenceNumber32 const& seq)
110
{
110
{
 Lines 128-134    Link Here 
128
  TcpSocketBase::NewAck (seq);           // Complete newAck processing
128
  TcpSocketBase::NewAck (seq);           // Complete newAck processing
129
}
129
}
130
130
131
/** Cut down ssthresh upon triple dupack */
131
/* Cut down ssthresh upon triple dupack */
132
void
132
void
133
TcpTahoe::DupAck (const TcpHeader& t, uint32_t count)
133
TcpTahoe::DupAck (const TcpHeader& t, uint32_t count)
134
{
134
{
 Lines 148-154    Link Here 
148
    }
148
    }
149
}
149
}
150
150
151
/** Retransmit timeout */
151
/* Retransmit timeout */
152
void TcpTahoe::Retransmit (void)
152
void TcpTahoe::Retransmit (void)
153
{
153
{
154
  NS_LOG_FUNCTION (this);
154
  NS_LOG_FUNCTION (this);
(-)a/src/internet/model/tcp-tahoe.h (-5 / +16 lines)
 Lines 42-52    Link Here 
42
class TcpTahoe : public TcpSocketBase
42
class TcpTahoe : public TcpSocketBase
43
{
43
{
44
public:
44
public:
45
  /**
46
   * \brief Get the type ID.
47
   * \return the object TypeId
48
   */
45
  static TypeId GetTypeId (void);
49
  static TypeId GetTypeId (void);
46
  /**
50
  /**
47
   * Create an unbound tcp socket.
51
   * Create an unbound tcp socket.
48
   */
52
   */
49
  TcpTahoe (void);
53
  TcpTahoe (void);
54
  /**
55
   * \brief Copy constructor
56
   * \param sock the object to copy
57
   */
50
  TcpTahoe (const TcpTahoe& sock);
58
  TcpTahoe (const TcpTahoe& sock);
51
  virtual ~TcpTahoe (void);
59
  virtual ~TcpTahoe (void);
52
60
 Lines 68-80    Link Here 
68
  virtual void     SetInitialCwnd (uint32_t cwnd);
76
  virtual void     SetInitialCwnd (uint32_t cwnd);
69
  virtual uint32_t GetInitialCwnd (void) const;
77
  virtual uint32_t GetInitialCwnd (void) const;
70
private:
78
private:
71
  void InitializeCwnd (void);            // set m_cWnd when connection starts
79
  /**
80
   * \brief Set the congestion window when connection starts
81
   */
82
  void InitializeCwnd (void);
72
83
73
protected:
84
protected:
74
  TracedValue<uint32_t>  m_cWnd;         //< Congestion window
85
  TracedValue<uint32_t>  m_cWnd;         //!< Congestion window
75
  uint32_t               m_ssThresh;     //< Slow Start Threshold
86
  uint32_t               m_ssThresh;     //!< Slow Start Threshold
76
  uint32_t               m_initialCWnd;  //< Initial cWnd value
87
  uint32_t               m_initialCWnd;  //!< Initial cWnd value
77
  uint32_t               m_retxThresh;   //< Fast Retransmit threshold
88
  uint32_t               m_retxThresh;   //!< Fast Retransmit threshold
78
};
89
};
79
90
80
} // namespace ns3
91
} // namespace ns3
(-)a/src/internet/model/tcp-tx-buffer.h (-4 / +25 lines)
 Lines 40-46    Link Here 
40
class TcpTxBuffer : public Object
40
class TcpTxBuffer : public Object
41
{
41
{
42
public:
42
public:
43
  /**
44
   * \brief Get the type ID.
45
   * \return the object TypeId
46
   */
43
  static TypeId GetTypeId (void);
47
  static TypeId GetTypeId (void);
48
  /**
49
   * \brief Constructor
50
   * \param n initial Sequence number to be transmitted
51
   */
44
  TcpTxBuffer (uint32_t n = 0);
52
  TcpTxBuffer (uint32_t n = 0);
45
  virtual ~TcpTxBuffer (void);
53
  virtual ~TcpTxBuffer (void);
46
54
 Lines 48-78    Link Here 
48
56
49
  /**
57
  /**
50
   * Returns the first byte's sequence number
58
   * Returns the first byte's sequence number
59
   * \returns the first byte's sequence number
51
   */
60
   */
52
  SequenceNumber32 HeadSequence (void) const;
61
  SequenceNumber32 HeadSequence (void) const;
53
62
54
  /**
63
  /**
55
   * Returns the last byte's sequence number + 1
64
   * Returns the last byte's sequence number + 1
65
   * \returns the last byte's sequence number + 1
56
   */
66
   */
57
  SequenceNumber32 TailSequence (void) const;
67
  SequenceNumber32 TailSequence (void) const;
58
68
59
  /**
69
  /**
60
   * Returns total number of bytes in this Tx buffer
70
   * Returns total number of bytes in this Tx buffer
71
   * \returns total number of bytes in this Tx buffer
61
   */
72
   */
62
  uint32_t Size (void) const;
73
  uint32_t Size (void) const;
63
74
64
  /**
75
  /**
65
   * Returns the Tx window size
76
   * Returns the Tx window size
77
   * \returns the Tx window size (in bytes)
66
   */
78
   */
67
  uint32_t MaxBufferSize (void) const;
79
  uint32_t MaxBufferSize (void) const;
68
80
69
  /**
81
  /**
70
   * Set the Tx window size
82
   * Set the Tx window size
83
   * \param n Tx window size (in bytes)
71
   */
84
   */
72
  void SetMaxBufferSize (uint32_t n);
85
  void SetMaxBufferSize (uint32_t n);
73
86
74
  /**
87
  /**
75
   * Returns the available capacity in this Tx window
88
   * Returns the available capacity in this Tx window
89
   * \returns available capacity in this Tx window
76
   */
90
   */
77
  uint32_t Available (void) const;
91
  uint32_t Available (void) const;
78
92
 Lines 86-102    Link Here 
86
100
87
  /**
101
  /**
88
   * Returns the number of bytes from the buffer in the range [seq, tailSequence)
102
   * Returns the number of bytes from the buffer in the range [seq, tailSequence)
103
   * \param seq initial sequence number
104
   * \returns the number of bytes from the buffer in the range
89
   */
105
   */
90
  uint32_t SizeFromSequence (const SequenceNumber32& seq) const;
106
  uint32_t SizeFromSequence (const SequenceNumber32& seq) const;
91
107
92
  /**
108
  /**
93
   * Copy data of size numBytes into a packet, data from the range [seq, seq+numBytes)
109
   * Copy data of size numBytes into a packet, data from the range [seq, seq+numBytes)
110
   * \param numBytes number of bytes to copy
111
   * \param seq start sequence number to extract
112
   * \returns a packet
94
   */
113
   */
95
  Ptr<Packet> CopyFromSequence (uint32_t numBytes, const SequenceNumber32& seq);
114
  Ptr<Packet> CopyFromSequence (uint32_t numBytes, const SequenceNumber32& seq);
96
115
97
  /**
116
  /**
98
   * Set the m_firstByteSeq to seq. Supposed to be called only when the
117
   * Set the m_firstByteSeq to seq. Supposed to be called only when the
99
   * connection is just set up and we did not send any data out yet.
118
   * connection is just set up and we did not send any data out yet.
119
   * \param seq The sequence number of the head byte
100
   */
120
   */
101
  void SetHeadSequence (const SequenceNumber32& seq);
121
  void SetHeadSequence (const SequenceNumber32& seq);
102
122
 Lines 108-119    Link Here 
108
  void DiscardUpTo (const SequenceNumber32& seq);
128
  void DiscardUpTo (const SequenceNumber32& seq);
109
129
110
private:
130
private:
131
  /// container for data stored in the buffer
111
  typedef std::list<Ptr<Packet> >::iterator BufIterator;
132
  typedef std::list<Ptr<Packet> >::iterator BufIterator;
112
133
113
  TracedValue<SequenceNumber32> m_firstByteSeq; //< Sequence number of the first byte in data (SND.UNA)
134
  TracedValue<SequenceNumber32> m_firstByteSeq; //!< Sequence number of the first byte in data (SND.UNA)
114
  uint32_t m_size;                              //< Number of data bytes
135
  uint32_t m_size;                              //!< Number of data bytes
115
  uint32_t m_maxBuffer;                         //< Max number of data bytes in buffer (SND.WND)
136
  uint32_t m_maxBuffer;                         //!< Max number of data bytes in buffer (SND.WND)
116
  std::list<Ptr<Packet> > m_data;               //< Corresponding data (may be null)
137
  std::list<Ptr<Packet> > m_data;               //!< Corresponding data (may be null)
117
};
138
};
118
139
119
} // namepsace ns3
140
} // namepsace ns3
(-)a/src/internet/model/tcp-westwood.h (-72 / +39 lines)
 Lines 62-79    Link Here 
62
class TcpWestwood : public TcpSocketBase
62
class TcpWestwood : public TcpSocketBase
63
{
63
{
64
public:
64
public:
65
  /**
66
   * \brief Get the type ID.
67
   * \return the object TypeId
68
   */
65
  static TypeId GetTypeId (void);
69
  static TypeId GetTypeId (void);
66
70
67
  TcpWestwood (void);
71
  TcpWestwood (void);
72
  /**
73
   * \brief Copy constructor
74
   * \param sock the object to copy
75
   */
68
  TcpWestwood (const TcpWestwood& sock);
76
  TcpWestwood (const TcpWestwood& sock);
69
  virtual ~TcpWestwood (void);
77
  virtual ~TcpWestwood (void);
70
78
79
  /**
80
   * \brief Protocol variant (Westwood or Westwood+)
81
   */
71
  enum ProtocolType 
82
  enum ProtocolType 
72
  {
83
  {
73
    WESTWOOD,
84
    WESTWOOD,
74
    WESTWOODPLUS
85
    WESTWOODPLUS
75
  };
86
  };
76
87
88
  /**
89
   * \brief Filter type (None or Tustin)
90
   */
77
  enum FilterType 
91
  enum FilterType 
78
  {
92
  {
79
    NONE,
93
    NONE,
 Lines 85-101    Link Here 
85
  virtual int Listen (void);
99
  virtual int Listen (void);
86
100
87
protected:
101
protected:
88
  /**
102
  virtual uint32_t Window (void); // Return the max possible number of unacked bytes
89
   * Limit the size of outstanding data based on the cwnd and the receiver's advertised window
103
  virtual Ptr<TcpSocketBase> Fork (void); // Call CopyObject<TcpTahoe> to clone me
90
   *
104
  virtual void NewAck (SequenceNumber32 const& seq); // Inc cwnd and call NewAck() of parent
91
   * \return the max. possible number of unacked bytes
105
  virtual void DupAck (const TcpHeader& t, uint32_t count);  // Treat 3 dupack as timeout
92
   */  
106
  virtual void Retransmit (void); // Retransmit time out
93
  virtual uint32_t Window (void);
94
95
  /**
96
   * Call CopyObject<TcpWestwood> to clone me
97
   */  
98
  virtual Ptr<TcpSocketBase> Fork (void);
99
107
100
  /**
108
  /**
101
   * Process the newly received ACK
109
   * Process the newly received ACK
 Lines 106-163    Link Here 
106
  virtual void ReceivedAck (Ptr<Packet> packet, const TcpHeader& tcpHeader);
114
  virtual void ReceivedAck (Ptr<Packet> packet, const TcpHeader& tcpHeader);
107
  
115
  
108
  /**
116
  /**
109
   * Adjust the cwnd based on the current congestion control phase,
110
   * and then call the TcpSocketBase::NewAck() to complete the processing
111
   *
112
   * \param seq the acknowledgment number
113
   */  
114
  virtual void NewAck (SequenceNumber32 const& seq);
115
116
  /**
117
   * Adjust the cwnd using the currently estimated bandwidth,
118
   * retransmit the missing packet, and enter fast recovery if 3 DUPACKs are received
119
   *
120
   * \param header the TCP header of the ACK packet
121
   * \param count the number of DUPACKs
122
   */  
123
  virtual void DupAck (const TcpHeader& header, uint32_t count);
124
125
  /**
126
   * Upon an RTO event, adjust the cwnd using the currently estimated bandwidth,
127
   * retransmit the missing packet, and exit fast recovery
128
   */  
129
  virtual void Retransmit (void);
130
131
  /**
132
   * Estimate the RTT, record the minimum value,
117
   * Estimate the RTT, record the minimum value,
133
   * and run a clock on the RTT to trigger Westwood+ bandwidth sampling
118
   * and run a clock on the RTT to trigger Westwood+ bandwidth sampling
119
   * \param header the packet header
134
   */
120
   */
135
  virtual void EstimateRtt (const TcpHeader& header);
121
  virtual void EstimateRtt (const TcpHeader& header);
136
122
137
  // Implementing ns3::TcpSocket -- Attribute get/set
123
  // Implementing ns3::TcpSocket -- Attribute get/set
138
  /**
124
  virtual void     SetSegSize (uint32_t size);
139
   * \param size the segment size to be used in a connection
125
  virtual void     SetSSThresh (uint32_t threshold);
140
   */  
141
  virtual void SetSegSize (uint32_t size);
142
143
  /**
144
   * \param the slow-start threshold
145
   */  
146
  virtual void SetSSThresh (uint32_t threshold);
147
148
  /**
149
   * \return the slow-start threshold
150
   */  
151
  virtual uint32_t GetSSThresh (void) const;
126
  virtual uint32_t GetSSThresh (void) const;
152
127
  virtual void     SetInitialCwnd (uint32_t cwnd);
153
  /**
154
   * \param cwnd the initial cwnd
155
   */  
156
  virtual void SetInitialCwnd (uint32_t cwnd);
157
158
  /**
159
   * \return the initial cwnd
160
   */ 
161
  virtual uint32_t GetInitialCwnd (void) const;
128
  virtual uint32_t GetInitialCwnd (void) const;
162
129
163
private:
130
private:
 Lines 196-219    Link Here 
196
  void Filtering (void);
163
  void Filtering (void);
197
164
198
protected:
165
protected:
199
  TracedValue<uint32_t>  m_cWnd;                   //< Congestion window
166
  TracedValue<uint32_t>  m_cWnd;                   //!< Congestion window
200
  uint32_t               m_ssThresh;               //< Slow Start Threshold
167
  uint32_t               m_ssThresh;               //!< Slow Start Threshold
201
  uint32_t               m_initialCWnd;            //< Initial cWnd value
168
  uint32_t               m_initialCWnd;            //!< Initial cWnd value
202
  bool                   m_inFastRec;              //< Currently in fast recovery if TRUE
169
  bool                   m_inFastRec;              //!< Currently in fast recovery if TRUE
203
170
204
  TracedValue<double>    m_currentBW;              //< Current value of the estimated BW
171
  TracedValue<double>    m_currentBW;              //!< Current value of the estimated BW
205
  double                 m_lastSampleBW;           //< Last bandwidth sample
172
  double                 m_lastSampleBW;           //!< Last bandwidth sample
206
  double                 m_lastBW;                 //< Last bandwidth sample after being filtered
173
  double                 m_lastBW;                 //!< Last bandwidth sample after being filtered
207
  Time                   m_minRtt;                 //< Minimum RTT
174
  Time                   m_minRtt;                 //!< Minimum RTT
208
  double                 m_lastAck;                //< The time last ACK was received
175
  double                 m_lastAck;                //!< The time last ACK was received
209
  SequenceNumber32       m_prevAckNo;              //< Previously received ACK number
176
  SequenceNumber32       m_prevAckNo;              //!< Previously received ACK number
210
  int                    m_accountedFor;           //< The number of received DUPACKs
177
  int                    m_accountedFor;           //!< The number of received DUPACKs
211
  enum ProtocolType      m_pType;                  //< 0 for Westwood, 1 for Westwood+
178
  enum ProtocolType      m_pType;                  //!< 0 for Westwood, 1 for Westwood+
212
  enum FilterType        m_fType;                  //< 0 for none, 1 for Tustin
179
  enum FilterType        m_fType;                  //!< 0 for none, 1 for Tustin
213
180
214
  int                    m_ackedSegments;          //< The number of segments ACKed between RTTs
181
  int                    m_ackedSegments;          //!< The number of segments ACKed between RTTs
215
  bool                   m_IsCount;                //< Start keeping track of m_ackedSegments for Westwood+ if TRUE
182
  bool                   m_IsCount;                //!< Start keeping track of m_ackedSegments for Westwood+ if TRUE
216
  EventId                m_bwEstimateEvent;        //< The BW estimation event for Westwood+
183
  EventId                m_bwEstimateEvent;        //!< The BW estimation event for Westwood+
217
184
218
};
185
};
219
186
(-)a/src/internet/model/udp-header.h (-8 / +17 lines)
 Lines 114-119    Link Here 
114
                           Ipv6Address destination,
114
                           Ipv6Address destination,
115
                           uint8_t protocol);
115
                           uint8_t protocol);
116
116
117
  /**
118
   * \brief Get the type ID.
119
   * \return the object TypeId
120
   */
117
  static TypeId GetTypeId (void);
121
  static TypeId GetTypeId (void);
118
  virtual TypeId GetInstanceTypeId (void) const;
122
  virtual TypeId GetInstanceTypeId (void) const;
119
  virtual void Print (std::ostream &os) const;
123
  virtual void Print (std::ostream &os) const;
 Lines 128-143    Link Here 
128
  bool IsChecksumOk (void) const;
132
  bool IsChecksumOk (void) const;
129
133
130
private:
134
private:
135
  /**
136
   * \brief Calculate the header checksum
137
   * \param size packet size
138
   * \returns the checksum
139
   */
131
  uint16_t CalculateHeaderChecksum (uint16_t size) const;
140
  uint16_t CalculateHeaderChecksum (uint16_t size) const;
132
  uint16_t m_sourcePort;
141
  uint16_t m_sourcePort;      //!< Source port
133
  uint16_t m_destinationPort;
142
  uint16_t m_destinationPort; //!< Destination port
134
  uint16_t m_payloadSize;
143
  uint16_t m_payloadSize;     //!< Payload size
135
144
136
  Address m_source;
145
  Address m_source;           //!< Source IP address
137
  Address m_destination;
146
  Address m_destination;      //!< Destination IP address
138
  uint8_t m_protocol;
147
  uint8_t m_protocol;         //!< Protocol number
139
  bool m_calcChecksum;
148
  bool m_calcChecksum;        //!< Flag to calculate checksum
140
  bool m_goodChecksum;
149
  bool m_goodChecksum;        //!< Flag to indicate that checksum is correct
141
};
150
};
142
151
143
} // namespace ns3
152
} // namespace ns3
(-)a/src/internet/model/udp-l4-protocol.h (-32 / +129 lines)
 Lines 47-58    Link Here 
47
 */
47
 */
48
class UdpL4Protocol : public IpL4Protocol {
48
class UdpL4Protocol : public IpL4Protocol {
49
public:
49
public:
50
  /**
51
   * \brief Get the type ID.
52
   * \return the object TypeId
53
   */
50
  static TypeId GetTypeId (void);
54
  static TypeId GetTypeId (void);
51
  static const uint8_t PROT_NUMBER;
55
  static const uint8_t PROT_NUMBER; //!< protocol number (0x11)
52
56
53
  UdpL4Protocol ();
57
  UdpL4Protocol ();
54
  virtual ~UdpL4Protocol ();
58
  virtual ~UdpL4Protocol ();
55
59
60
  /**
61
   * Set node associated with this stack
62
   * \param node the node
63
   */
56
  void SetNode (Ptr<Node> node);
64
  void SetNode (Ptr<Node> node);
57
65
58
  virtual int GetProtocolNumber (void) const;
66
  virtual int GetProtocolNumber (void) const;
 Lines 63-87    Link Here 
63
   */
71
   */
64
  Ptr<Socket> CreateSocket (void);
72
  Ptr<Socket> CreateSocket (void);
65
73
74
  /**
75
   * \brief Allocate an IPv4 Endpoint
76
   * \return the Endpoint
77
   */
66
  Ipv4EndPoint *Allocate (void);
78
  Ipv4EndPoint *Allocate (void);
79
  /**
80
   * \brief Allocate an IPv4 Endpoint
81
   * \param address address to use
82
   * \return the Endpoint
83
   */
67
  Ipv4EndPoint *Allocate (Ipv4Address address);
84
  Ipv4EndPoint *Allocate (Ipv4Address address);
85
  /**
86
   * \brief Allocate an IPv4 Endpoint
87
   * \param port port to use
88
   * \return the Endpoint
89
   */
68
  Ipv4EndPoint *Allocate (uint16_t port);
90
  Ipv4EndPoint *Allocate (uint16_t port);
91
  /**
92
   * \brief Allocate an IPv4 Endpoint
93
   * \param address address to use
94
   * \param port port to use
95
   * \return the Endpoint
96
   */
69
  Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
97
  Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
98
  /**
99
   * \brief Allocate an IPv4 Endpoint
100
   * \param localAddress local address to use
101
   * \param localPort local port to use
102
   * \param peerAddress remote address to use
103
   * \param peerPort remote port to use
104
   * \return the Endpoint
105
   */
70
  Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
106
  Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
71
                          Ipv4Address peerAddress, uint16_t peerPort);
107
                          Ipv4Address peerAddress, uint16_t peerPort);
108
109
  /**
110
   * \brief Allocate an IPv6 Endpoint
111
   * \return the Endpoint
112
   */
72
  Ipv6EndPoint *Allocate6 (void);
113
  Ipv6EndPoint *Allocate6 (void);
114
  /**
115
   * \brief Allocate an IPv6 Endpoint
116
   * \param address address to use
117
   * \return the Endpoint
118
   */
73
  Ipv6EndPoint *Allocate6 (Ipv6Address address);
119
  Ipv6EndPoint *Allocate6 (Ipv6Address address);
120
  /**
121
   * \brief Allocate an IPv6 Endpoint
122
   * \param port port to use
123
   * \return the Endpoint
124
   */
74
  Ipv6EndPoint *Allocate6 (uint16_t port);
125
  Ipv6EndPoint *Allocate6 (uint16_t port);
126
  /**
127
   * \brief Allocate an IPv6 Endpoint
128
   * \param address address to use
129
   * \param port port to use
130
   * \return the Endpoint
131
   */
75
  Ipv6EndPoint *Allocate6 (Ipv6Address address, uint16_t port);
132
  Ipv6EndPoint *Allocate6 (Ipv6Address address, uint16_t port);
133
  /**
134
   * \brief Allocate an IPv6 Endpoint
135
   * \param localAddress local address to use
136
   * \param localPort local port to use
137
   * \param peerAddress remote address to use
138
   * \param peerPort remote port to use
139
   * \return the Endpoint
140
   */
76
  Ipv6EndPoint *Allocate6 (Ipv6Address localAddress, uint16_t localPort,
141
  Ipv6EndPoint *Allocate6 (Ipv6Address localAddress, uint16_t localPort,
77
                          Ipv6Address peerAddress, uint16_t peerPort);
142
                           Ipv6Address peerAddress, uint16_t peerPort);
78
143
144
  /**
145
   * \brief Remove an IPv4 Endpoint.
146
   * \param endPoint the end point to remove
147
   */
79
  void DeAllocate (Ipv4EndPoint *endPoint);
148
  void DeAllocate (Ipv4EndPoint *endPoint);
149
  /**
150
   * \brief Remove an IPv6 Endpoint.
151
   * \param endPoint the end point to remove
152
   */
80
  void DeAllocate (Ipv6EndPoint *endPoint);
153
  void DeAllocate (Ipv6EndPoint *endPoint);
81
154
82
  // called by UdpSocket.
155
  // called by UdpSocket.
83
  /**
156
  /**
84
   * \brief Send a packet via UDP
157
   * \brief Send a packet via UDP (IPv4)
85
   * \param packet The packet to send
158
   * \param packet The packet to send
86
   * \param saddr The source Ipv4Address
159
   * \param saddr The source Ipv4Address
87
   * \param daddr The destination Ipv4Address
160
   * \param daddr The destination Ipv4Address
 Lines 91-130    Link Here 
91
  void Send (Ptr<Packet> packet,
164
  void Send (Ptr<Packet> packet,
92
             Ipv4Address saddr, Ipv4Address daddr, 
165
             Ipv4Address saddr, Ipv4Address daddr, 
93
             uint16_t sport, uint16_t dport);
166
             uint16_t sport, uint16_t dport);
167
  /**
168
   * \brief Send a packet via UDP (IPv4)
169
   * \param packet The packet to send
170
   * \param saddr The source Ipv4Address
171
   * \param daddr The destination Ipv4Address
172
   * \param sport The source port number
173
   * \param dport The destination port number
174
   * \param route The route
175
   */
94
  void Send (Ptr<Packet> packet,
176
  void Send (Ptr<Packet> packet,
95
             Ipv4Address saddr, Ipv4Address daddr, 
177
             Ipv4Address saddr, Ipv4Address daddr, 
96
             uint16_t sport, uint16_t dport, Ptr<Ipv4Route> route);
178
             uint16_t sport, uint16_t dport, Ptr<Ipv4Route> route);
179
  /**
180
   * \brief Send a packet via UDP (IPv6)
181
   * \param packet The packet to send
182
   * \param saddr The source Ipv4Address
183
   * \param daddr The destination Ipv4Address
184
   * \param sport The source port number
185
   * \param dport The destination port number
186
   */
97
  void Send (Ptr<Packet> packet,
187
  void Send (Ptr<Packet> packet,
98
             Ipv6Address saddr, Ipv6Address daddr, 
188
             Ipv6Address saddr, Ipv6Address daddr, 
99
             uint16_t sport, uint16_t dport);
189
             uint16_t sport, uint16_t dport);
190
  /**
191
   * \brief Send a packet via UDP (IPv6)
192
   * \param packet The packet to send
193
   * \param saddr The source Ipv4Address
194
   * \param daddr The destination Ipv4Address
195
   * \param sport The source port number
196
   * \param dport The destination port number
197
   * \param route The route
198
   */
100
  void Send (Ptr<Packet> packet,
199
  void Send (Ptr<Packet> packet,
101
             Ipv6Address saddr, Ipv6Address daddr, 
200
             Ipv6Address saddr, Ipv6Address daddr, 
102
             uint16_t sport, uint16_t dport, Ptr<Ipv6Route> route);
201
             uint16_t sport, uint16_t dport, Ptr<Ipv6Route> route);
103
  /**
202
104
   * \brief Receive a packet up the protocol stack
105
   * \param p The Packet to dump the contents into
106
   * \param header IPv4 Header information
107
   * \param interface the interface from which the packet is coming.
108
   */
109
  // inherited from Ipv4L4Protocol
203
  // inherited from Ipv4L4Protocol
110
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
204
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
111
                                                 Ipv4Header const &header,
205
                                               Ipv4Header const &header,
112
                                                 Ptr<Ipv4Interface> interface);
206
                                               Ptr<Ipv4Interface> interface);
113
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
207
  virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
114
                                                 Ipv6Header const &header,
208
                                               Ipv6Header const &header,
115
                                                 Ptr<Ipv6Interface> interface);
209
                                               Ptr<Ipv6Interface> interface);
116
210
117
  /**
118
   * \brief Receive an ICMP packet
119
   * \param icmpSource The IP address of the source of the packet.
120
   * \param icmpTtl The time to live from the IP header
121
   * \param icmpType The type of the message from the ICMP header
122
   * \param icmpCode The message code from the ICMP header
123
   * \param icmpInfo 32-bit integer carrying informational value of varying semantics.
124
   * \param payloadSource The IP source address from the IP header of the packet
125
   * \param payloadDestination The IP destination address from the IP header of the packet
126
   * \param payload Payload of the ICMP packet
127
   */
128
  virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
211
  virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
129
                            uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
212
                            uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
130
                            Ipv4Address payloadSource,Ipv4Address payloadDestination,
213
                            Ipv4Address payloadSource,Ipv4Address payloadDestination,
 Lines 149-162    Link Here 
149
   */
232
   */
150
  virtual void NotifyNewAggregate ();
233
  virtual void NotifyNewAggregate ();
151
private:
234
private:
152
  Ptr<Node> m_node;
235
  Ptr<Node> m_node; //!< the node this stack is associated with
153
  Ipv4EndPointDemux *m_endPoints;
236
  Ipv4EndPointDemux *m_endPoints; //!< A list of IPv4 end points.
154
  Ipv6EndPointDemux *m_endPoints6;
237
  Ipv6EndPointDemux *m_endPoints6; //!< A list of IPv6 end points.
155
  UdpL4Protocol (const UdpL4Protocol &o);
238
156
  UdpL4Protocol &operator = (const UdpL4Protocol &o);
239
  /**
157
  std::vector<Ptr<UdpSocketImpl> > m_sockets;
240
   * \brief Copy constructor
158
  IpL4Protocol::DownTargetCallback m_downTarget;
241
   *
159
  IpL4Protocol::DownTargetCallback6 m_downTarget6;
242
   * Defined and not implemented to avoid misuse
243
   */
244
  UdpL4Protocol (const UdpL4Protocol &);
245
  /**
246
   * \brief Copy constructor
247
   *
248
   * Defined and not implemented to avoid misuse
249
   * \returns
250
   */
251
  UdpL4Protocol &operator = (const UdpL4Protocol &);
252
253
  std::vector<Ptr<UdpSocketImpl> > m_sockets;      //!< list of sockets
254
  IpL4Protocol::DownTargetCallback m_downTarget;   //!< Callback to send packets over IPv4
255
  IpL4Protocol::DownTargetCallback6 m_downTarget6; //!< Callback to send packets over IPv6
256
160
};
257
};
161
258
162
} // namespace ns3
259
} // namespace ns3
(-)a/src/internet/model/udp-socket-factory-impl.h (-1 / +5 lines)
 Lines 57-62    Link Here 
57
  UdpSocketFactoryImpl ();
57
  UdpSocketFactoryImpl ();
58
  virtual ~UdpSocketFactoryImpl ();
58
  virtual ~UdpSocketFactoryImpl ();
59
59
60
  /**
61
   * \brief Set the associated UDP L4 protocol.
62
   * \param udp the UDP L4 protocol
63
   */
60
  void SetUdp (Ptr<UdpL4Protocol> udp);
64
  void SetUdp (Ptr<UdpL4Protocol> udp);
61
65
62
  /**
66
  /**
 Lines 71-77    Link Here 
71
protected:
75
protected:
72
  virtual void DoDispose (void);
76
  virtual void DoDispose (void);
73
private:
77
private:
74
  Ptr<UdpL4Protocol> m_udp;
78
  Ptr<UdpL4Protocol> m_udp; //!< the associated UDP L4 protocol
75
};
79
};
76
80
77
} // namespace ns3
81
} // namespace ns3
(-)a/src/internet/model/udp-socket-factory.h (+4 lines)
 Lines 40-45    Link Here 
40
class UdpSocketFactory : public SocketFactory
40
class UdpSocketFactory : public SocketFactory
41
{
41
{
42
public:
42
public:
43
  /**
44
   * \brief Get the type ID.
45
   * \return the object TypeId
46
   */
43
  static TypeId GetTypeId (void);
47
  static TypeId GetTypeId (void);
44
48
45
};
49
};
(-)a/src/internet/model/udp-socket-impl.cc (-3 / +6 lines)
 Lines 45-51    Link Here 
45
NS_OBJECT_ENSURE_REGISTERED (UdpSocketImpl)
45
NS_OBJECT_ENSURE_REGISTERED (UdpSocketImpl)
46
  ;
46
  ;
47
47
48
static const uint32_t MAX_IPV4_UDP_DATAGRAM_SIZE = 65507;
48
// The correct maximum UDP message size is 65507, as determined by the following formula:
49
// 0xffff - (sizeof(IP Header) + sizeof(UDP Header)) = 65535-(20+8) = 65507
50
// \todo MAX_IPV4_UDP_DATAGRAM_SIZE is correct only for IPv4
51
static const uint32_t MAX_IPV4_UDP_DATAGRAM_SIZE = 65507; //!< Maximum UDP datagram size
49
52
50
// Add attributes generic to all UdpSockets to base class UdpSocket
53
// Add attributes generic to all UdpSockets to base class UdpSocket
51
TypeId
54
TypeId
 Lines 736-744    Link Here 
736
}
739
}
737
740
738
741
739
//  maximum message size for UDP broadcast is limited by MTU
742
// maximum message size for UDP broadcast is limited by MTU
740
// size of underlying link; we are not checking that now.
743
// size of underlying link; we are not checking that now.
741
/// \todo Check MTU size of underlying link
744
// \todo Check MTU size of underlying link
742
uint32_t
745
uint32_t
743
UdpSocketImpl::GetTxAvailable (void) const
746
UdpSocketImpl::GetTxAvailable (void) const
744
{
747
{
(-)a/src/internet/model/udp-socket-impl.h (-30 / +121 lines)
 Lines 50-55    Link Here 
50
class UdpSocketImpl : public UdpSocket
50
class UdpSocketImpl : public UdpSocket
51
{
51
{
52
public:
52
public:
53
  /**
54
   * \brief Get the type ID.
55
   * \return the object TypeId
56
   */
53
  static TypeId GetTypeId (void);
57
  static TypeId GetTypeId (void);
54
  /**
58
  /**
55
   * Create an unbound udp socket.
59
   * Create an unbound udp socket.
 Lines 57-63    Link Here 
57
  UdpSocketImpl ();
61
  UdpSocketImpl ();
58
  virtual ~UdpSocketImpl ();
62
  virtual ~UdpSocketImpl ();
59
63
64
  /**
65
   * \brief Set the associated node.
66
   * \param node the node
67
   */
60
  void SetNode (Ptr<Node> node);
68
  void SetNode (Ptr<Node> node);
69
  /**
70
   * \brief Set the associated UDP L4 protocol.
71
   * \param udp the UDP L4 protocol
72
   */
61
  void SetUdp (Ptr<UdpL4Protocol> udp);
73
  void SetUdp (Ptr<UdpL4Protocol> udp);
62
74
63
  virtual enum SocketErrno GetErrno (void) const;
75
  virtual enum SocketErrno GetErrno (void) const;
 Lines 101-148    Link Here 
101
113
102
  friend class UdpSocketFactory;
114
  friend class UdpSocketFactory;
103
  // invoked by Udp class
115
  // invoked by Udp class
116
117
  /**
118
   * Finish the binding process
119
   * \returns 0 on success, -1 on failure
120
   */
104
  int FinishBind (void);
121
  int FinishBind (void);
105
  void ForwardUp (Ptr<Packet> p, Ipv4Header header, uint16_t port, 
122
106
                  Ptr<Ipv4Interface> incomingInterface);
123
  /**
107
  void ForwardUp6 (Ptr<Packet> p, Ipv6Header header, uint16_t port);
124
   * \brief Called by the L3 protocol when it received a packet to pass on to TCP.
125
   *
126
   * \param packet the incoming packet
127
   * \param header the packet's IPv4 header
128
   * \param port the incoming port
129
   * \param incomingInterface the incoming interface
130
   */
131
  void ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Ptr<Ipv4Interface> incomingInterface);
132
133
  /**
134
   * \brief Called by the L3 protocol when it received a packet to pass on to TCP.
135
   *
136
   * \param packet the incoming packet
137
   * \param header the packet's IPv6 header
138
   * \param port the incoming port
139
   */
140
  void ForwardUp6 (Ptr<Packet> packet, Ipv6Header header, uint16_t port);
141
142
  /**
143
   * \brief Kill this socket by zeroing its attributes (IPv4)
144
   *
145
   * This is a callback function configured to m_endpoint in
146
   * SetupCallback(), invoked when the endpoint is destroyed.
147
   */
108
  void Destroy (void);
148
  void Destroy (void);
149
150
  /**
151
   * \brief Kill this socket by zeroing its attributes (IPv6)
152
   *
153
   * This is a callback function configured to m_endpoint in
154
   * SetupCallback(), invoked when the endpoint is destroyed.
155
   */
109
  void Destroy6 (void);
156
  void Destroy6 (void);
157
158
  /**
159
   * \brief Send a packet
160
   * \param p packet
161
   * \returns 0 on success, -1 on failure
162
   */
110
  int DoSend (Ptr<Packet> p);
163
  int DoSend (Ptr<Packet> p);
164
  /**
165
   * \brief Send a packet to a specific destination
166
   * \param p packet
167
   * \param daddr destination address
168
   * \returns 0 on success, -1 on failure
169
   */
111
  int DoSendTo (Ptr<Packet> p, const Address &daddr);
170
  int DoSendTo (Ptr<Packet> p, const Address &daddr);
171
  /**
172
   * \brief Send a packet to a specific destination and port (IPv4)
173
   * \param p packet
174
   * \param daddr destination address
175
   * \param dport destination port
176
   * \returns 0 on success, -1 on failure
177
   */
112
  int DoSendTo (Ptr<Packet> p, Ipv4Address daddr, uint16_t dport);
178
  int DoSendTo (Ptr<Packet> p, Ipv4Address daddr, uint16_t dport);
179
  /**
180
   * \brief Send a packet to a specific destination and port (IPv6)
181
   * \param p packet
182
   * \param daddr destination address
183
   * \param dport destination port
184
   * \returns 0 on success, -1 on failure
185
   */
113
  int DoSendTo (Ptr<Packet> p, Ipv6Address daddr, uint16_t dport);
186
  int DoSendTo (Ptr<Packet> p, Ipv6Address daddr, uint16_t dport);
114
  void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, 
115
                    uint8_t icmpType, uint8_t icmpCode,
116
                    uint32_t icmpInfo);
117
  void ForwardIcmp6 (Ipv6Address icmpSource, uint8_t icmpTtl, 
118
                     uint8_t icmpType, uint8_t icmpCode,
119
                     uint32_t icmpInfo);
120
187
121
  Ipv4EndPoint *m_endPoint;
188
  /**
122
  Ipv6EndPoint *m_endPoint6;
189
   * \brief Called by the L3 protocol when it received an ICMP packet to pass on to TCP.
123
  Ptr<Node> m_node;
190
   *
124
  Ptr<UdpL4Protocol> m_udp;
191
   * \param icmpSource the ICMP source address
125
  Address m_defaultAddress;
192
   * \param icmpTtl the ICMP Time to Live
126
  uint16_t m_defaultPort;
193
   * \param icmpType the ICMP Type
127
  TracedCallback<Ptr<const Packet> > m_dropTrace;
194
   * \param icmpCode the ICMP Code
195
   * \param icmpInfo the ICMP Info
196
   */
197
  void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo);
128
198
129
  enum SocketErrno m_errno;
199
  /**
130
  bool m_shutdownSend;
200
   * \brief Called by the L3 protocol when it received an ICMPv6 packet to pass on to TCP.
131
  bool m_shutdownRecv;
201
   *
132
  bool m_connected;
202
   * \param icmpSource the ICMP source address
133
  bool m_allowBroadcast;
203
   * \param icmpTtl the ICMP Time to Live
204
   * \param icmpType the ICMP Type
205
   * \param icmpCode the ICMP Code
206
   * \param icmpInfo the ICMP Info
207
   */
208
  void ForwardIcmp6 (Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo);
134
209
135
  std::queue<Ptr<Packet> > m_deliveryQueue;
210
  // Connections to other layers of TCP/IP
136
  uint32_t m_rxAvailable;
211
  Ipv4EndPoint*       m_endPoint;   //!< the IPv4 endpoint
212
  Ipv6EndPoint*       m_endPoint6;  //!< the IPv6 endpoint
213
  Ptr<Node>           m_node;       //!< the associated node
214
  Ptr<UdpL4Protocol> m_udp;         //!< the associated UDP L4 protocol
215
  Callback<void, Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback;  //!< ICMP callback
216
  Callback<void, Ipv6Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback6; //!< ICMPv6 callback
217
218
  Address m_defaultAddress; //!< Default address
219
  uint16_t m_defaultPort;   //!< Default port
220
  TracedCallback<Ptr<const Packet> > m_dropTrace; //!< Trace for dropped packets
221
222
  enum SocketErrno         m_errno;           //!< Socket error code
223
  bool                     m_shutdownSend;    //!< Send no longer allowed
224
  bool                     m_shutdownRecv;    //!< Receive no longer allowed
225
  bool                     m_connected;       //!< Connection established
226
  bool                     m_allowBroadcast;  //!< Allow send broadcast packets
227
228
  std::queue<Ptr<Packet> > m_deliveryQueue; //!< Queue for incoming packets
229
  uint32_t m_rxAvailable;                   //!< Number of available bytes to be received
137
230
138
  // Socket attributes
231
  // Socket attributes
139
  uint32_t m_rcvBufSize;
232
  uint32_t m_rcvBufSize;    //!< Receive buffer size
140
  uint8_t m_ipMulticastTtl;
233
  uint8_t m_ipMulticastTtl; //!< Multicast TTL
141
  int32_t m_ipMulticastIf;
234
  int32_t m_ipMulticastIf;  //!< Multicast Interface
142
  bool m_ipMulticastLoop;
235
  bool m_ipMulticastLoop;   //!< Allow multicast loop
143
  bool m_mtuDiscover;
236
  bool m_mtuDiscover;       //!< Allow MTU discovery
144
  Callback<void, Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback;
145
  Callback<void, Ipv6Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback6;
146
};
237
};
147
238
148
} // namespace ns3
239
} // namespace ns3
(-)a/src/internet/model/udp-socket.h (+57 lines)
 Lines 46-51    Link Here 
46
class UdpSocket : public Socket
46
class UdpSocket : public Socket
47
{
47
{
48
public:
48
public:
49
  /**
50
   * Get the type ID.
51
   * \brief Get the type ID.
52
   * \return the object TypeId
53
   */
49
  static TypeId GetTypeId (void);
54
  static TypeId GetTypeId (void);
50
 
55
 
51
  UdpSocket (void);
56
  UdpSocket (void);
 Lines 99-113    Link Here 
99
104
100
private:
105
private:
101
  // Indirect the attribute setting and getting through private virtual methods
106
  // Indirect the attribute setting and getting through private virtual methods
107
  /**
108
   * \brief Set the receiving buffer size
109
   * \param size the buffer size
110
   */
102
  virtual void SetRcvBufSize (uint32_t size) = 0;
111
  virtual void SetRcvBufSize (uint32_t size) = 0;
112
  /**
113
   * \brief Get the receiving buffer size
114
   * \returns the buffer size
115
   */
103
  virtual uint32_t GetRcvBufSize (void) const = 0;
116
  virtual uint32_t GetRcvBufSize (void) const = 0;
117
  /**
118
   * \brief Set the IP multicast TTL
119
   * \param ipTtl the IP multicast TTL
120
   */
104
  virtual void SetIpMulticastTtl (uint8_t ipTtl) = 0;
121
  virtual void SetIpMulticastTtl (uint8_t ipTtl) = 0;
122
  /**
123
   * \brief Get the IP multicast TTL
124
   * \returns the IP multicast TTL
125
   */
105
  virtual uint8_t GetIpMulticastTtl (void) const = 0;
126
  virtual uint8_t GetIpMulticastTtl (void) const = 0;
127
  /**
128
   * \brief Set the IP multicast interface
129
   * \param ipIf the IP multicast interface
130
   */
106
  virtual void SetIpMulticastIf (int32_t ipIf) = 0;
131
  virtual void SetIpMulticastIf (int32_t ipIf) = 0;
132
  /**
133
   * \brief Get the IP multicast interface
134
   * \returns the IP multicast interface
135
   */
107
  virtual int32_t GetIpMulticastIf (void) const = 0;
136
  virtual int32_t GetIpMulticastIf (void) const = 0;
137
  /**
138
   * \brief Set the IP multicast loop capability
139
   *
140
   * This means that the socket will receive the packets
141
   * sent by itself on a multicast address.
142
   * Equivalent to setsockopt  IP_MULTICAST_LOOP
143
   *
144
   * \param loop the IP multicast loop capability
145
   */
108
  virtual void SetIpMulticastLoop (bool loop) = 0;
146
  virtual void SetIpMulticastLoop (bool loop) = 0;
147
  /**
148
   * \brief Get the IP multicast loop capability
149
   *
150
   * This means that the socket will receive the packets
151
   * sent by itself on a multicast address.
152
   * Equivalent to setsockopt  IP_MULTICAST_LOOP
153
   *
154
   * \returns the IP multicast loop capability
155
   */
109
  virtual bool GetIpMulticastLoop (void) const = 0;
156
  virtual bool GetIpMulticastLoop (void) const = 0;
157
  /**
158
   * \brief Set the MTU discover capability
159
   *
160
   * \param discover the MTU discover capability
161
   */
110
  virtual void SetMtuDiscover (bool discover) = 0;
162
  virtual void SetMtuDiscover (bool discover) = 0;
163
  /**
164
   * \brief Get the MTU discover capability
165
   *
166
   * \returns the MTU discover capability
167
   */
111
  virtual bool GetMtuDiscover (void) const = 0;
168
  virtual bool GetMtuDiscover (void) const = 0;
112
};
169
};
113
170
(-)a/src/network/model/socket.h (-1 / +5 lines)
 Lines 119-124    Link Here 
119
   */
119
   */
120
  static Ptr<Socket> CreateSocket (Ptr<Node> node, TypeId tid);
120
  static Ptr<Socket> CreateSocket (Ptr<Node> node, TypeId tid);
121
  /**
121
  /**
122
   * \brief Get last error number.
123
   *
122
   * \return the errno associated to the last call which failed in this
124
   * \return the errno associated to the last call which failed in this
123
   *         socket. Each socket's errno is initialized to zero
125
   *         socket. Each socket's errno is initialized to zero
124
   *         when the socket is created.
126
   *         when the socket is created.
 Lines 129-135    Link Here 
129
    */
131
    */
130
  virtual enum Socket::SocketType GetSocketType (void) const = 0;
132
  virtual enum Socket::SocketType GetSocketType (void) const = 0;
131
  /**
133
  /**
132
   * \returns the node this socket is associated with.
134
   * \brief Return the node this socket is associated with.
135
   * \returns the node
133
   */
136
   */
134
  virtual Ptr<Node> GetNode (void) const = 0;
137
  virtual Ptr<Node> GetNode (void) const = 0;
135
  /**
138
  /**
 Lines 551-556    Link Here 
551
  int RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
554
  int RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
552
                Address &fromAddress);
555
                Address &fromAddress);
553
  /**
556
  /**
557
   * \brief Get socket address.
554
   * \param address the address name this socket is associated with.
558
   * \param address the address name this socket is associated with.
555
   * \returns 0 if success, -1 otherwise
559
   * \returns 0 if success, -1 otherwise
556
   */
560
   */

Return to bug 938