Hi John,
I used next code to send packets:
_______________________________________________________________________________________________________
// CONFIGURATION OF SOURCES AND SINKS NODES
// Set sink node which receives packets (2->4)
uint16_t sinkPort = 8080; // HTTP port
// Create TCP sockets and Bind to address and port
// GetAny returns the 0.0.0.0 address -> Node can receive packets
from all the IPs, but only for the specified port
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory",
InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps = packetSinkHelper.Install (nodos.Get
(sinkNode)); // Set up one application on the sink node
sinkApps.Start (Seconds (startSocket-1.0)); // Start Time
sinkApps.Stop (Seconds (stopSocket)); // End Time
// Other application to probe hidden node (1->0) (2->4)
ApplicationContainer sinkApps2 = packetSinkHelper.Install (nodos.Get
(0)); // Set up one application on the sink node
sinkApps2.Start (Seconds (10.)); // Start Time
sinkApps2.Stop (Seconds (stopSocket)); // End Time
// Create socket for sender
Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (nodos.Get
(sourceNode), TcpSocketFactory::GetTypeId ());
ns3TcpSocket->TraceConnectWithoutContext ("CongestionWindow",
MakeCallback (&CwndChange)); // Call to CwndChange function
// Set source node which sends packets (node 2 to node 4)
Ptr<MyApp> app = CreateObject<MyApp> ();
Address sinkAddress (InetSocketAddress(interfaces.GetAddress
(sinkNode), sinkPort)); // Address (with port) of node which receive
packets
app->Setup (ns3TcpSocket, sinkAddress, AppPacketSize, numPackets,
DataRate ("2Mbps"));
nodos.Get (sourceNode)->AddApplication (app);
app->SetStartTime (Seconds (startSocket)); // Start Time
app->SetStopTime (Seconds (stopSocket)); // End Time
// It can't start at 0 seconds because of OLSR protocol, for example,
the nodes require flooding messages to be exchanged for a few seconds
// Definition of the node that sends packets (node 1 to node 0)
Ptr<Socket> ns3TcpSocket2 = Socket::CreateSocket (nodos.Get (1),
TcpSocketFactory::GetTypeId ());
ns3TcpSocket2->TraceConnectWithoutContext ("CongestionWindow",
MakeCallback (&CwndChange)); // Call to CwndChange function
Ptr<MyApp> app2 = CreateObject<MyApp> ();
Address sinkAddress2 (InetSocketAddress(interfaces.GetAddress (0),
sinkPort)); // Address (with port) of node which receive packets
app2->Setup (ns3TcpSocket2, sinkAddress2, AppPacketSize, numPackets,
DataRate ("2Mbps")); // Physical layer has to transmit at least at 2x
nodos.Get (1)->AddApplication (app2);
app2->SetStartTime (Seconds (30.0)); //1
app2->SetStopTime (Seconds (stopSocket)); //20
____________________________________________________________________________________________________________
// Call to PhyRxOkTrace when node 0 receives a packet
Config::Connect ("/NodeList/4/DeviceList/*/Phy/State/
RxOk",MakeCallback (&PhyRxOkTrace));
Throughput (); // Call to function that calculates the throughput
every X seconds
_____________________________________________________________________________________________________________
void PhyRxOkTrace (std::string context, Ptr<const Packet> packet,
double snr, WifiMode mode, enum WifiPreamble preamble)
{
Ptr<Packet> m_currentPacket;
WifiMacHeader hdr;
m_currentPacket = packet->Copy();
m_currentPacket->RemoveHeader (hdr); // Remove header
if (hdr.IsData())
{
m_bytesTotal += m_currentPacket->GetSize (); // Get size of ok rx
bytes and add to previous
}
}
________________________________________________________________________________________________________________
So, I can't use Socket::GetSockName and SocketAddressTag because
Socket isn't argument on PhyRxOkTrace.
I'm looking for the way to obtain the IP through the packet, but i
can't see anything. It is possible?
I found:
Ipv4Address destAddressPacket = ipv4Header.GetDestination();
Ipv4Address scrAddressPacket = ipv4Header.GetSource();
and next i want to do something like:
if (destAddressPacket == 192.168.1.5 && scrAddressPacket ==
192.168.1.2)
m_bytesTotal += m_currentPacket->GetSize (); // Get size of ok rx
bytes and add to previous
but I don't know how to associate it to a specificied packet.
Can I solve the problem differently?
Thanks
On 30 oct, 23:46, John Abraham <
johnj...@gmail.com> wrote:
> There is Socket::GetSockName for destination address,
> there is SocketAddressTag carrying the source address, that is already
> shown in the example.
> -john
>
> On Oct 30, 6:26 pm,GuillermoGala<
valentinosn...@gmail.com> wrote:
>
> > Hi John,
>
> > I'm watching manet-routing-compare.cc, but in the example, throughput
> > is not filtered by IP, only shows the IP which sends packets.
>
> > I think the only way to "do a filter" is make a python script that
> > analize trace output file
>
> > Thanks
>
> > On 30 oct, 14:58, John Abraham <
johnj...@gmail.com> wrote:
>
> > > It is important to realize that even if RxOk is seen at the Phy layer,
> > > it does not mean Receive is OK for Mac, IP, and TCP layers. Goodput
> > > (useful throughput), is something usually best measured at the
> > > application layer (after all what your application ,say webbrowser,
> > > experiences, is what matters most , in many cases). In your code,
> > > heavy retransmissions (useless/control overhead) can also cause higher
> > > throughput numbers.
>
> > > For instance, you can check "manet-routing-compare.cc" on how they
> > > calculate throughput.
>
> > > > > On Oct 29, 9:19 pm,GuillermoGala<
valentinosn...@gmail.com> wrote:
>
> > > > > > Hi again John,
>
> > > > > > If I set RcvBufSize and SndBufSize to 11680 bytes=8MSS (1MSS = 1460
> > > > > > Bytes) I obtain next plot:
>
> > > > > >
http://www.subirimagenes.com/imagen-throughputaodv11680-7081103.html
>
> > > > > > On Wireshark "Window size value" is equal to 11680.
>
> > > > > > However if I put RcvBufSize and SndBufSize to 65535 bytes or more I
> > > > > > obtain this other plot:
>
> > > > > >
http://www.subirimagenes.com/imagen-throughputaodv65535-7081114.html
>
> > > > > > and on Wireshark "Window size value" is equal to 65535 (always).
>
> > > > > > I think that Send and Receive buffer don't delete send and receive
> > > > > > correct packets, because with 11680, throughput down to 0 Kbps after
> > > > > > 40 sec (more or less)
>
> > > > > > Regards
>
> > > > > > On 29 oct, 19:52, John Abraham <
johnj...@gmail.com> wrote:
>
> > > > > > > if you see those graphs, you will see the max throughput 400 vs 325
> > > > > > > (not average throughput) is higher for larger rx windows. Average
> > > > > > > throughput can grow for lower rWnd only if the BDP limits and/or
> > > > > > > congestion come into play.
>
> > > > > > > And further, the window_ mentioned here, is the maximum window size
> > > > > > > (my guess). If yes, it is the same as setting RcvBufSize which
> > > > > > > eventually translates to rWnd . If you hard-code rWnd to a constant
> > > > > > > value, you may get unexpected behavior (my opinion).
>
> > > > > > > On Oct 29, 6:35 pm,GuillermoGala<
valentinosn...@gmail.com> wrote:
>
> > > > > > > > Hi John,
>
> > > > > > > > I want to replicate next paper:
http://www.tcs.hut.fi/Studies/T-79.300/2005S/slides/Paper_Presentatio...
>
> > > > > > > > Graphs on page 16 / 28. As you can see, setting less windows value, do
> > > > > > > > that throughput is more stable and I can eliminate the problem of
> > > > > > > > hidden node on TCP.
>
> > > > > > > > This is exactly that I want to do, but using NS-3. On NS-2 i know that
> > > > > > > > the variable is "window_"
>
> > > > > > > > Thanks for your reply
>
> > > > > > > > On 30 oct, 00:12, John Abraham <
johnj...@gmail.com> wrote:
>
> > > > > > > > > well by hard-coding m_rWnd like you did earlier, you are forcing that
> > > > > > > > > receiver's window to be something you want. But in fact for an
> > > > > > > > > unhacked TCP , the receivers window is a function of the receiver's
> > > > > > > > > available rx buffer.
> > > > > > > > > By logic, setting rWnd to a lower value should decrease your
> > > > > > > > > throughput rather than increase it (when congestion is not present).
>
> > > > > > > > > So fixing rWnd to a fixed value ignores the current state of the rx
> > > > > > > > > buffer,.. the consequences for doing that are undefined. But you might
> > > > > > > > > have some legitimate reason for doing that, so you might want to
> > > > > > > > > search for places where "SetWindowSize" is used in tcp-socket-base.cc
> > > > > > > > > and change it appropriately.
>
> > > > > > > > > -john
>
> ...
>
> leer más »