Skip to content

Commit 98a8f4d

Browse files
committed
修改了 nvswitch-node.cc
1 parent c2bfbf4 commit 98a8f4d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

simulation/src/point-to-point/model/nvswitch-node.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "ns3/int-header.h"
1313
#include "ns3/simulator.h"
1414
#include <cmath>
15+
#include <unordered_set>
1516

1617
namespace ns3 {
1718

@@ -48,6 +49,7 @@ NVSwitchNode::NVSwitchNode(){
4849
m_u[i] = 0;
4950
}
5051

52+
//std::unordered_set<uint64_t> printedFlows;
5153
int NVSwitchNode::GetOutDev(Ptr<const Packet> p, CustomHeader &ch){
5254
// look up entries
5355
auto entry = m_rtTable.find(ch.dip);
@@ -66,6 +68,9 @@ int NVSwitchNode::GetOutDev(Ptr<const Packet> p, CustomHeader &ch){
6668
} buf;
6769
buf.u32[0] = ch.sip;
6870
buf.u32[1] = ch.dip;
71+
//uint32_t srcIp = ch.sip;
72+
//uint32_t dstIp = ch.dip;
73+
//uint64_t flowId = ((uint64_t)srcIp << 32) | dstIp;
6974
if (ch.l3Prot == 0x6)
7075
buf.u32[2] = ch.tcp.sport | ((uint32_t)ch.tcp.dport << 16);
7176
else if (ch.l3Prot == 0x11)
@@ -74,6 +79,10 @@ int NVSwitchNode::GetOutDev(Ptr<const Packet> p, CustomHeader &ch){
7479
buf.u32[2] = ch.ack.sport | ((uint32_t)ch.ack.dport << 16);
7580

7681
uint32_t idx = EcmpHash(buf.u8, 12, m_ecmpSeed) % nexthops.size();
82+
//if (nexthops.size() > 0 && printedFlows.find(flowId) == printedFlows.end()) {
83+
//std::cout << "src IP: "<< ((srcIp >> 24) & 0xFF) << "." << ((srcIp >> 16) & 0xFF) << "." << ((srcIp >> 8) & 0xFF) << "." << (srcIp & 0xFF)<<">"<<"Destination IP: "<< ((dstIp >> 24) & 0xFF) << "." << ((dstIp >> 16) & 0xFF) << "." << ((dstIp >> 8) & 0xFF) << "." << (dstIp & 0xFF)<<" in nvswitch: "<<m_id<<" ECMP(header): "<<idx<< " selected interface: " << nexthops[idx]<<" selected node: "<<nexthops[idx]<<std::endl;
84+
//printedFlows.insert(flowId); //记录该流已经打印
85+
//}
7786
return nexthops[idx];
7887
}
7988

0 commit comments

Comments
 (0)