src/internet/model/tcp-socket-base.h
changeset 7608 de67936e4017
parent 7385 10beb0e53130
child 7619 b4dee6307aa7
--- a/src/internet/model/tcp-socket-base.h	Wed Nov 30 19:16:09 2011 -0500
+++ b/src/internet/model/tcp-socket-base.h	Thu Dec 01 04:53:20 2011 -0500
@@ -1,5 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
+ * Copyright (c) 2007 Georgia Tech Research Corporation
  * Copyright (c) 2010 Adrian Sai-wah Tam
  *
  * This program is free software; you can redistribute it and/or modify
@@ -53,7 +54,7 @@
  * functions where the sliding window mechanism is handled here. This class
  * provides connection orientation and sliding window flow control. Part of
  * this class is modified from the original NS-3 TCP socket implementation
- * (TcpSocketImpl) by Raj Bhattacharjea.
+ * (TcpSocketImpl) by Raj Bhattacharjea <raj.b@gatech.edu> of Georgia Tech.
  */
 class TcpSocketBase : public TcpSocket
 {
@@ -118,7 +119,7 @@
   virtual void     SetPersistTimeout (Time timeout);
   virtual Time     GetPersistTimeout (void) const;
   virtual bool     SetAllowBroadcast (bool allowBroadcast);
-  virtual bool     GetAllowBroadcast () const;
+  virtual bool     GetAllowBroadcast (void) const;
 
   // Helper functions: Connection set up
   int SetupCallback (void);        // Common part of the two Bind(), i.e. set callback and remembering local addr:port
@@ -128,11 +129,13 @@
   void CompleteFork (Ptr<Packet>, const TcpHeader&, const Address& fromAddress, const Address& toAdress);
 
   // Helper functions: Transfer operation
-  void ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Ptr<Ipv4Interface> incomingInterface); //Get a pkt from L3
+  void ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Ptr<Ipv4Interface> incomingInterface);
+  virtual void DoForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port, Ptr<Ipv4Interface> incomingInterface); //Get a pkt from L3
   bool SendPendingData (bool withAck = false); // Send as much as the window allows
+  uint32_t SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool withAck); // Send a data packet
   void SendEmptyPacket (uint8_t flags); // Send a empty packet that carries a flag, e.g. ACK
   void SendRST (void); // Send reset and tear down this socket
-  bool OutOfRange (SequenceNumber32 s) const; // Check if a sequence number is within rx window
+  bool OutOfRange (SequenceNumber32 head, SequenceNumber32 tail) const; // Check if a sequence number range is within the rx window
 
   // Helper functions: Connection close
   int DoClose (void); // Close a socket by sending RST, FIN, or FIN+ACK, depend on the current state
@@ -142,6 +145,7 @@
   void PeerClose (Ptr<Packet>, const TcpHeader&); // Received a FIN from peer, notify rx buffer
   void DoPeerClose (void); // FIN is in sequence, notify app and respond with a FIN
   void CancelAllTimers (void); // Cancel all timer when endpoint is deleted
+  void TimeWait (void);  // Move from CLOSING or FIN_WAIT_2 to TIME_WAIT state
 
   // State transition functions
   void ProcessEstablished (Ptr<Packet>, const TcpHeader&); // Received a packet upon ESTABLISHED state
@@ -172,6 +176,8 @@
   virtual void LastAckTimeout (void); // Timeout at LAST_ACK, close the connection
   virtual void PersistTimeout (void); // Send 1 byte probe to get an updated window size
   virtual void DoRetransmit (void); // Retransmit the oldest packet
+  virtual void ReadOptions (const TcpHeader&); // Read option from incoming packets
+  virtual void AddOptions (TcpHeader&); // Add option to outgoing packets
 
 protected:
   // Counters and events
@@ -179,10 +185,12 @@
   EventId           m_lastAckEvent;    //< Last ACK timeout event
   EventId           m_delAckEvent;     //< Delayed ACK timeout event
   EventId           m_persistEvent;    //< Persist event: Send 1 byte to probe for a non-zero Rx window
+  EventId           m_timewaitEvent;   //< TIME_WAIT expiration event: Move this socket to CLOSED state
   uint32_t          m_dupAckCount;     //< Dupack counter
   uint32_t          m_delAckCount;     //< Delayed ACK counter
   uint32_t          m_delAckMaxCount;  //< Number of packet to fire an ACK before delay timeout
   uint32_t          m_cnCount;         //< Count of remaining connection retries
+  uint32_t          m_cnRetries;       //< Number of connection retries before giving up
   TracedValue<Time> m_rto;             //< Retransmit timeout
   TracedValue<Time> m_lastRtt;         //< Last RTT sample collected
   Time              m_delAckTimeout;   //< Time to delay an ACK
@@ -211,9 +219,11 @@
   bool                     m_shutdownSend;  //< Send no longer allowed
   bool                     m_shutdownRecv;  //< Receive no longer allowed
   bool                     m_connected;     //< Connection established
+  double                   m_msl;           //< Max segment lifetime
 
   // Window management
   uint32_t              m_segmentSize; //< Segment size
+  uint16_t              m_maxWinSize;  //< Maximum window size to advertise
   TracedValue<uint32_t> m_rWnd;        //< Flow control window at remote side
 };