merge with HEAD

This commit is contained in:
Mathieu Lacage
2008-04-17 15:50:49 -07:00
29 changed files with 201 additions and 143 deletions

View File

@@ -108,6 +108,11 @@ ArpL3Protocol::Receive(Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t proto
arp.GetDestinationIpv4Address () << "; we have address " <<
cache->GetInterface ()->GetAddress ());
/**
* Note: we do not update the ARP cache when we receive an ARP request
* from an unknown node. See bug #107
*/
if (arp.IsRequest () &&
arp.GetDestinationIpv4Address () == cache->GetInterface ()->GetAddress ())
{

View File

@@ -31,6 +31,7 @@
#include "tcp-typedefs.h"
#include "ns3/simulator.h"
#include "ns3/packet.h"
#include "ns3/trace-source-accessor.h"
#include <algorithm>
@@ -40,6 +41,20 @@ using namespace std;
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (TcpSocket);
TypeId
TcpSocket::GetTypeId ()
{
static TypeId tid = TypeId("ns3::TcpSocket")
.SetParent<Socket> ()
.AddTraceSource ("CongestionWindow",
"The TCP connection's congestion window",
MakeTraceSourceAccessor (&TcpSocket::m_cWnd))
;
return tid;
}
TcpSocket::TcpSocket ()
: m_skipRetxResched (false),
m_dupAckCount (0),
@@ -680,6 +695,7 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr<Packet> p,
// TCP SYN consumes one byte
m_nextRxSequence = tcpHeader.GetSequenceNumber() + SequenceNumber(1);
m_nextTxSequence = tcpHeader.GetAckNumber ();
m_firstPendingSequence = m_nextTxSequence; //bug 166
NS_LOG_DEBUG ("TcpSocket " << this << " ACK_TX_1" <<
" nextRxSeq " << m_nextRxSequence);
SendEmptyPacket (TcpHeader::ACK);
@@ -899,7 +915,7 @@ uint32_t TcpSocket::Window ()
{
NS_LOG_FUNCTION;
NS_LOG_LOGIC ("TcpSocket::Window() "<<this);
return std::min (m_rxWindowSize, m_cWnd);
return std::min (m_rxWindowSize, m_cWnd.Get());
}
uint32_t TcpSocket::AvailableWindow ()
@@ -1120,7 +1136,7 @@ void TcpSocket::NewAck (SequenceNumber seq)
}
else
{ // Congestion avoidance mode, adjust by (ackBytes*segSize) / cWnd
double adder = ((double) m_segmentSize * m_segmentSize) / m_cWnd;
double adder = ((double) m_segmentSize * m_segmentSize) / m_cWnd.Get();
if (adder < 1.0)
{
adder = 1.0;

View File

@@ -22,6 +22,7 @@
#include <stdint.h>
#include "ns3/callback.h"
#include "ns3/traced-value.h"
#include "ns3/socket.h"
#include "ns3/ptr.h"
#include "ns3/ipv4-address.h"
@@ -31,6 +32,7 @@
#include "sequence-number.h"
#include "rtt-estimator.h"
namespace ns3 {
class Ipv4EndPoint;
@@ -42,6 +44,7 @@ class TcpHeader;
class TcpSocket : public Socket
{
public:
static TypeId GetTypeId (void);
/**
* Create an unbound tcp socket.
*/
@@ -152,12 +155,12 @@ private:
SequenceNumber m_firstPendingSequence;
// Window management
uint32_t m_segmentSize; // SegmentSize
uint32_t m_rxWindowSize;
uint32_t m_advertisedWindowSize; // Window to advertise to peer
uint32_t m_cWnd; // Congestion window
uint32_t m_ssThresh; // Slow Start Threshold
uint32_t m_initialCWnd; // Initial (and reset) value for cWnd
uint32_t m_segmentSize; //SegmentSize
uint32_t m_rxWindowSize;
uint32_t m_advertisedWindowSize; //Window to advertise
TracedValue<uint32_t> m_cWnd; //Congestion window
uint32_t m_ssThresh; //Slow Start Threshold
uint32_t m_initialCWnd; //Initial cWnd value
// Round trip time estimation
Ptr<RttEstimator> m_rtt;

View File

@@ -300,14 +300,15 @@ UdpSocket::DoSendTo (Ptr<Packet> p, Ipv4Address dest, uint16_t port)
NotifyDataSent (p->GetSize ());
}
NS_LOG_LOGIC ("Limited broadcast end.");
return p->GetSize();
}
else if (ipv4->GetIfIndexForDestination(dest, localIfIndex))
{
NS_LOG_LOGIC ("Route exists");
m_udp->Send (p, ipv4->GetAddress (localIfIndex), dest,
m_udp->Send (p->Copy (), ipv4->GetAddress (localIfIndex), dest,
m_endPoint->GetLocalPort (), port);
NotifyDataSent (p->GetSize ());
return 0;
return p->GetSize();;
}
else
{
@@ -478,7 +479,7 @@ UdpSocketTest::RunTests (void)
m_receivedPacket = Create<Packet> ();
m_receivedPacket2 = Create<Packet> ();
NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("10.0.0.1"), 1234),
Create<Packet> (123)), 0);
Create<Packet> (123)), 123);
Simulator::Run ();
NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 0); // second interface should receive it
@@ -489,7 +490,7 @@ UdpSocketTest::RunTests (void)
m_receivedPacket = Create<Packet> ();
m_receivedPacket2 = Create<Packet> ();
NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("255.255.255.255"), 1234),
Create<Packet> (123)), 0);
Create<Packet> (123)), 123);
Simulator::Run ();
NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
// second socket should not receive it (it is bound specifically to the second interface's address
@@ -509,7 +510,7 @@ UdpSocketTest::RunTests (void)
m_receivedPacket = Create<Packet> ();
m_receivedPacket2 = Create<Packet> ();
NS_TEST_ASSERT_EQUAL (txSocket->SendTo (InetSocketAddress (Ipv4Address("255.255.255.255"), 1234),
Create<Packet> (123)), 0);
Create<Packet> (123)), 123);
Simulator::Run ();
NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 123);