blob: 3147ed08a8959ca0bf6c8a33c044ba55e7f5b9ea [file] [log] [blame]
Alexander Afanasyevc4f88282012-01-03 11:27:20 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2011 UCLA
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21#include "ipv4-seqs-app-tracer.h"
22#include "ns3/node.h"
23#include "ns3/packet.h"
24#include "ns3/config.h"
25#include "ns3/callback.h"
26#include "ns3/simulator.h"
27
28#include "ns3/tcp-l4-protocol.h"
29#include "ns3/tcp-header.h"
30#include "ns3/ipv4-header.h"
31
32namespace ns3 {
33
34Ipv4SeqsAppTracer::Ipv4SeqsAppTracer (std::ostream &os, Ptr<Node> node, const std::string &appId)
35 : Ipv4AppTracer (node, appId)
36 , m_os (os)
37{
38}
39
40void
41Ipv4SeqsAppTracer::Reset ()
42{
43}
44
45void
46Ipv4SeqsAppTracer::PrintHeader (std::ostream &os) const
47{
48 os << "Time\t"
49 << "Node\t"
50 << "AppName\t"
51 << "AppId\t"
52 << "Type\t"
53 << "SeqNo";
54}
55
56void
57Ipv4SeqsAppTracer::Print (std::ostream &os) const
58{
59}
60
61#define PRINTER(type,size) \
62 m_os \
63 << Simulator::Now ().ToDouble (Time::S) << "\t" \
64 << m_node << "\t" \
65 << m_app << "\t" \
66 << m_appId << "\t" \
67 << type << "\t" \
68 << size / 1040.0 << std::endl;
69
70void
71Ipv4SeqsAppTracer::Tx (std::string context,
72 const Ipv4Header &ip, Ptr<const Packet>, uint32_t)
73{
74 if (ip.GetProtocol () != TcpL4Protocol::PROT_NUMBER) return;
75}
76
77void
78Ipv4SeqsAppTracer::Rx (std::string context,
79 const Ipv4Header &ip, Ptr<const Packet> pktOrig, uint32_t)
80{
81 if (ip.GetProtocol () != TcpL4Protocol::PROT_NUMBER) return;
82
83 TcpHeader tcp;
84 Ptr<Packet> packet = pktOrig->Copy ();
85 packet->RemoveHeader (tcp);
86
87 if (tcp.GetFlags () | TcpHeader::ACK)
88 {
89 PRINTER("InAck", tcp.GetAckNumber ().GetValue ());
90 }
91}
92
93
94// void
95// Ipv4SeqsAppTracer::InData (std::string context,
96// Ptr<const Packet> packet, const Address &address)
97// {
98// PRINTER ("InData", m_inSeq);
99// m_inSeq += packet->GetSize ();
100// }
101
102// void
103// Ipv4SeqsAppTracer::OutData (std::string context,
104// Ptr<const Packet> packet)
105// {
106// PRINTER ("OutData", m_outSeq);
107// m_outSeq += packet->GetSize ();
108// }
109
110} // namespace ns3