|
|
| 48 |
void |
48 |
void |
| 49 |
EpcTftClassifier::Add (Ptr<EpcTft> tft, uint32_t id) |
49 |
EpcTftClassifier::Add (Ptr<EpcTft> tft, uint32_t id) |
| 50 |
{ |
50 |
{ |
| 51 |
NS_LOG_FUNCTION (this << tft); |
51 |
NS_LOG_FUNCTION (this << tft << id); |
| 52 |
|
52 |
|
| 53 |
m_tftMap[id] = tft; |
53 |
m_tftMap[id] = tft; |
| 54 |
|
54 |
|
| 55 |
// simple sanity check: there shouldn't be more than 16 bearers (hence TFTs) per UE |
55 |
// simple sanity check: there shouldn't be more than 16 bearers (hence TFTs) per UE |
|
|
| 67 |
uint32_t |
67 |
uint32_t |
| 68 |
EpcTftClassifier::Classify (Ptr<Packet> p, EpcTft::Direction direction) |
68 |
EpcTftClassifier::Classify (Ptr<Packet> p, EpcTft::Direction direction) |
| 69 |
{ |
69 |
{ |
| 70 |
NS_LOG_FUNCTION (this << p << direction); |
70 |
NS_LOG_FUNCTION (this << p << p->GetSize () << direction); |
| 71 |
|
71 |
|
| 72 |
Ptr<Packet> pCopy = p->Copy (); |
72 |
Ptr<Packet> pCopy = p->Copy (); |
| 73 |
|
73 |
|
|
|
| 77 |
Ipv4Address localAddress; |
77 |
Ipv4Address localAddress; |
| 78 |
Ipv4Address remoteAddress; |
78 |
Ipv4Address remoteAddress; |
| 79 |
|
79 |
|
| 80 |
|
|
|
| 81 |
if (direction == EpcTft::UPLINK) |
80 |
if (direction == EpcTft::UPLINK) |
| 82 |
{ |
81 |
{ |
| 83 |
localAddress = ipv4Header.GetSource (); |
82 |
localAddress = ipv4Header.GetSource (); |
|
|
| 91 |
} |
90 |
} |
| 92 |
|
91 |
|
| 93 |
uint8_t protocol = ipv4Header.GetProtocol (); |
92 |
uint8_t protocol = ipv4Header.GetProtocol (); |
| 94 |
|
|
|
| 95 |
uint8_t tos = ipv4Header.GetTos (); |
93 |
uint8_t tos = ipv4Header.GetTos (); |
| 96 |
|
|
|
| 97 |
uint16_t localPort = 0; |
94 |
uint16_t localPort = 0; |
| 98 |
uint16_t remotePort = 0; |
95 |
uint16_t remotePort = 0; |
| 99 |
|
96 |
|
| 100 |
if (protocol == UdpL4Protocol::PROT_NUMBER) |
97 |
uint16_t payloadSize = ipv4Header.GetPayloadSize (); |
|
|
98 |
NS_LOG_DEBUG ("PayloadSize = " << payloadSize); |
| 99 |
|
| 100 |
uint16_t fragmentOffset = ipv4Header.GetFragmentOffset (); |
| 101 |
NS_LOG_DEBUG ("fragmentOffset = " << fragmentOffset); |
| 102 |
|
| 103 |
if (fragmentOffset == 0) |
| 101 |
{ |
104 |
{ |
| 102 |
UdpHeader udpHeader; |
105 |
if (protocol == UdpL4Protocol::PROT_NUMBER && payloadSize >= 8) |
| 103 |
pCopy->RemoveHeader (udpHeader); |
106 |
{ |
| 104 |
|
107 |
UdpHeader udpHeader; |
| 105 |
if (direction == EpcTft::UPLINK) |
108 |
pCopy->RemoveHeader (udpHeader); |
| 106 |
{ |
109 |
if (direction == EpcTft::UPLINK) |
| 107 |
localPort = udpHeader.GetSourcePort (); |
110 |
{ |
| 108 |
remotePort = udpHeader.GetDestinationPort (); |
111 |
localPort = udpHeader.GetSourcePort (); |
| 109 |
} |
112 |
remotePort = udpHeader.GetDestinationPort (); |
|
|
113 |
} |
| 114 |
else |
| 115 |
{ |
| 116 |
remotePort = udpHeader.GetSourcePort (); |
| 117 |
localPort = udpHeader.GetDestinationPort (); |
| 118 |
} |
| 119 |
} |
| 120 |
else if (protocol == TcpL4Protocol::PROT_NUMBER && payloadSize >= 20) |
| 121 |
{ |
| 122 |
TcpHeader tcpHeader; |
| 123 |
pCopy->RemoveHeader (tcpHeader); |
| 124 |
if (direction == EpcTft::UPLINK) |
| 125 |
{ |
| 126 |
localPort = tcpHeader.GetSourcePort (); |
| 127 |
remotePort = tcpHeader.GetDestinationPort (); |
| 128 |
} |
| 129 |
else |
| 130 |
{ |
| 131 |
remotePort = tcpHeader.GetSourcePort (); |
| 132 |
localPort = tcpHeader.GetDestinationPort (); |
| 133 |
} |
| 134 |
} |
| 110 |
else |
135 |
else |
| 111 |
{ |
136 |
{ |
| 112 |
remotePort = udpHeader.GetSourcePort (); |
137 |
NS_LOG_INFO ("Unknown protocol: " << protocol); |
| 113 |
localPort = udpHeader.GetDestinationPort (); |
138 |
return 0; // no match |
| 114 |
} |
139 |
} |
| 115 |
} |
|
|
| 116 |
else if (protocol == TcpL4Protocol::PROT_NUMBER) |
| 117 |
{ |
| 118 |
TcpHeader tcpHeader; |
| 119 |
pCopy->RemoveHeader (tcpHeader); |
| 120 |
if (direction == EpcTft::UPLINK) |
| 121 |
{ |
| 122 |
localPort = tcpHeader.GetSourcePort (); |
| 123 |
remotePort = tcpHeader.GetDestinationPort (); |
| 124 |
} |
| 125 |
else |
| 126 |
{ |
| 127 |
remotePort = tcpHeader.GetSourcePort (); |
| 128 |
localPort = tcpHeader.GetDestinationPort (); |
| 129 |
} |
| 130 |
} |
| 131 |
else |
| 132 |
{ |
| 133 |
NS_LOG_INFO ("Unknown protocol: " << protocol); |
| 134 |
return 0; // no match |
| 135 |
} |
140 |
} |
| 136 |
|
141 |
|
| 137 |
NS_LOG_INFO ("Classifing packet:" |
142 |
NS_LOG_INFO ("Classifing packet:" |