github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/chapar/topology.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package chapar
     4  
     5  // MakeTopologyReq is request structure of MakeTopology()
     6  type MakeTopologyReq struct {
     7  	EndUser           uint
     8  	GateWayPort       uint  // Last hop free port
     9  	UserHopEfficiency uint8 // How many physical link to upper hop
    10  	Efficiency        uint8 // How many physical link to upper hop
    11  }
    12  
    13  // MakeTopologyRes is response structure of MakeTopology()
    14  type MakeTopologyRes struct {
    15  	EndUserSwitch uint
    16  	HopNumber     uint8
    17  }
    18  
    19  // MakeTopology calculate some data to implement Chapar network easily.
    20  func MakeTopology(req *MakeTopologyReq) (res *MakeTopologyRes) {
    21  	res = &MakeTopologyRes{}
    22  
    23  	// TODO::: Calculate each hop free port to upper hop by req.Efficiency
    24  
    25  	res.EndUserSwitch = req.EndUser / uint(255 - req.UserHopEfficiency + 1) 
    26  	return
    27  }