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

(-)i/src/internet/test/tcp-error-model.cc (-1 / +1 lines)
 Lines 58-64   TcpGeneralErrorModel::DoCorrupt (Ptr<Packet> p) Link Here 
58
58
59
  bool toDrop = ShouldDrop (ipHeader, tcpHeader, p->GetSize ());
59
  bool toDrop = ShouldDrop (ipHeader, tcpHeader, p->GetSize ());
60
60
61
  if (toDrop)
61
  if (toDrop && ! m_dropCallback.IsNull ())
62
    {
62
    {
63
      m_dropCallback (ipHeader, tcpHeader, p);
63
      m_dropCallback (ipHeader, tcpHeader, p);
64
    }
64
    }
(-)i/src/internet/test/tcp-general-test.cc (+17 lines)
 Lines 597-602   TcpGeneralTest::GetSegSize (SocketWho who) Link Here 
597
    }
597
    }
598
}
598
}
599
599
600
SequenceNumber32
601
TcpGeneralTest::GetHighestTxMark (SocketWho who)
602
{
603
  if (who == SENDER)
604
    {
605
      return DynamicCast<TcpSocketMsgBase> (m_senderSocket)->m_highTxMark;
606
    }
607
  else if (who == RECEIVER)
608
    {
609
      return DynamicCast<TcpSocketMsgBase> (m_receiverSocket)->m_highTxMark;
610
    }
611
  else
612
    {
613
      NS_FATAL_ERROR ("Not defined");
614
    }
615
}
616
600
uint32_t
617
uint32_t
601
TcpGeneralTest::GetInitialCwnd (SocketWho who)
618
TcpGeneralTest::GetInitialCwnd (SocketWho who)
602
{
619
{
(-)i/src/internet/test/tcp-general-test.h (+9 lines)
 Lines 362-367   protected: Link Here 
362
  uint32_t GetSegSize (SocketWho who);
362
  uint32_t GetSegSize (SocketWho who);
363
363
364
  /**
364
  /**
365
   * \brief Get the highest tx mark of the node specified
366
   *
367
   * \param who node to get the parameter from
368
   *
369
   * \return mark of the specified node
370
   */
371
  SequenceNumber32 GetHighestTxMark (SocketWho who);
372
373
  /**
365
   * \brief Get the retransmission threshold
374
   * \brief Get the retransmission threshold
366
   * \param who node to get the parameter from
375
   * \param who node to get the parameter from
367
   * \return retransmission threshold
376
   * \return retransmission threshold
(-)i/src/internet/test/tcp-rtt-estimation.cc (-5 / +95 lines)
 Lines 57-62   private: Link Here 
57
  bool m_rttChanged;
57
  bool m_rttChanged;
58
  SequenceNumber32 m_highestTxSeq;
58
  SequenceNumber32 m_highestTxSeq;
59
  uint32_t m_pktCount;
59
  uint32_t m_pktCount;
60
  uint32_t m_dataCount;
60
};
61
};
61
62
62
TcpRttEstimationTest::TcpRttEstimationTest (const std::string &desc, bool enableTs,
63
TcpRttEstimationTest::TcpRttEstimationTest (const std::string &desc, bool enableTs,
 Lines 65-71   TcpRttEstimationTest::TcpRttEstimationTest (const std::string &desc, bool enable Link Here 
65
    m_enableTs (enableTs),
66
    m_enableTs (enableTs),
66
    m_rttChanged (false),
67
    m_rttChanged (false),
67
    m_highestTxSeq (0),
68
    m_highestTxSeq (0),
68
    m_pktCount (pktCount)
69
    m_pktCount (pktCount),
70
    m_dataCount (0)
69
{
71
{
70
}
72
}
71
73
 Lines 111-121   TcpRttEstimationTest::Tx (const Ptr<const Packet> p, const TcpHeader &h, SocketW Link Here 
111
      if (m_highestTxSeq < h.GetSequenceNumber ())
113
      if (m_highestTxSeq < h.GetSequenceNumber ())
112
        {
114
        {
113
          m_highestTxSeq = h.GetSequenceNumber ();
115
          m_highestTxSeq = h.GetSequenceNumber ();
116
          m_dataCount = 0;
114
        }
117
        }
115
118
116
      Ptr<RttEstimator> rttEstimator = GetRttEstimator (SENDER);
119
      Ptr<RttEstimator> rttEstimator = GetRttEstimator (SENDER);
117
      NS_ASSERT (rttEstimator != 0);
120
      NS_ASSERT (rttEstimator != 0);
118
      NS_LOG_DEBUG ("S Rx: seq=" << h.GetSequenceNumber () << " ack=" << h.GetAckNumber ());
121
      NS_LOG_DEBUG ("S Tx: seq=" << h.GetSequenceNumber () << " ack=" << h.GetAckNumber ());
119
      NS_TEST_ASSERT_MSG_NE (rttEstimator->GetEstimate (), Seconds (1),
122
      NS_TEST_ASSERT_MSG_NE (rttEstimator->GetEstimate (), Seconds (1),
120
                             "Default Estimate for the RTT");
123
                             "Default Estimate for the RTT");
121
    }
124
    }
 Lines 134-156   void Link Here 
134
TcpRttEstimationTest::UpdatedRttHistory (const SequenceNumber32 & seq, uint32_t sz,
137
TcpRttEstimationTest::UpdatedRttHistory (const SequenceNumber32 & seq, uint32_t sz,
135
                                         bool isRetransmission, SocketWho who)
138
                                         bool isRetransmission, SocketWho who)
136
{
139
{
140
  if (sz == 0)
141
    {
142
      return;
143
    }
144
137
  if (seq < m_highestTxSeq)
145
  if (seq < m_highestTxSeq)
138
    {
146
    {
139
      NS_TEST_ASSERT_MSG_EQ (isRetransmission, true,
147
      NS_TEST_ASSERT_MSG_EQ (isRetransmission, true,
140
                             "A retransmission is not flagged as such");
148
                             "A retransmission is not flagged as such");
141
    }
149
    }
142
  else
150
  else if (seq == m_highestTxSeq && m_dataCount == 0)
143
    {
151
    {
144
      NS_TEST_ASSERT_MSG_EQ (isRetransmission, false,
152
      NS_TEST_ASSERT_MSG_EQ (isRetransmission, false,
145
                             "Incorrectly flagging seq as retransmission");
153
                             "Incorrectly flagging seq as retransmission");
154
      m_dataCount++;
155
    }
156
  else if (seq == m_highestTxSeq && m_dataCount > 0)
157
    {
158
      NS_TEST_ASSERT_MSG_EQ (isRetransmission, true,
159
                             "A retransmission is not flagged as such");
146
    }
160
    }
147
148
}
161
}
149
162
150
void
163
void
151
TcpRttEstimationTest::RttTrace (Time oldTime, Time newTime)
164
TcpRttEstimationTest::RttTrace (Time oldTime, Time newTime)
152
{
165
{
153
  NS_LOG_DEBUG ("Rtt changed to " << newTime);
166
  NS_LOG_DEBUG ("Rtt changed to " << newTime.GetSeconds ());
154
  m_rttChanged = true;
167
  m_rttChanged = true;
155
}
168
}
156
169
 Lines 161-166   TcpRttEstimationTest::FinalChecks () Link Here 
161
}
174
}
162
175
163
//-----------------------------------------------------------------------------
176
//-----------------------------------------------------------------------------
177
class TcpRttEstimationWithLossTest : public TcpRttEstimationTest
178
{
179
public:
180
  TcpRttEstimationWithLossTest (const std::string &desc, bool enableTs,
181
                                uint32_t pktCount, std::vector<uint32_t> toDrop);
182
183
protected:
184
  Ptr<ErrorModel> CreateReceiverErrorModel ();
185
186
private:
187
  std::vector<uint32_t> m_toDrop;
188
};
189
190
TcpRttEstimationWithLossTest::TcpRttEstimationWithLossTest (const std::string &desc,
191
                                                            bool enableTs,
192
                                                            uint32_t pktCount,
193
                                                            std::vector<uint32_t> toDrop)
194
  : TcpRttEstimationTest (desc, enableTs, pktCount),
195
    m_toDrop (toDrop)
196
{
197
198
}
199
200
Ptr<ErrorModel>
201
TcpRttEstimationWithLossTest::CreateReceiverErrorModel ()
202
{
203
  Ptr<TcpSeqErrorModel> errorModel = CreateObject<TcpSeqErrorModel> ();
204
205
  std::vector<uint32_t>::iterator it;
206
207
  for (it = m_toDrop.begin (); it != m_toDrop.end (); ++it)
208
    {
209
      errorModel->AddSeqToKill (SequenceNumber32 ((*it)));
210
    }
211
212
  return errorModel;
213
}
214
215
//-----------------------------------------------------------------------------
164
216
165
static class TcpRttEstimationTestSuite : public TestSuite
217
static class TcpRttEstimationTestSuite : public TestSuite
166
{
218
{
 Lines 175-181   public: Link Here 
175
                 TestCase::QUICK);
227
                 TestCase::QUICK);
176
    AddTestCase (new TcpRttEstimationTest ("RTT estimation, no ts, some data", false, 10),
228
    AddTestCase (new TcpRttEstimationTest ("RTT estimation, no ts, some data", false, 10),
177
                 TestCase::QUICK);
229
                 TestCase::QUICK);
230
231
    std::vector<uint32_t> toDrop;
232
    toDrop.push_back (501);
233
234
    AddTestCase (new TcpRttEstimationWithLossTest ("RTT estimation, no ts,"
235
                                                   " some data, with retr",
236
                                                   false, 10, toDrop),
237
                 TestCase::QUICK);
238
    AddTestCase (new TcpRttEstimationWithLossTest ("RTT estimation, ts,"
239
                                                   " some data, with retr",
240
                                                   true, 10, toDrop),
241
                 TestCase::QUICK);
242
243
    toDrop.push_back (501);
244
    AddTestCase (new TcpRttEstimationWithLossTest ("RTT estimation, no ts,"
245
                                                   " some data, with retr",
246
                                                   false, 10, toDrop),
247
                 TestCase::QUICK);
248
    AddTestCase (new TcpRttEstimationWithLossTest ("RTT estimation, ts,"
249
                                                   " some data, with retr",
250
                                                   true, 10, toDrop),
251
                 TestCase::QUICK);
252
253
    toDrop.push_back (54001);
254
    toDrop.push_back (58001);
255
    toDrop.push_back (58501);
256
    toDrop.push_back (60001);
257
    toDrop.push_back (68501);
258
    AddTestCase (new TcpRttEstimationWithLossTest ("RTT estimation, no ts,"
259
                                                   " a lot of data, with retr",
260
                                                   false, 1000, toDrop),
261
                 TestCase::QUICK);
262
    AddTestCase (new TcpRttEstimationWithLossTest ("RTT estimation, ts,"
263
                                                   " a lot of data, with retr",
264
                                                   true, 1000, toDrop),
265
                 TestCase::QUICK);
178
  }
266
  }
267
179
} g_tcpRttEstimationTestSuite;
268
} g_tcpRttEstimationTestSuite;
180
269
181
} // namespace ns3
270
} // namespace ns3
271

Return to bug 2302