Feature (contd.): Device Emulation - reorganized/renamed some emulation RPCs and messages

This commit is contained in:
Srivats P 2015-11-11 10:52:29 +05:30
parent 280d4bedaa
commit 492a207ede
9 changed files with 82 additions and 61 deletions

View File

@ -21,9 +21,9 @@ import "protocol.proto";
package OstEmul; package OstEmul;
// ====== // =======
// VLAN // Encap
// ====== // =======
message VlanEmulation { message VlanEmulation {
message Vlan { message Vlan {
optional uint32 tpid = 1 [default = 0x8100]; optional uint32 tpid = 1 [default = 0x8100];
@ -38,15 +38,13 @@ message VlanEmulation {
repeated Vlan stack = 1; // outer to inner repeated Vlan stack = 1; // outer to inner
} }
// FIXME: encapsulate VlanEmulation inside a new encapEmulation message? message EncapEmulation {
optional VlanEmulation vlan = 1;
extend OstProto.DeviceGroup {
optional VlanEmulation vlan = 200;
} }
// ======== // ===========
// Device // Protocols
// ======== // ===========
message MacEmulation { message MacEmulation {
optional uint64 address = 1; // FIXME: default value optional uint64 address = 1; // FIXME: default value
@ -76,40 +74,51 @@ message Ip6Emulation {
// FIXME: step for gateway? // FIXME: step for gateway?
} }
// FIXME: move fields of Device directly inside 'extend OstProto.DeviceGroup'
message Device {
optional MacEmulation mac = 1;
optional Ip4Emulation ip4 = 2;
optional Ip6Emulation ip6 = 3;
optional uint32 count = 10 [default = 1];
}
extend OstProto.DeviceGroup { extend OstProto.DeviceGroup {
optional Device device = 201; optional EncapEmulation encap = 2000;
optional MacEmulation mac = 2001;
optional Ip4Emulation ip4 = 3000;
optional Ip6Emulation ip6 = 3001;
} }
// FIXME: rename xxxEntry to something better? /* TODO
message Device {
optional uint64 mac = 1;
// FIXME: move vlan into encapInfo?
repeated uint32 vlan = 2; // includes tpid 'n vlan tag
optional uint32 ip4 = 3;
optional uint32 ip4_prefix_length = 4;
optional uint32 ip4_default_gateway = 5;
// TODO: IPv6 fields
}
message DeviceList {
repeated Device devices = 1;
}
*/
message ArpEntry { message ArpEntry {
optional uint32 ip4 = 1; optional uint32 ip4 = 1;
optional uint64 mac = 2; optional uint64 mac = 2;
// FIXME: add state/status field?
} }
message NdEntry { message NdEntry {
optional uint64 ip6_hi = 1; optional uint64 ip6_hi = 1;
optional uint64 ip6_lo = 2; optional uint64 ip6_lo = 2;
optional uint64 mac = 3; optional uint64 mac = 3;
// FIXME: add state/status field?
} }
// FIXME: change message name message DeviceNeighborList {
message DeviceNeighbors {
optional uint32 device_index = 1; optional uint32 device_index = 1;
repeated ArpEntry arp = 2; repeated ArpEntry arp = 2;
repeated NdEntry nd = 3; repeated NdEntry nd = 3;
} }
extend OstProto.DeviceNeighborList { extend OstProto.PortNeighborList {
repeated DeviceNeighbors devices = 100; repeated DeviceNeighborList devices = 100;
} }

View File

@ -281,7 +281,6 @@ message Notification {
* FIXME: What will be the contents of a default device created by addDeviceGroup()? * FIXME: What will be the contents of a default device created by addDeviceGroup()?
* FIXME: decide default values for device and protoEmulations * FIXME: decide default values for device and protoEmulations
* FIXME: rename 'DeviceGroup'? * FIXME: rename 'DeviceGroup'?
* FIXME: review RPC abstractions - esp. Neighbor related
*/ */
message DeviceGroupId { message DeviceGroupId {
required uint32 id = 1; required uint32 id = 1;
@ -299,8 +298,9 @@ message DeviceGroupIdList {
message DeviceGroup { message DeviceGroup {
required DeviceGroupId device_group_id = 1; required DeviceGroupId device_group_id = 1;
optional DeviceGroupCore core = 2; optional DeviceGroupCore core = 2;
optional uint32 device_count = 3 [default = 1];
extensions 200 to 500; // For use by Protocol Emulations extensions 2000 to 5999; // For use by Protocol Emulations
} }
message DeviceGroupConfigList { message DeviceGroupConfigList {
@ -308,7 +308,7 @@ message DeviceGroupConfigList {
repeated DeviceGroup device_group = 2; repeated DeviceGroup device_group = 2;
} }
message DeviceNeighborList { message PortNeighborList {
required PortId port_id = 1; required PortId port_id = 1;
extensions 100 to 199; extensions 100 to 199;
@ -337,16 +337,17 @@ service OstService {
rpc checkVersion(VersionInfo) returns (VersionCompatibility); rpc checkVersion(VersionInfo) returns (VersionCompatibility);
// Device/Protocol Emulation // Device Emulation
rpc getDeviceGroupIdList(PortId) returns (DeviceGroupIdList); rpc getDeviceGroupIdList(PortId) returns (DeviceGroupIdList);
rpc getDeviceGroupConfig(DeviceGroupIdList) returns (DeviceGroupConfigList); rpc getDeviceGroupConfig(DeviceGroupIdList) returns (DeviceGroupConfigList);
rpc addDeviceGroup(DeviceGroupIdList) returns (Ack); rpc addDeviceGroup(DeviceGroupIdList) returns (Ack);
rpc deleteDeviceGroup(DeviceGroupIdList) returns (Ack); rpc deleteDeviceGroup(DeviceGroupIdList) returns (Ack);
rpc modifyDeviceGroup(DeviceGroupConfigList) returns (Ack); rpc modifyDeviceGroup(DeviceGroupConfigList) returns (Ack);
// TODO: rpc getDeviceList(PortId) returns (DeviceList);
rpc resolveDeviceNeighbors(PortIdList) returns (Ack); rpc resolveDeviceNeighbors(PortIdList) returns (Ack);
rpc clearDeviceNeighbors(PortIdList) returns (Ack); rpc clearDeviceNeighbors(PortIdList) returns (Ack);
// FIXME: take PortIdList instead of PortId? rpc getDeviceNeighbors(PortId) returns (PortNeighborList);
rpc getDeviceNeighbors(PortId) returns (DeviceNeighborList);
} }

View File

@ -206,7 +206,7 @@ void Device::resolveNeighbor(PacketBuffer *pktBuf)
} }
// Append this device's neighbors to the list // Append this device's neighbors to the list
void Device::getNeighbors(OstEmul::DeviceNeighbors *neighbors) void Device::getNeighbors(OstEmul::DeviceNeighborList *neighbors)
{ {
QList<quint32> ipList = arpTable.keys(); QList<quint32> ipList = arpTable.keys();
QList<quint64> macList = arpTable.values(); QList<quint64> macList = arpTable.values();

View File

@ -53,7 +53,7 @@ public:
void clearNeighbors(); void clearNeighbors();
void resolveNeighbor(PacketBuffer *pktBuf); void resolveNeighbor(PacketBuffer *pktBuf);
void getNeighbors(OstEmul::DeviceNeighbors *neighbors); void getNeighbors(OstEmul::DeviceNeighborList *neighbors);
bool isOrigin(const PacketBuffer *pktBuf); bool isOrigin(const PacketBuffer *pktBuf);
quint64 neighborMac(const PacketBuffer *pktBuf); quint64 neighborMac(const PacketBuffer *pktBuf);

View File

@ -215,12 +215,12 @@ void DeviceManager::clearDeviceNeighbors()
} }
void DeviceManager::getDeviceNeighbors( void DeviceManager::getDeviceNeighbors(
OstProto::DeviceNeighborList *neighborList) OstProto::PortNeighborList *neighborList)
{ {
int count = 0; int count = 0;
foreach(Device *device, deviceList_) { foreach(Device *device, deviceList_) {
OstEmul::DeviceNeighbors *neighList = OstEmul::DeviceNeighborList *neighList =
neighborList->AddExtension(OstEmul::devices); neighborList->AddExtension(OstEmul::devices);
neighList->set_device_index(count++); neighList->set_device_index(count++);
device->getNeighbors(neighList); device->getNeighbors(neighList);
@ -296,11 +296,14 @@ void DeviceManager::enumerateDevices(
Operation oper) Operation oper)
{ {
Device dk(this); Device dk(this);
OstEmul::VlanEmulation pbVlan = deviceGroup->GetExtension(OstEmul::vlan); OstEmul::VlanEmulation pbVlan = deviceGroup->GetExtension(OstEmul::encap)
OstEmul::Device pbDevice = deviceGroup->GetExtension(OstEmul::device); .vlan();
int numTags = pbVlan.stack_size(); int numTags = pbVlan.stack_size();
int vlanCount = 1; int vlanCount = 1;
OstEmul::MacEmulation mac = deviceGroup->GetExtension(OstEmul::mac);
OstEmul::Ip4Emulation ip4 = deviceGroup->GetExtension(OstEmul::ip4);
for (int i = 0; i < numTags; i++) for (int i = 0; i < numTags; i++)
vlanCount *= pbVlan.stack(i).count(); vlanCount *= pbVlan.stack(i).count();
@ -316,15 +319,15 @@ void DeviceManager::enumerateDevices(
dk.setVlan(j, vlan.vlan_tag() + vlanAdd); dk.setVlan(j, vlan.vlan_tag() + vlanAdd);
} }
for (uint k = 0; k < pbDevice.count(); k++) { for (uint k = 0; k < deviceGroup->device_count(); k++) {
Device *device; Device *device;
quint64 macAdd = k * pbDevice.mac().step(); quint64 macAdd = k * mac.step();
quint32 ip4Add = k * pbDevice.ip4().step(); quint32 ip4Add = k * ip4.step();
dk.setMac(pbDevice.mac().address() + macAdd); dk.setMac(mac.address() + macAdd);
dk.setIp4(pbDevice.ip4().address() + ip4Add, dk.setIp4(ip4.address() + ip4Add,
pbDevice.ip4().prefix_length(), ip4.prefix_length(),
pbDevice.ip4().default_gateway()); ip4.default_gateway());
// TODO: fill in other pbDevice data // TODO: fill in other pbDevice data

View File

@ -53,7 +53,7 @@ public:
void clearDeviceNeighbors(); void clearDeviceNeighbors();
void resolveDeviceNeighbor(PacketBuffer *pktBuf); void resolveDeviceNeighbor(PacketBuffer *pktBuf);
void getDeviceNeighbors(OstProto::DeviceNeighborList *neighborList); void getDeviceNeighbors(OstProto::PortNeighborList *neighborList);
quint64 deviceMacAddress(PacketBuffer *pktBuf); quint64 deviceMacAddress(PacketBuffer *pktBuf);
quint64 neighborMacAddress(PacketBuffer *pktBuf); quint64 neighborMacAddress(PacketBuffer *pktBuf);

View File

@ -878,7 +878,7 @@ void MyService::clearDeviceNeighbors(
void MyService::getDeviceNeighbors( void MyService::getDeviceNeighbors(
::google::protobuf::RpcController* controller, ::google::protobuf::RpcController* controller,
const ::OstProto::PortId* request, const ::OstProto::PortId* request,
::OstProto::DeviceNeighborList* response, ::OstProto::PortNeighborList* response,
::google::protobuf::Closure* done) ::google::protobuf::Closure* done)
{ {
DeviceManager *devMgr; DeviceManager *devMgr;

View File

@ -145,7 +145,7 @@ public:
virtual void getDeviceNeighbors( virtual void getDeviceNeighbors(
::google::protobuf::RpcController* controller, ::google::protobuf::RpcController* controller,
const ::OstProto::PortId* request, const ::OstProto::PortId* request,
::OstProto::DeviceNeighborList* response, ::OstProto::PortNeighborList* response,
::google::protobuf::Closure* done); ::google::protobuf::Closure* done);
friend quint64 getDeviceMacAddress( friend quint64 getDeviceMacAddress(

View File

@ -195,6 +195,12 @@ try:
log.info('adding tx_stream %d' % stream_id.stream_id[0].id) log.info('adding tx_stream %d' % stream_id.stream_id[0].id)
drone.addStream(stream_id) drone.addStream(stream_id)
# ----------------------------------------------------------------- #
# delete all configuration on the DUT interfaces
# ----------------------------------------------------------------- #
sudo('ip address flush dev ' + dut_rx_port)
sudo('ip address flush dev ' + dut_tx_port)
# ================================================================= # # ================================================================= #
# ----------------------------------------------------------------- # # ----------------------------------------------------------------- #
# TEST CASES # TEST CASES
@ -227,12 +233,12 @@ try:
dg = devgrp_cfg.device_group.add() dg = devgrp_cfg.device_group.add()
dg.device_group_id.id = tx_dgid_list.device_group_id[0].id dg.device_group_id.id = tx_dgid_list.device_group_id[0].id
dg.core.name = "Host1" dg.core.name = "Host1"
d = dg.Extensions[emul.device] dg.device_count = num_devs
d.count = num_devs dg.Extensions[emul.mac].address = 0x000102030a01
d.mac.address = 0x000102030a01 ip = dg.Extensions[emul.ip4]
d.ip4.address = 0x0a0a0165 ip.address = 0x0a0a0165
d.ip4.prefix_length = 24 ip.prefix_length = 24
d.ip4.default_gateway = 0x0a0a0101 ip.default_gateway = 0x0a0a0101
drone.modifyDeviceGroup(devgrp_cfg) drone.modifyDeviceGroup(devgrp_cfg)
@ -242,15 +248,17 @@ try:
dg = devgrp_cfg.device_group.add() dg = devgrp_cfg.device_group.add()
dg.device_group_id.id = rx_dgid_list.device_group_id[0].id dg.device_group_id.id = rx_dgid_list.device_group_id[0].id
dg.core.name = "Host1" dg.core.name = "Host1"
d = dg.Extensions[emul.device] dg.device_count = num_devs
d.count = num_devs dg.Extensions[emul.mac].address = 0x000102030b01
d.mac.address = 0x000102030b01 ip = dg.Extensions[emul.ip4]
d.ip4.address = 0x0a0a0265 ip.address = 0x0a0a0265
d.ip4.prefix_length = 24 ip.prefix_length = 24
d.ip4.default_gateway = 0x0a0a0201 ip.default_gateway = 0x0a0a0201
drone.modifyDeviceGroup(devgrp_cfg) drone.modifyDeviceGroup(devgrp_cfg)
s = raw_input('Press [Enter] to continue')
# configure the tx stream # configure the tx stream
stream_cfg = ost_pb.StreamConfigList() stream_cfg = ost_pb.StreamConfigList()
stream_cfg.port_id.CopyFrom(tx_port.port_id[0]) stream_cfg.port_id.CopyFrom(tx_port.port_id[0])