From 5d895f662d7e0fa71de51e0fbcdf29b59fdebf76 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Mon, 14 Oct 2024 15:29:39 +0100 Subject: [PATCH] doc: Fix formatting of code samples --- doc/tutorial/source/building-topologies.rst | 14 ++++++------ doc/tutorial/source/tracing.rst | 24 +++++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/doc/tutorial/source/building-topologies.rst b/doc/tutorial/source/building-topologies.rst index 5d590d26d..b786a6709 100644 --- a/doc/tutorial/source/building-topologies.rst +++ b/doc/tutorial/source/building-topologies.rst @@ -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 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 diff --git a/doc/tutorial/source/tracing.rst b/doc/tutorial/source/tracing.rst index f85c00589..1dd9c2129 100644 --- a/doc/tutorial/source/tracing.rst +++ b/doc/tutorial/source/tracing.rst @@ -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, 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