public class Parameters {
//mapState:The state of VN.
//1:STATE_NEW
static int STATE_NEW = 1;
static int STATE_MAP_LINK = 2;
static int STATE_DONE = 3;
static int STATE_EXPIRE = 4;
static int STATE_MAP_NODE_FAIL = 5;
static int STATE_MAP_FAIL = 6;
static int STATE_MAP_NODE = 7;
static int STATE_MAP_Link_FAIL = 8;
static int STATE_MAP_SUCC = 9;
static int STATE_MAP_KEY_FAIL = 10;
}
二 s2v数据结构相关解释
2.1 snode对象
snode是LinkedList<Integer>的对象,之所以采用该双向链表数据结构是因为在不同环境下,虚拟节点和物理节点的数量是不同的。在虚拟网络映射过程中,添加节点映射结果如下所示:
v2s[index].snode.add(i, snode);
为什么采用这样的方式添加映射结果,主要是虚拟节点和虚拟链路采用的是序号的方式,即0,1,...,的方式来表示,例如0->2表示虚拟节点0映射到物理节点2上。为了加深该对象的理解,以下介绍LinkedList<Integer>双向链表。
LinkedList<Integer> 是Java集合框架中的一个双向链表实现,专门用于存储Integer对象。它实现了List和Deque接口,具有链表数据结构的特性。基本操作如下:
2.2 pathFlow 对象
添加链路映射结果如下所示:
v2s[index].pathFlow.add(i, pathFlow);
其中i是第i条虚拟链路,创建的路径pathFlow如下所示:
SpathFlow pathFlow = new SpathFlow();
pathFlow.link = link;
pathFlow.len = pathLength;//路径的长度
pathFlow.bw = reqs[index].link[i].bw;//第i条虚拟链路的带宽
其中pathLength和link的创建如下:
int pathLength = 0;
LinkedList<Integer> link = new LinkedList<Integer>();
while (p[i][snodeMid1] != -1) {
snodeMid = p[i][snodeMid1];
link.add(pathLength, snodeMid1);//link是在第pathLength个位置放置路径上的物理节点
pathLength++; //路径长度
snodeMid1 = snodeMid;
}
link.add(pathLength, snodeMid1);
其中pathFlow 是SpathFlow类的对象, SpathFlow类描述如下:
public class SpathFlow {
public int len; //The length of the flow.
public LinkedList<Integer> link = new LinkedList<Integer>(); //The path of the flow
public double bw; //The bandwidth of the flow.
}
2.3 flowLen、startSlotNo和slotNum对象
这三个对象分别记录是否是单路径映射还是多路径映射、分配的频谱槽的起始位置、分配的频谱槽的数量,分别通过以下语句实现:
v2s[index].flowLen.add(i, 1);//1:单路径链路映射;i:第i条链路。
v2s[index].startSlotNo.add(i, ret[i][0]);//分配的起始索引
v2s[index].slotNum.add(i, ret[i][1] - ret[i][0] + 1);
一个问题:如何实现多路径的虚拟链路映射?

