File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed 
simulation/src/point-to-point/model Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 1212#include  " ns3/int-header.h" 
1313#include  " ns3/simulator.h" 
1414#include  < cmath> 
15+ #include  < unordered_set> 
1516
1617namespace  ns3  {
1718
@@ -60,6 +61,7 @@ SwitchNode::SwitchNode(){
6061		m_u[i] = 0 ;
6162}
6263
64+ std::unordered_set<uint64_t >  printedFlows;
6365int  SwitchNode::GetOutDev (Ptr<const  Packet> p, CustomHeader &ch){
6466	//  look up entries
6567	auto  entry = m_rtTable.find (ch.dip );
@@ -78,6 +80,9 @@ int SwitchNode::GetOutDev(Ptr<const Packet> p, CustomHeader &ch){
7880	} buf;
7981	buf.u32 [0 ] = ch.sip ;
8082	buf.u32 [1 ] = ch.dip ;
83+ 	uint32_t  srcIp = ch.sip ;
84+ 	uint32_t  dstIp = ch.dip ;
85+ 	uint64_t  flowId = ((uint64_t )srcIp << 32 ) | dstIp;
8186	if  (ch.l3Prot  == 0x6 )
8287		buf.u32 [2 ] = ch.tcp .sport  | ((uint32_t )ch.tcp .dport  << 16 );
8388	else  if  (ch.l3Prot  == 0x11 )
@@ -86,6 +91,10 @@ int SwitchNode::GetOutDev(Ptr<const Packet> p, CustomHeader &ch){
8691		buf.u32 [2 ] = ch.ack .sport  | ((uint32_t )ch.ack .dport  << 16 );
8792
8893	uint32_t  idx = EcmpHash (buf.u8 , 12 , m_ecmpSeed) % nexthops.size ();
94+ 	if  (nexthops.size () > 0  && printedFlows.find (flowId) == printedFlows.end ()) {
95+ 	    std::cout << " src IP: " 24 ) & 0xFF ) << " ." 16 ) & 0xFF ) << " ." 8 ) & 0xFF ) << " ." 0xFF )<<" >" " Destination IP: " 24 ) & 0xFF ) << " ." 16 ) & 0xFF ) << " ." 8 ) & 0xFF ) << " ." 0xFF )<<"  in switch: " "  ECMP(header): " "  selected interface: " 
96+ 		  printedFlows.insert (flowId);  // 记录该流已经打印
97+ 	}
8998	return  nexthops[idx];
9099}
91100
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments