A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ipv4-flow-classifier.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 //
3 // Copyright (c) 2009 INESC Porto
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: Gustavo J. A. M. Carneiro <gjc@inescporto.pt> <gjcarneiro@gmail.com>
19 //
20 
21 #ifndef IPV4_FLOW_CLASSIFIER_H
22 #define IPV4_FLOW_CLASSIFIER_H
23 
24 #include <stdint.h>
25 #include <map>
26 
27 #include "ns3/ipv4-header.h"
28 #include "ns3/flow-classifier.h"
29 
30 namespace ns3 {
31 
32 class Packet;
33 
39 {
40 public:
41 
42  struct FiveTuple
43  {
44  Ipv4Address sourceAddress;
45  Ipv4Address destinationAddress;
46  uint8_t protocol;
47  uint16_t sourcePort;
48  uint16_t destinationPort;
49  };
50 
52 
56  bool Classify (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload,
57  uint32_t *out_flowId, uint32_t *out_packetId);
58 
60  FiveTuple FindFlow (FlowId flowId) const;
61 
62  virtual void SerializeToXmlStream (std::ostream &os, int indent) const;
63 
64 private:
65 
66  std::map<FiveTuple, FlowId> m_flowMap;
67 
68 };
69 
70 
71 bool operator < (const Ipv4FlowClassifier::FiveTuple &t1, const Ipv4FlowClassifier::FiveTuple &t2);
72 bool operator == (const Ipv4FlowClassifier::FiveTuple &t1, const Ipv4FlowClassifier::FiveTuple &t2);
73 
74 
75 } // namespace ns3
76 
77 #endif /* IPV4_FLOW_CLASSIFIER_H */
Packet header for IPv4.
Definition: ipv4-header.h:31
FiveTuple FindFlow(FlowId flowId) const
Searches for the FiveTuple corresponding to the given flowId.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
bool Classify(const Ipv4Header &ipHeader, Ptr< const Packet > ipPayload, uint32_t *out_flowId, uint32_t *out_packetId)
try to classify the packet into flow-id and packet-id