doc: Fix formatting of code samples

This commit is contained in:
Eduardo Almeida
2024-10-14 15:29:39 +01:00
parent a92941c6ab
commit 5d895f662d
2 changed files with 20 additions and 18 deletions

View File

@@ -105,10 +105,10 @@ entirely comfortable with the following code at this point in the tutorial.
cmd.Parse(argc, argv);
if (verbose)
{
{
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
}
}
nCsma = nCsma == 0 ? 1 : nCsma;
@@ -892,10 +892,10 @@ number of devices created.
cmd.Parse(argc,argv);
if (verbose)
{
{
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
}
}
Just as in all of the previous examples, the next step is to create two nodes
that we will connect via the point-to-point link.
@@ -1359,9 +1359,9 @@ following function:
void
CourseChange(std::string context, Ptr<const MobilityModel> model)
{
Vector position = model->GetPosition();
NS_LOG_UNCOND(context <<
" x = " << position.x << ", y = " << position.y);
Vector position = model->GetPosition();
NS_LOG_UNCOND(context <<
" x = " << position.x << ", y = " << position.y);
}
This code just pulls the position information from the mobility model and

View File

@@ -120,24 +120,26 @@ You could simply add one, changing the code. Here is the original::
...
else if (tcpflags == (TcpHeader::SYN | TcpHeader::ACK))
{ // No action for received SYN+ACK, it is probably a duplicated packet
}
{
// No action for received SYN+ACK, it is probably a duplicated packet
}
...
To log the SYN+ACK case, you can add a new ``NS_LOG_LOGIC`` in the
``if`` statement body::
/* Received a packet upon ESTABLISHED state. This function is mimicking the
role of tcp_rcv_established() in tcp_input.c in Linux kernel. */
role of tcp_rcv_established() in tcp_input.c in Linux kernel. */
void
TcpSocketBase::ProcessEstablished(Ptr<Packet> packet, const TcpHeader& tcpHeader)
{
NS_LOG_FUNCTION(this << tcpHeader);
...
else if (tcpflags == (TcpHeader::SYN | TcpHeader::ACK))
{ // No action for received SYN+ACK, it is probably a duplicated packet
NS_LOG_LOGIC("TcpSocketBase " << this << " ignoring SYN+ACK");
}
{
// No action for received SYN+ACK, it is probably a duplicated packet
NS_LOG_LOGIC("TcpSocketBase " << this << " ignoring SYN+ACK");
}
...
This may seem fairly simple and satisfying at first glance, but
@@ -1620,13 +1622,13 @@ look at ``src/network/model/application.cc`` and you will find::
void
Application::DoInitialize()
{
NS_LOG_FUNCTION(this);
m_startEvent = Simulator::Schedule(m_startTime, &Application::StartApplication, this);
if (m_stopTime != TimeStep(0))
NS_LOG_FUNCTION(this);
m_startEvent = Simulator::Schedule(m_startTime, &Application::StartApplication, this);
if (m_stopTime != TimeStep(0))
{
m_stopEvent = Simulator::Schedule(m_stopTime, &Application::StopApplication, this);
m_stopEvent = Simulator::Schedule(m_stopTime, &Application::StopApplication, this);
}
Object::DoInitialize();
Object::DoInitialize();
}
Here, we finally come to the end of the trail. If you have kept it