satellite-packet-classifier.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd
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: Jani Puttonen <jani.puttonen@magister.fi>
19  */
20 
22 
24 #include "satellite-enums.h"
25 
26 #include <ns3/ipv4-header.h>
27 #include <ns3/ipv4-l3-protocol.h>
28 #include <ns3/log.h>
29 
30 NS_LOG_COMPONENT_DEFINE("SatPacketClassifier");
31 
32 namespace ns3
33 {
34 
36 {
37 }
38 
40 {
41 }
42 
43 uint8_t
45 {
46  NS_LOG_FUNCTION(this << dest);
47 
48  // ACKs are treated as user data, thus they are classified to be using the best effort
49  // flow id. Note, that in FWD link, the ACK is sent in RTN link back to the GW, thus
50  // the UT needs to have a lower layer service configured for BE RC index to be able to
51  // transmit the ACKs.
53  {
54  return SatEnums::BE_FID;
55  }
56 
57  // By default the control messages are classified to control fid
58  return SatEnums::CONTROL_FID;
59 }
60 
61 uint8_t
62 SatPacketClassifier::Classify(const Ptr<Packet> packet,
63  const Address& dest,
64  uint16_t protocolNumber) const
65 {
66  NS_LOG_FUNCTION(this << packet->GetUid() << dest << protocolNumber);
67 
68  Ipv4Header ipv4Header;
69  packet->PeekHeader(ipv4Header);
70 
71  uint8_t dscp = ipv4Header.GetDscp();
72 
73  switch (dscp)
74  {
75  case Ipv4Header::DscpDefault: {
76  return SatEnums::BE_FID;
77  break;
78  }
79  case Ipv4Header::DSCP_AF11:
80  case Ipv4Header::DSCP_AF12:
81  case Ipv4Header::DSCP_AF13:
82  case Ipv4Header::DSCP_AF21:
83  case Ipv4Header::DSCP_AF22:
84  case Ipv4Header::DSCP_AF23:
85  case Ipv4Header::DSCP_AF31:
86  case Ipv4Header::DSCP_AF32:
87  case Ipv4Header::DSCP_AF33:
88  case Ipv4Header::DSCP_AF41:
89  case Ipv4Header::DSCP_AF42:
90  case Ipv4Header::DSCP_AF43:
91  case Ipv4Header::DSCP_CS1:
92  case Ipv4Header::DSCP_CS2:
93  case Ipv4Header::DSCP_CS3:
94  case Ipv4Header::DSCP_CS4: {
95  return SatEnums::AF_FID;
96  break;
97  }
98  case Ipv4Header::DSCP_EF:
99  case Ipv4Header::DSCP_CS5:
100  case Ipv4Header::DSCP_CS6:
101  case Ipv4Header::DSCP_CS7: {
102  return SatEnums::EF_FID;
103  break;
104  }
105  default: {
106  NS_FATAL_ERROR("Unsupported DSCP field value: " << dscp);
107  break;
108  }
109  }
110 
111  return SatEnums::BE_FID;
112 }
113 
114 } // namespace ns3
SatControlMsgType_t
Definition for different types of control messages.
uint8_t Classify(SatControlMsgTag::SatControlMsgType_t type, const Address &dest) const
Classify control message.
virtual ~SatPacketClassifier()
Destructor for SatPacketClassifier.
SatPacketClassifier()
Default constructor.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.