fixed valgrind errors of epc-s1u tests

This commit is contained in:
Nicola Baldo
2012-01-18 17:04:01 +01:00
parent 6b6010e904
commit 60c71ef6c4
4 changed files with 27 additions and 8 deletions

View File

@@ -64,16 +64,16 @@ EpcHelper::EpcHelper ()
NS_ASSERT (retval == 0);
// create TUN device implementing tunneling of user data over GTP-U/UDP/IP
Ptr<VirtualNetDevice> tunDevice = CreateObject<VirtualNetDevice> ();
m_tunDevice = CreateObject<VirtualNetDevice> ();
// allow jumbo packets
tunDevice->SetAttribute ("Mtu", UintegerValue (30000));
m_tunDevice->SetAttribute ("Mtu", UintegerValue (30000));
// yes we need this
tunDevice->SetAddress (Mac48Address::Allocate ());
m_tunDevice->SetAddress (Mac48Address::Allocate ());
m_sgwPgw->AddDevice (tunDevice);
m_sgwPgw->AddDevice (m_tunDevice);
NetDeviceContainer tunDeviceContainer;
tunDeviceContainer.Add (tunDevice);
tunDeviceContainer.Add (m_tunDevice);
// the TUN device is on the same subnet as the UEs, so when a packet
// addressed to an UE arrives at the intenet to the WAN interface of
@@ -81,11 +81,11 @@ EpcHelper::EpcHelper ()
Ipv4InterfaceContainer tunDeviceIpv4IfContainer = m_ueAddressHelper.Assign (tunDeviceContainer);
// create EpcSgwPgwApplication
m_sgwPgwApp = CreateObject<EpcSgwPgwApplication> (tunDevice, sgwPgwS1uSocket);
m_sgwPgwApp = CreateObject<EpcSgwPgwApplication> (m_tunDevice, sgwPgwS1uSocket);
m_sgwPgw->AddApplication (m_sgwPgwApp);
// connect SgwPgwApplication and virtual net device for tunneling
tunDevice->SetSendCallback (MakeCallback (&EpcSgwPgwApplication::RecvFromTunDevice, m_sgwPgwApp));
m_tunDevice->SetSendCallback (MakeCallback (&EpcSgwPgwApplication::RecvFromTunDevice, m_sgwPgwApp));
}
@@ -119,6 +119,15 @@ EpcHelper::GetTypeId (void)
return tid;
}
void
EpcHelper::DoDispose ()
{
m_tunDevice->SetSendCallback (MakeNullCallback<bool, Ptr<Packet>, const Address&, const Address&, uint16_t> ());
m_tunDevice = 0;
m_sgwPgwApp = 0;
m_sgwPgw->Dispose ();
}
void
EpcHelper::AddEnb (Ptr<Node> enb, Ptr<NetDevice> lteEnbNetDevice)

View File

@@ -32,6 +32,7 @@ namespace ns3 {
class Node;
class NetDevice;
class VirtualNetDevice;
class EpcSgwPgwApplication;
/**
@@ -58,6 +59,7 @@ public:
// inherited from Object
static TypeId GetTypeId (void);
virtual void DoDispose ();
/**
@@ -126,8 +128,8 @@ private:
Ipv4AddressHelper m_ueAddressHelper;
Ptr<Node> m_sgwPgw;
Ptr<EpcSgwPgwApplication> m_sgwPgwApp;
Ptr<VirtualNetDevice> m_tunDevice;
DataRate m_s1uLinkDataRate;
Time m_s1uLinkDelay;

View File

@@ -85,6 +85,13 @@ EpcSgwPgwApplication::GetTypeId (void)
return tid;
}
void
EpcSgwPgwApplication::DoDispose ()
{
m_s1uSocket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
m_s1uSocket = 0;
}
EpcSgwPgwApplication::EpcSgwPgwApplication (const Ptr<VirtualNetDevice> tunDevice, const Ptr<Socket> s1uSocket)

View File

@@ -51,6 +51,7 @@ public:
// inherited from Object
static TypeId GetTypeId (void);
virtual void DoDispose ();
/**
* Constructor that binds the tap device to the callback methods.