merge
This commit is contained in:
@@ -14,8 +14,7 @@ static void
|
||||
GenerateTraffic (Ptr<Socket> socket, uint32_t size)
|
||||
{
|
||||
std::cout << "at=" << Simulator::Now ().GetSeconds () << "s, tx bytes=" << size << std::endl;
|
||||
Packet p(size);
|
||||
socket->Send (p);
|
||||
socket->Send (Packet (size));
|
||||
if (size > 0)
|
||||
{
|
||||
Simulator::Schedule (Seconds (0.5), &GenerateTraffic, socket, size - 50);
|
||||
|
||||
@@ -206,8 +206,7 @@ void OnOffApplication::ScheduleStopEvent()
|
||||
void OnOffApplication::SendPacket()
|
||||
{
|
||||
NS_ASSERT (m_sendEvent.IsExpired ());
|
||||
Packet p(m_pktSize);
|
||||
m_socket->Send(p);
|
||||
m_socket->Send(Packet (m_pktSize));
|
||||
m_totBytes += m_pktSize;
|
||||
m_lastStartTime = Simulator::Now();
|
||||
m_residualBits = 0;
|
||||
|
||||
@@ -274,12 +274,13 @@ CsmaNetDevice::DoNeedsArp (void) const
|
||||
|
||||
bool
|
||||
CsmaNetDevice::SendTo (
|
||||
Packet& packet,
|
||||
const Packet& packet,
|
||||
const Address& dest,
|
||||
uint16_t protocolNumber)
|
||||
{
|
||||
NS_DEBUG ("CsmaNetDevice::SendTo (" << &packet << ")");
|
||||
NS_DEBUG ("CsmaNetDevice::SendTo (): UID is " << packet.GetUid () << ")");
|
||||
Packet p = packet;
|
||||
NS_DEBUG ("CsmaNetDevice::SendTo (" << &p << ")");
|
||||
NS_DEBUG ("CsmaNetDevice::SendTo (): UID is " << p.GetUid () << ")");
|
||||
|
||||
NS_ASSERT (IsLinkUp ());
|
||||
|
||||
@@ -288,10 +289,10 @@ CsmaNetDevice::SendTo (
|
||||
return false;
|
||||
|
||||
Eui48Address destination = Eui48Address::ConvertFrom (dest);
|
||||
AddHeader(packet, destination, protocolNumber);
|
||||
AddHeader(p, destination, protocolNumber);
|
||||
|
||||
// Place the packet to be sent on the send queue
|
||||
if (m_queue->Enqueue(packet) == false )
|
||||
if (m_queue->Enqueue(p) == false )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -300,10 +301,11 @@ CsmaNetDevice::SendTo (
|
||||
// transmission (see TransmitCompleteEvent)
|
||||
if (m_txMachineState == READY)
|
||||
{
|
||||
if (m_queue->IsEmpty()) return true; // Nothing else to do
|
||||
// Store the next packet to be transmitted
|
||||
m_currentPkt = m_queue->Dequeue();
|
||||
TransmitStart();
|
||||
if (m_queue->Dequeue (m_currentPkt))
|
||||
{
|
||||
TransmitStart();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -387,8 +389,9 @@ CsmaNetDevice::TransmitAbort (void)
|
||||
m_currentPkt.GetUid () << ")");
|
||||
|
||||
// Try to transmit a new packet
|
||||
if (m_queue->IsEmpty()) return; //No packet to transmit
|
||||
m_currentPkt = m_queue->Dequeue ();
|
||||
bool found;
|
||||
found = m_queue->Dequeue (m_currentPkt);
|
||||
NS_ASSERT_MSG(found, "IsEmpty false but no Packet on queue?");
|
||||
m_backoff.ResetBackoffTime();
|
||||
m_txMachineState = READY;
|
||||
TransmitStart ();
|
||||
@@ -435,10 +438,18 @@ CsmaNetDevice::TransmitReadyEvent (void)
|
||||
NS_ASSERT_MSG(m_txMachineState == GAP, "Must be in interframe gap");
|
||||
m_txMachineState = READY;
|
||||
|
||||
if (m_queue->IsEmpty()) return; // No more to transmit, remain ready
|
||||
// Get the next packet from the queue for transmitting
|
||||
m_currentPkt = m_queue->Dequeue ();
|
||||
TransmitStart ();
|
||||
if (m_queue->IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool found;
|
||||
found = m_queue->Dequeue (m_currentPkt);
|
||||
NS_ASSERT_MSG(found, "IsEmpty false but no Packet on queue?");
|
||||
TransmitStart ();
|
||||
}
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
@@ -484,31 +495,32 @@ CsmaNetDevice::AddQueue (Ptr<Queue> q)
|
||||
}
|
||||
|
||||
void
|
||||
CsmaNetDevice::Receive (Packet& packet)
|
||||
CsmaNetDevice::Receive (const Packet& packet)
|
||||
{
|
||||
EthernetHeader header (false);
|
||||
EthernetTrailer trailer;
|
||||
Eui48Address broadcast;
|
||||
Eui48Address destination;
|
||||
Packet p = packet;
|
||||
|
||||
NS_DEBUG ("CsmaNetDevice::Receive UID is (" << packet.GetUid() << ")");
|
||||
NS_DEBUG ("CsmaNetDevice::Receive UID is (" << p.GetUid() << ")");
|
||||
|
||||
// Only receive if send side of net device is enabled
|
||||
if (!IsReceiveEnabled())
|
||||
{
|
||||
m_dropTrace (packet);
|
||||
m_dropTrace (p);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_encapMode == RAW)
|
||||
{
|
||||
ForwardUp (packet, 0, GetBroadcast ());
|
||||
//m_dropTrace (packet);
|
||||
m_dropTrace (p);
|
||||
return;
|
||||
}
|
||||
packet.RemoveTrailer(trailer);
|
||||
trailer.CheckFcs(packet);
|
||||
packet.RemoveHeader(header);
|
||||
p.RemoveTrailer(trailer);
|
||||
trailer.CheckFcs(p);
|
||||
p.RemoveHeader(header);
|
||||
|
||||
broadcast = Eui48Address::ConvertFrom (GetBroadcast ());
|
||||
destination = Eui48Address::ConvertFrom (GetAddress ());
|
||||
@@ -516,11 +528,11 @@ CsmaNetDevice::Receive (Packet& packet)
|
||||
(header.GetDestination() != destination))
|
||||
{
|
||||
// not for us.
|
||||
m_dropTrace (packet);
|
||||
m_dropTrace (p);
|
||||
return;
|
||||
}
|
||||
|
||||
m_rxTrace (packet);
|
||||
m_rxTrace (p);
|
||||
//
|
||||
// protocol must be initialized to avoid a compiler warning in the RAW
|
||||
// case that breaks the optimized build.
|
||||
@@ -535,7 +547,7 @@ CsmaNetDevice::Receive (Packet& packet)
|
||||
break;
|
||||
case LLC: {
|
||||
LlcSnapHeader llc;
|
||||
packet.RemoveHeader (llc);
|
||||
p.RemoveHeader (llc);
|
||||
protocol = llc.GetType ();
|
||||
} break;
|
||||
case RAW:
|
||||
@@ -543,7 +555,7 @@ CsmaNetDevice::Receive (Packet& packet)
|
||||
break;
|
||||
}
|
||||
|
||||
ForwardUp (packet, protocol, header.GetSource ());
|
||||
ForwardUp (p, protocol, header.GetSource ());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ enum CsmaEncapsulationMode {
|
||||
* @see CsmaChannel
|
||||
* \param p a reference to the received packet
|
||||
*/
|
||||
void Receive (Packet& p);
|
||||
void Receive (const Packet& p);
|
||||
|
||||
bool IsSendEnabled (void);
|
||||
bool IsReceiveEnabled (void);
|
||||
@@ -270,7 +270,7 @@ private:
|
||||
* \param protocolNumber -- this parameter is not used here
|
||||
* \return true if success, false on failure
|
||||
*/
|
||||
virtual bool SendTo (Packet& p, const Address& dest, uint16_t protocolNumber);
|
||||
virtual bool SendTo (const Packet& p, const Address& dest, uint16_t protocolNumber);
|
||||
|
||||
/**
|
||||
* Start Sending a Packet Down the Wire.
|
||||
|
||||
@@ -117,17 +117,18 @@ void PointToPointNetDevice::SetInterframeGap(const Time& t)
|
||||
m_tInterframeGap = t;
|
||||
}
|
||||
|
||||
bool PointToPointNetDevice::SendTo (Packet& packet, const Address& dest,
|
||||
bool PointToPointNetDevice::SendTo (const Packet& packet, const Address& dest,
|
||||
uint16_t protocolNumber)
|
||||
{
|
||||
NS_DEBUG ("PointToPointNetDevice::SendTo (" << &packet << ", " << &dest << ")");
|
||||
NS_DEBUG ("PointToPointNetDevice::SendTo (): UID is " << packet.GetUid () << ")");
|
||||
Packet p = packet;
|
||||
NS_DEBUG ("PointToPointNetDevice::SendTo (" << &p << ", " << &dest << ")");
|
||||
NS_DEBUG ("PointToPointNetDevice::SendTo (): UID is " << p.GetUid () << ")");
|
||||
|
||||
// GFR Comment. Why is this an assertion? Can't a link legitimately
|
||||
// "go down" during the simulation? Shouldn't we just wait for it
|
||||
// to come back up?
|
||||
NS_ASSERT (IsLinkUp ());
|
||||
AddHeader(packet, protocolNumber);
|
||||
AddHeader(p, protocolNumber);
|
||||
|
||||
//
|
||||
// This class simulates a point to point device. In the case of a serial
|
||||
@@ -138,16 +139,16 @@ bool PointToPointNetDevice::SendTo (Packet& packet, const Address& dest,
|
||||
// trnsmission; otherwise we send it now.
|
||||
if (m_txMachineState == READY)
|
||||
{
|
||||
return TransmitStart (packet);
|
||||
return TransmitStart (p);
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_queue->Enqueue(packet);
|
||||
return m_queue->Enqueue(p);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
PointToPointNetDevice::TransmitStart (Packet& p)
|
||||
PointToPointNetDevice::TransmitStart (Packet &p)
|
||||
{
|
||||
NS_DEBUG ("PointToPointNetDevice::TransmitStart (" << &p << ")");
|
||||
NS_DEBUG (
|
||||
@@ -183,8 +184,8 @@ void PointToPointNetDevice::TransmitComplete (void)
|
||||
//
|
||||
NS_ASSERT_MSG(m_txMachineState == BUSY, "Must be BUSY if transmitting");
|
||||
m_txMachineState = READY;
|
||||
if (m_queue->IsEmpty()) return; // Nothing to do at this point
|
||||
Packet p = m_queue->Dequeue();
|
||||
Packet p;
|
||||
if (!m_queue->Dequeue(p)) return; // Nothing to do at this point
|
||||
TransmitStart(p);
|
||||
}
|
||||
|
||||
@@ -235,9 +236,11 @@ void PointToPointNetDevice::Receive (Packet& p)
|
||||
{
|
||||
NS_DEBUG ("PointToPointNetDevice::Receive (" << &p << ")");
|
||||
uint16_t protocol = 0;
|
||||
m_rxTrace (p);
|
||||
ProcessHeader(p, protocol);
|
||||
ForwardUp (p, protocol, GetBroadcast ());
|
||||
Packet packet = p;
|
||||
|
||||
m_rxTrace (packet);
|
||||
ProcessHeader(packet, protocol);
|
||||
ForwardUp (packet, protocol, GetBroadcast ());
|
||||
}
|
||||
|
||||
Ptr<Queue> PointToPointNetDevice::GetQueue(void) const
|
||||
|
||||
@@ -211,7 +211,7 @@ private:
|
||||
* @param protocolNumber Protocol Number used to find protocol touse
|
||||
* @returns true if success, false on failure
|
||||
*/
|
||||
virtual bool SendTo (Packet& p, const Address& dest,
|
||||
virtual bool SendTo (const Packet& p, const Address& dest,
|
||||
uint16_t protocolNumber);
|
||||
/**
|
||||
* Start Sending a Packet Down the Wire.
|
||||
|
||||
@@ -84,11 +84,12 @@ ArpL3Protocol::FindCache (Ptr<NetDevice> device)
|
||||
}
|
||||
|
||||
void
|
||||
ArpL3Protocol::Receive(Ptr<NetDevice> device, Packet& p, uint16_t protocol, const Address &from)
|
||||
ArpL3Protocol::Receive(Ptr<NetDevice> device, const Packet& p, uint16_t protocol, const Address &from)
|
||||
{
|
||||
ArpCache *cache = FindCache (device);
|
||||
ArpHeader arp;
|
||||
p.RemoveHeader (arp);
|
||||
Packet packet = p;
|
||||
packet.RemoveHeader (arp);
|
||||
|
||||
NS_DEBUG ("ARP: received "<< (arp.IsRequest ()? "request" : "reply") <<
|
||||
" node="<<m_node->GetId ()<<", got request from " <<
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
/**
|
||||
* \brief Recieve a packet
|
||||
*/
|
||||
void Receive(Ptr<NetDevice> device, Packet& p, uint16_t protocol, const Address &from);
|
||||
void Receive(Ptr<NetDevice> device, const Packet& p, uint16_t protocol, const Address &from);
|
||||
/**
|
||||
* \brief Perform an ARP lookup
|
||||
* \param p
|
||||
|
||||
@@ -65,7 +65,7 @@ Ipv4EndPoint::SetPeer (Ipv4Address address, uint16_t port)
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4EndPoint::SetRxCallback (Callback<void, Packet&, Ipv4Address, uint16_t> callback)
|
||||
Ipv4EndPoint::SetRxCallback (Callback<void,const Packet &, Ipv4Address, uint16_t> callback)
|
||||
{
|
||||
m_rxCallback = callback;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ Ipv4EndPoint::SetDestroyCallback (Callback<void> callback)
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4EndPoint::ForwardUp (Packet &p, Ipv4Address saddr, uint16_t sport)
|
||||
Ipv4EndPoint::ForwardUp (const Packet &p, Ipv4Address saddr, uint16_t sport)
|
||||
{
|
||||
if (!m_rxCallback.IsNull ())
|
||||
{
|
||||
|
||||
@@ -43,17 +43,17 @@ public:
|
||||
|
||||
void SetPeer (Ipv4Address address, uint16_t port);
|
||||
|
||||
void SetRxCallback (Callback<void, Packet&, Ipv4Address, uint16_t> callback);
|
||||
void SetRxCallback (Callback<void,const Packet &, Ipv4Address, uint16_t> callback);
|
||||
void SetDestroyCallback (Callback<void> callback);
|
||||
|
||||
void ForwardUp (Packet &p, Ipv4Address saddr, uint16_t sport);
|
||||
void ForwardUp (const Packet &p, Ipv4Address saddr, uint16_t sport);
|
||||
|
||||
private:
|
||||
Ipv4Address m_localAddr;
|
||||
uint16_t m_localPort;
|
||||
Ipv4Address m_peerAddr;
|
||||
uint16_t m_peerPort;
|
||||
Callback<void, Packet&, Ipv4Address, uint16_t> m_rxCallback;
|
||||
Callback<void,const Packet &, Ipv4Address, uint16_t> m_rxCallback;
|
||||
Callback<void> m_destroyCallback;
|
||||
};
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ Ipv4L3Protocol::SetDefaultRoute (Ipv4Address nextHop,
|
||||
|
||||
void
|
||||
Ipv4L3Protocol::Lookup (Ipv4Header const &ipHeader,
|
||||
Packet& packet,
|
||||
Packet packet,
|
||||
Ipv4RoutingProtocol::RouteReplyCallback routeReply)
|
||||
{
|
||||
for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin ();
|
||||
@@ -310,7 +310,7 @@ Ipv4L3Protocol::FindInterfaceForDevice (Ptr<const NetDevice> device)
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Packet& p, uint16_t protocol, const Address &from)
|
||||
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, const Packet& p, uint16_t protocol, const Address &from)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
|
||||
@@ -322,25 +322,26 @@ Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Packet& p, uint16_t protocol, co
|
||||
}
|
||||
index++;
|
||||
}
|
||||
Packet packet = p;
|
||||
Ipv4Header ipHeader;
|
||||
p.RemoveHeader (ipHeader);
|
||||
packet.RemoveHeader (ipHeader);
|
||||
|
||||
if (!ipHeader.IsChecksumOk ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Forwarding (p, ipHeader, device))
|
||||
if (Forwarding (packet, ipHeader, device))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ForwardUp (p, ipHeader);
|
||||
ForwardUp (packet, ipHeader);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Ipv4L3Protocol::Send (Packet& packet,
|
||||
Ipv4L3Protocol::Send (Packet const &packet,
|
||||
Ipv4Address source,
|
||||
Ipv4Address destination,
|
||||
uint8_t protocol)
|
||||
@@ -364,10 +365,12 @@ Ipv4L3Protocol::Send (Packet& packet,
|
||||
ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++)
|
||||
{
|
||||
Ipv4Interface *outInterface = *ifaceIter;
|
||||
NS_ASSERT (packet.GetSize () <= outInterface->GetMtu ());
|
||||
packet.AddHeader (ipHeader);
|
||||
m_txTrace (packet, ifaceIndex);
|
||||
outInterface->Send (packet, destination);
|
||||
Packet packetCopy = packet;
|
||||
|
||||
NS_ASSERT (packetCopy.GetSize () <= outInterface->GetMtu ());
|
||||
packetCopy.AddHeader (ipHeader);
|
||||
m_txTrace (packetCopy, ifaceIndex);
|
||||
outInterface->Send (packetCopy, destination);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -388,7 +391,7 @@ Ipv4L3Protocol::Send (Packet& packet,
|
||||
void
|
||||
Ipv4L3Protocol::SendRealOut (bool found,
|
||||
Ipv4Route const &route,
|
||||
Packet& packet,
|
||||
Packet packet,
|
||||
Ipv4Header const &ipHeader)
|
||||
{
|
||||
if (!found)
|
||||
@@ -413,7 +416,7 @@ Ipv4L3Protocol::SendRealOut (bool found,
|
||||
|
||||
|
||||
bool
|
||||
Ipv4L3Protocol::Forwarding (Packet& packet, Ipv4Header &ipHeader, Ptr<NetDevice> device)
|
||||
Ipv4L3Protocol::Forwarding (Packet const &packet, Ipv4Header &ipHeader, Ptr<NetDevice> device)
|
||||
{
|
||||
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();
|
||||
i != m_interfaces.end (); i++)
|
||||
@@ -468,7 +471,7 @@ Ipv4L3Protocol::Forwarding (Packet& packet, Ipv4Header &ipHeader, Ptr<NetDevice>
|
||||
|
||||
|
||||
void
|
||||
Ipv4L3Protocol::ForwardUp (Packet& p, Ipv4Header const&ip)
|
||||
Ipv4L3Protocol::ForwardUp (Packet p, Ipv4Header const&ip)
|
||||
{
|
||||
Ptr<Ipv4L4Demux> demux = m_node->QueryInterface<Ipv4L4Demux> (Ipv4L4Demux::iid);
|
||||
Ptr<Ipv4L4Protocol> protocol = demux->GetProtocol (ip.GetProtocol ());
|
||||
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
* - implement a per-NetDevice ARP cache
|
||||
* - send back arp replies on the right device
|
||||
*/
|
||||
void Receive( Ptr<NetDevice> device, Packet& p, uint16_t protocol, const Address &from);
|
||||
void Receive( Ptr<NetDevice> device, const Packet& p, uint16_t protocol, const Address &from);
|
||||
|
||||
/**
|
||||
* \param packet packet to send
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
* Higher-level layers call this method to send a packet
|
||||
* down the stack to the MAC and PHY layers.
|
||||
*/
|
||||
void Send (Packet& packet, Ipv4Address source,
|
||||
void Send (Packet const &packet, Ipv4Address source,
|
||||
Ipv4Address destination, uint8_t protocol);
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
uint32_t interface);
|
||||
|
||||
void Lookup (Ipv4Header const &ipHeader,
|
||||
Packet& packet,
|
||||
Packet packet,
|
||||
Ipv4RoutingProtocol::RouteReplyCallback routeReply);
|
||||
|
||||
uint32_t GetNRoutes (void);
|
||||
@@ -183,10 +183,10 @@ private:
|
||||
|
||||
void SendRealOut (bool found,
|
||||
Ipv4Route const &route,
|
||||
Packet& packet,
|
||||
Packet packet,
|
||||
Ipv4Header const &ipHeader);
|
||||
bool Forwarding (Packet& packet, Ipv4Header &ipHeader, Ptr<NetDevice> device);
|
||||
void ForwardUp (Packet& p, Ipv4Header const&ip);
|
||||
bool Forwarding (Packet const &packet, Ipv4Header &ipHeader, Ptr<NetDevice> device);
|
||||
void ForwardUp (Packet p, Ipv4Header const&ip);
|
||||
uint32_t AddIpv4Interface (Ipv4Interface *interface);
|
||||
void SetupLoopback (void);
|
||||
TraceResolver *InterfacesCreateTraceResolver (TraceContext const &context) const;
|
||||
|
||||
@@ -210,7 +210,7 @@ Ipv4StaticRouting::RemoveRoute (uint32_t index)
|
||||
|
||||
bool
|
||||
Ipv4StaticRouting::RequestRoute (Ipv4Header const &ipHeader,
|
||||
Packet& packet,
|
||||
Packet packet,
|
||||
RouteReplyCallback routeReply)
|
||||
{
|
||||
Ipv4Route *route = LookupStatic (ipHeader.GetDestination ());
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
Ipv4StaticRouting () : m_defaultRoute (0) {}
|
||||
|
||||
virtual bool RequestRoute (Ipv4Header const &ipHeader,
|
||||
Packet& packet,
|
||||
Packet packet,
|
||||
RouteReplyCallback routeReply);
|
||||
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ UdpL4Protocol::Receive(Packet& packet,
|
||||
}
|
||||
|
||||
void
|
||||
UdpL4Protocol::Send (Packet& packet,
|
||||
UdpL4Protocol::Send (Packet packet,
|
||||
Ipv4Address saddr, Ipv4Address daddr,
|
||||
uint16_t sport, uint16_t dport)
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
* \param sport The source port number
|
||||
* \param dport The destination port number
|
||||
*/
|
||||
void Send (Packet& packet,
|
||||
void Send (Packet packet,
|
||||
Ipv4Address saddr, Ipv4Address daddr,
|
||||
uint16_t sport, uint16_t dport);
|
||||
/**
|
||||
|
||||
@@ -155,7 +155,7 @@ UdpSocket::Connect(const Address & address)
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
UdpSocket::Send (Packet &p)
|
||||
UdpSocket::Send (const Packet &p)
|
||||
{
|
||||
if (!m_connected)
|
||||
{
|
||||
@@ -165,7 +165,7 @@ UdpSocket::Send (Packet &p)
|
||||
return DoSendTo (p, m_defaultAddress, m_defaultPort);
|
||||
}
|
||||
int
|
||||
UdpSocket::DoSendTo (Packet &p, const Address &address)
|
||||
UdpSocket::DoSendTo (const Packet &p, const Address &address)
|
||||
{
|
||||
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
|
||||
Ipv4Address ipv4 = transport.GetIpv4 ();
|
||||
@@ -173,7 +173,7 @@ UdpSocket::DoSendTo (Packet &p, const Address &address)
|
||||
return DoSendTo (p, ipv4, port);
|
||||
}
|
||||
int
|
||||
UdpSocket::DoSendTo (Packet& p, Ipv4Address ipv4, uint16_t port)
|
||||
UdpSocket::DoSendTo (const Packet &p, Ipv4Address ipv4, uint16_t port)
|
||||
{
|
||||
if (m_endPoint == 0)
|
||||
{
|
||||
@@ -195,7 +195,7 @@ UdpSocket::DoSendTo (Packet& p, Ipv4Address ipv4, uint16_t port)
|
||||
return 0;
|
||||
}
|
||||
int
|
||||
UdpSocket::SendTo(const Address &address, Packet &p)
|
||||
UdpSocket::SendTo(const Address &address, const Packet &p)
|
||||
{
|
||||
if (m_connected)
|
||||
{
|
||||
@@ -209,7 +209,7 @@ UdpSocket::SendTo(const Address &address, Packet &p)
|
||||
}
|
||||
|
||||
void
|
||||
UdpSocket::ForwardUp (Packet &packet, Ipv4Address ipv4, uint16_t port)
|
||||
UdpSocket::ForwardUp (const Packet &packet, Ipv4Address ipv4, uint16_t port)
|
||||
{
|
||||
if (m_shutdownRecv)
|
||||
{
|
||||
@@ -217,7 +217,8 @@ UdpSocket::ForwardUp (Packet &packet, Ipv4Address ipv4, uint16_t port)
|
||||
}
|
||||
|
||||
Address address = InetSocketAddress (ipv4, port);
|
||||
NotifyDataReceived (packet, address);
|
||||
Packet p = packet;
|
||||
NotifyDataReceived (p, address);
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -51,8 +51,8 @@ public:
|
||||
virtual int ShutdownSend (void);
|
||||
virtual int ShutdownRecv (void);
|
||||
virtual int Connect(const Address &address);
|
||||
virtual int Send (Packet &p);
|
||||
virtual int SendTo(const Address &address,Packet &p);
|
||||
virtual int Send (const Packet &p);
|
||||
virtual int SendTo(const Address &address,const Packet &p);
|
||||
|
||||
private:
|
||||
|
||||
@@ -60,10 +60,10 @@ private:
|
||||
friend class Udp;
|
||||
// invoked by Udp class
|
||||
int FinishBind (void);
|
||||
void ForwardUp (Packet &p, Ipv4Address ipv4, uint16_t port);
|
||||
void ForwardUp (const Packet &p, Ipv4Address ipv4, uint16_t port);
|
||||
void Destroy (void);
|
||||
int DoSendTo (Packet &p, const Address &daddr);
|
||||
int DoSendTo (Packet &p, Ipv4Address daddr, uint16_t dport);
|
||||
int DoSendTo (const Packet &p, const Address &daddr);
|
||||
int DoSendTo (const Packet &p, Ipv4Address daddr, uint16_t dport);
|
||||
|
||||
Ipv4EndPoint *m_endPoint;
|
||||
Ptr<Node> m_node;
|
||||
|
||||
@@ -73,26 +73,39 @@ DropTailQueue::DoEnqueue (const Packet& p)
|
||||
return true;
|
||||
}
|
||||
|
||||
Packet
|
||||
DropTailQueue::DoDequeue ()
|
||||
bool
|
||||
DropTailQueue::DoDequeue (Packet& p)
|
||||
{
|
||||
NS_DEBUG("DropTailQueue::DoDequeue ( )");
|
||||
NS_ASSERT(!IsEmpty());
|
||||
Packet p = m_packets.front ();
|
||||
NS_DEBUG("DropTailQueue::DoDequeue (" << &p << ")");
|
||||
|
||||
if (m_packets.empty())
|
||||
{
|
||||
NS_DEBUG("DropTailQueue::DoDequeue (): Queue empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
p = m_packets.front ();
|
||||
m_packets.pop ();
|
||||
|
||||
NS_DEBUG("DropTailQueue::DoDequeue (): Popped " << &p << " <= true");
|
||||
|
||||
return p;
|
||||
return true;
|
||||
}
|
||||
|
||||
Packet
|
||||
DropTailQueue::DoPeek ()
|
||||
bool
|
||||
DropTailQueue::DoPeek (Packet& p)
|
||||
{
|
||||
NS_DEBUG("DropTailQueue::DoPeek ( )");
|
||||
NS_ASSERT(!IsEmpty());
|
||||
NS_DEBUG("DropTailQueue::DoPeek (" << &p << ")");
|
||||
|
||||
return m_packets.front ();
|
||||
if (m_packets.empty())
|
||||
{
|
||||
NS_DEBUG("DropTailQueue::DoPeek (): Queue empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
p = m_packets.front ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
@@ -58,8 +58,8 @@ public:
|
||||
|
||||
private:
|
||||
virtual bool DoEnqueue (const Packet& p);
|
||||
virtual Packet DoDequeue ();
|
||||
virtual Packet DoPeek ();
|
||||
virtual bool DoDequeue (Packet &p);
|
||||
virtual bool DoPeek (Packet &p);
|
||||
|
||||
private:
|
||||
std::queue<Packet> m_packets;
|
||||
|
||||
@@ -46,7 +46,7 @@ class Ipv4Header; // FIXME: ipv4-header.h needs to move from module
|
||||
class Ipv4RoutingProtocol : public Object
|
||||
{
|
||||
public:
|
||||
// void (*RouteReply) (bool found, Ipv4Route route, Packet& packet, Ipv4Header const &ipHeader);
|
||||
// void (*RouteReply) (bool found, Ipv4Route route, Packet packet, Ipv4Header const &ipHeader);
|
||||
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
* inserted and consequently the protocol type has to change).
|
||||
*
|
||||
*/
|
||||
typedef Callback<void, bool, const Ipv4Route&, Packet&, const Ipv4Header&> RouteReplyCallback;
|
||||
typedef Callback<void, bool, const Ipv4Route&, Packet, const Ipv4Header&> RouteReplyCallback;
|
||||
|
||||
/**
|
||||
* \brief Asynchronously requests a route for a given packet and IP header
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
* insert any extra header.
|
||||
*/
|
||||
virtual bool RequestRoute (const Ipv4Header &ipHeader,
|
||||
Packet& packet,
|
||||
Packet packet,
|
||||
RouteReplyCallback routeReply) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ NetDevice::DisablePointToPoint (void)
|
||||
|
||||
// Receive packet from above
|
||||
bool
|
||||
NetDevice::Send(Packet& p, const Address& dest, uint16_t protocolNumber)
|
||||
NetDevice::Send(const Packet& p, const Address& dest, uint16_t protocolNumber)
|
||||
{
|
||||
if (m_isUp)
|
||||
{
|
||||
@@ -197,7 +197,7 @@ NetDevice::GetChannel (void) const
|
||||
|
||||
// Receive packets from below
|
||||
bool
|
||||
NetDevice::ForwardUp(Packet& p, uint16_t param, const Address &from)
|
||||
NetDevice::ForwardUp(const Packet& p, uint16_t param, const Address &from)
|
||||
{
|
||||
bool retval = false;
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
*
|
||||
* \return whether the Send operation succeeded
|
||||
*/
|
||||
bool Send(Packet& p, const Address& dest, uint16_t protocolNumber);
|
||||
bool Send(const Packet& p, const Address& dest, uint16_t protocolNumber);
|
||||
/**
|
||||
* \returns the node base class which contains this network
|
||||
* interface.
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
* \returns true if the callback could handle the packet successfully, false
|
||||
* otherwise.
|
||||
*/
|
||||
typedef Callback<bool,Ptr<NetDevice>,Packet &,uint16_t,const Address &> ReceiveCallback;
|
||||
typedef Callback<bool,Ptr<NetDevice>,const Packet &,uint16_t,const Address &> ReceiveCallback;
|
||||
|
||||
/**
|
||||
* \param cb callback to invoke whenever a packet has been received and must
|
||||
@@ -251,7 +251,7 @@ public:
|
||||
* forwards it to the higher layers by calling this method
|
||||
* which is responsible for passing it up to the Rx callback.
|
||||
*/
|
||||
bool ForwardUp (Packet& p, uint16_t param, const Address &address);
|
||||
bool ForwardUp (const Packet& p, uint16_t param, const Address &address);
|
||||
|
||||
|
||||
/**
|
||||
@@ -274,7 +274,7 @@ public:
|
||||
* method. When the link is Up, this method is invoked to ask
|
||||
* subclasses to forward packets. Subclasses MUST override this method.
|
||||
*/
|
||||
virtual bool SendTo (Packet& p, const Address &dest, uint16_t protocolNumber) = 0;
|
||||
virtual bool SendTo (const Packet& p, const Address &dest, uint16_t protocolNumber) = 0;
|
||||
/**
|
||||
* \returns true if this NetDevice needs the higher-layers
|
||||
* to perform ARP over it, false otherwise.
|
||||
|
||||
@@ -213,7 +213,7 @@ Node::UnregisterProtocolHandler (ProtocolHandler handler)
|
||||
}
|
||||
|
||||
bool
|
||||
Node::ReceiveFromDevice (Ptr<NetDevice> device, Packet &packet,
|
||||
Node::ReceiveFromDevice (Ptr<NetDevice> device, const Packet &packet,
|
||||
uint16_t protocol, const Address &from)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
/**
|
||||
* A protocol handler
|
||||
*/
|
||||
typedef Callback<void,Ptr<NetDevice>, Packet &,uint16_t,const Address &> ProtocolHandler;
|
||||
typedef Callback<void,Ptr<NetDevice>, const Packet &,uint16_t,const Address &> ProtocolHandler;
|
||||
/**
|
||||
* \param handler the handler to register
|
||||
* \param protocolType the type of protocol this handler is
|
||||
@@ -210,7 +210,7 @@ private:
|
||||
*/
|
||||
virtual void NotifyDeviceAdded (Ptr<NetDevice> device);
|
||||
|
||||
bool ReceiveFromDevice (Ptr<NetDevice> device, Packet &packet,
|
||||
bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &packet,
|
||||
uint16_t protocol, const Address &from);
|
||||
void Construct (void);
|
||||
TraceResolver *CreateDevicesTraceResolver (const TraceContext &context);
|
||||
|
||||
@@ -186,7 +186,7 @@ PacketSocket::Connect(const Address &ad)
|
||||
}
|
||||
|
||||
int
|
||||
PacketSocket::Send (Packet &p)
|
||||
PacketSocket::Send (const Packet &p)
|
||||
{
|
||||
if (m_state == STATE_OPEN ||
|
||||
m_state == STATE_BOUND)
|
||||
@@ -198,7 +198,7 @@ PacketSocket::Send (Packet &p)
|
||||
}
|
||||
|
||||
int
|
||||
PacketSocket::SendTo(const Address &address, Packet &p)
|
||||
PacketSocket::SendTo(const Address &address, const Packet &p)
|
||||
{
|
||||
PacketSocketAddress ad;
|
||||
if (m_state == STATE_CLOSED)
|
||||
@@ -262,7 +262,7 @@ PacketSocket::SendTo(const Address &address, Packet &p)
|
||||
}
|
||||
|
||||
void
|
||||
PacketSocket::ForwardUp (Ptr<NetDevice> device, Packet &packet,
|
||||
PacketSocket::ForwardUp (Ptr<NetDevice> device, const Packet &packet,
|
||||
uint16_t protocol, const Address &from)
|
||||
{
|
||||
if (m_shutdownRecv)
|
||||
@@ -270,7 +270,7 @@ PacketSocket::ForwardUp (Ptr<NetDevice> device, Packet &packet,
|
||||
return;
|
||||
}
|
||||
|
||||
//Packet p = packet; ?
|
||||
Packet p = packet;
|
||||
|
||||
PacketSocketAddress address;
|
||||
address.SetPhysicalAddress (from);
|
||||
@@ -279,7 +279,7 @@ PacketSocket::ForwardUp (Ptr<NetDevice> device, Packet &packet,
|
||||
|
||||
NS_DEBUG ("PacketSocket::ForwardUp: UID is " << packet.GetUid()
|
||||
<< " PacketSocket " << this);
|
||||
NotifyDataReceived (packet, address);
|
||||
NotifyDataReceived (p, address);
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -82,15 +82,15 @@ public:
|
||||
virtual int ShutdownSend (void);
|
||||
virtual int ShutdownRecv (void);
|
||||
virtual int Connect(const Address &address);
|
||||
virtual int Send (Packet &p);
|
||||
virtual int SendTo(const Address &address,Packet &p);
|
||||
virtual int Send (const Packet &p);
|
||||
virtual int SendTo(const Address &address,const Packet &p);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
void Init (void);
|
||||
void ForwardUp (Ptr<NetDevice> device, Packet &packet,
|
||||
void ForwardUp (Ptr<NetDevice> device, const Packet &packet,
|
||||
uint16_t protocol, const Address &from);
|
||||
int DoBind (const PacketSocketAddress &address);
|
||||
virtual void DoDispose (void);
|
||||
|
||||
@@ -49,7 +49,7 @@ QueueTraceType::IsEnqueue (void) const
|
||||
{
|
||||
return m_type == ENQUEUE;
|
||||
}
|
||||
bool
|
||||
bool
|
||||
QueueTraceType::IsDequeue (void) const
|
||||
{
|
||||
return m_type == DEQUEUE;
|
||||
@@ -122,25 +122,28 @@ Queue::Enqueue (const Packet& p)
|
||||
return retval;
|
||||
}
|
||||
|
||||
Packet
|
||||
Queue::Dequeue ()
|
||||
bool
|
||||
Queue::Dequeue (Packet &p)
|
||||
{
|
||||
NS_ASSERT(!IsEmpty());
|
||||
NS_DEBUG("Queue::Dequeue ( )");
|
||||
NS_DEBUG("Queue::Dequeue (" << &p << ")");
|
||||
|
||||
Packet p = DoDequeue ();
|
||||
bool retval = DoDequeue (p);
|
||||
|
||||
m_nBytes -= p.GetSize ();
|
||||
m_nPackets--;
|
||||
|
||||
NS_ASSERT (m_nBytes >= 0);
|
||||
NS_ASSERT (m_nPackets >= 0);
|
||||
|
||||
NS_DEBUG("Queue::Dequeue (): m_traceDequeue (p)");
|
||||
if (retval)
|
||||
{
|
||||
m_nBytes -= p.GetSize ();
|
||||
m_nPackets--;
|
||||
|
||||
m_traceDequeue (p);
|
||||
NS_ASSERT (m_nBytes >= 0);
|
||||
NS_ASSERT (m_nPackets >= 0);
|
||||
|
||||
return p;
|
||||
NS_DEBUG("Queue::Dequeue (): m_traceDequeue (p)");
|
||||
|
||||
const Packet packet = p;
|
||||
m_traceDequeue (packet);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -151,13 +154,12 @@ Queue::DequeueAll (void)
|
||||
NS_ASSERT (!"Don't know what to do with dequeued packets!");
|
||||
}
|
||||
|
||||
Packet
|
||||
Queue::Peek ()
|
||||
bool
|
||||
Queue::Peek (Packet &p)
|
||||
{
|
||||
NS_ASSERT(!IsEmpty());
|
||||
NS_DEBUG("Queue::Peek ( )");
|
||||
NS_DEBUG("Queue::Peek (" << &p << ")");
|
||||
|
||||
return DoPeek ();
|
||||
return DoPeek (p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -83,16 +83,14 @@ public:
|
||||
bool Enqueue (const Packet& p);
|
||||
/**
|
||||
* Remove a packet from the front of the Queue
|
||||
* Must not be called on an empty queue.
|
||||
* \return The packet removed from the queue
|
||||
* \return True if the operation was successful; false otherwise
|
||||
*/
|
||||
Packet Dequeue ();
|
||||
bool Dequeue (Packet &p);
|
||||
/**
|
||||
* Get a copy of the item at the front of the queue without removing it
|
||||
* Must NOT be called on an empty queue
|
||||
* \return The packet at the head of the queue.
|
||||
* \return True if the operation was successful; false otherwise
|
||||
*/
|
||||
Packet Peek ();
|
||||
bool Peek (Packet &p);
|
||||
|
||||
/**
|
||||
* XXX Doesn't do anything right now, think its supposed to flush the queue
|
||||
@@ -165,8 +163,8 @@ public:
|
||||
private:
|
||||
|
||||
virtual bool DoEnqueue (const Packet& p) = 0;
|
||||
virtual Packet DoDequeue () = 0;
|
||||
virtual Packet DoPeek () = 0;
|
||||
virtual bool DoDequeue (Packet &p) = 0;
|
||||
virtual bool DoPeek (Packet &p) = 0;
|
||||
|
||||
protected:
|
||||
// called by subclasses to notify parent of packet drops.
|
||||
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
* \returns -1 in case of error or the number of bytes copied in the
|
||||
* internal buffer and accepted for transmission.
|
||||
*/
|
||||
virtual int Send (Packet &p) = 0;
|
||||
virtual int Send (const Packet &p) = 0;
|
||||
|
||||
/**
|
||||
* \brief Send data to a specified peer.
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
* \returns -1 in case of error or the number of bytes copied in the
|
||||
* internal buffer and accepted for transmission.
|
||||
*/
|
||||
virtual int SendTo(const Address &address,Packet &p) = 0;
|
||||
virtual int SendTo(const Address &address,const Packet &p) = 0;
|
||||
|
||||
protected:
|
||||
void NotifyCloseCompleted (void);
|
||||
|
||||
Reference in New Issue
Block a user