本文整理汇总了Java中org.onlab.packet.Ethernet类的典型用法代码示例。如果您正苦于以下问题:Java Ethernet类的具体用法?Java Ethernet怎么用?Java Ethernet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ethernet类属于org.onlab.packet包,在下文中一共展示了Ethernet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processMcastEthDstFilter
import org.onlab.packet.Ethernet; //导入依赖的package包/类
protected List<FlowRule> processMcastEthDstFilter(EthCriterion ethCriterion,
ApplicationId applicationId) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
treatment.transition(MULTICAST_ROUTING_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(DEFAULT_PRIORITY)
.fromApp(applicationId)
.makePermanent()
.forTable(TMAC_TABLE).build();
return ImmutableList.<FlowRule>builder().add(rule).build();
}
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:Ofdpa2Pipeline.java
示例2: removeL3Rules
import org.onlab.packet.Ethernet; //导入依赖的package包/类
/**
* Removes L3 rules for routerInterface events.
*
* @param vmIp Corresponding Vm ip
* @param routerInterfaces Corresponding routerInterfaces
*/
public void removeL3Rules(Ip4Address vmIp, List<OpenstackRouterInterface> routerInterfaces) {
if (vmIp == null) {
return;
}
OpenstackRoutingService routingService = getService(OpenstackRoutingService.class);
deviceService.getAvailableDevices().forEach(d -> {
if (!d.equals(getGatewayNode())) {
routerInterfaces.forEach(routerInterface -> {
String networkId = routingService.networkIdForRouterInterface(routerInterface.portId());
long vni = getVni(networkId);
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
.matchIPDst(vmIp.toIpPrefix())
.matchTunnelId(vni);
removeRule(d.id(), sBuilder, ForwardingObjective.Flag.SPECIFIC, ROUTING_RULE_PRIORITY);
});
}
});
}
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:OpenstackRoutingRulePopulator.java
示例3: processEtherTable
import org.onlab.packet.Ethernet; //导入依赖的package包/类
protected void processEtherTable(boolean install) {
//Default action
processTableMissDrop(install, ETHER_TABLE, "Provisioned ether type table drop");
//IP to FIB_TABLE
TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4);
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().transition(FIB_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(ETHER_TABLE).build();
processFlowRule(install, rule, "Provisioned ether type table ip");
}
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:CorsaPipelineV39.java
示例4: removeVxLanFlowRule
import org.onlab.packet.Ethernet; //导入依赖的package包/类
/**
* Removes the flow rules between traffic from VMs in different Cnode.
*
* @param deviceId device id
* @param vmIp ip
* @param vni vni which removed VM was belonged
*/
private void removeVxLanFlowRule(DeviceId deviceId, Ip4Address vmIp, long vni) {
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
.matchTunnelId(vni)
.matchIPDst(vmIp.toIpPrefix());
ForwardingObjective fo = DefaultForwardingObjective.builder()
.withSelector(sBuilder.build())
.withTreatment(DefaultTrafficTreatment.builder().build())
.withFlag(ForwardingObjective.Flag.SPECIFIC)
.withPriority(SWITCHING_RULE_PRIORITY)
.fromApp(appId)
.remove();
flowObjectiveService.forward(deviceId, fo);
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:OpenstackSwitchingRulePopulator.java
示例5: sendPacket
import org.onlab.packet.Ethernet; //导入依赖的package包/类
private void sendPacket(Ethernet eth) {
List<Instruction> ins = treatmentBuilder().build().allInstructions();
OFPort p = null;
//TODO: support arbitrary list of treatments must be supported in ofPacketContext
for (Instruction i : ins) {
if (i.type() == Type.OUTPUT) {
p = buildPort(((OutputInstruction) i).port());
break; //for now...
}
}
if (eth == null) {
ofPktCtx.build(p);
} else {
ofPktCtx.build(eth, p);
}
ofPktCtx.send();
}
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:OpenFlowCorePacketContext.java
示例6: testConfiguredVlanOnInterfaces
import org.onlab.packet.Ethernet; //导入依赖的package包/类
/**
* Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
* a vlan packet comes in from a port without interfaces configured. The destination
* host is not known for that IP address and there are some interfaces configured on
* the same vlan.
* It's expected to see the ARP request going out through ports with no interfaces
* configured, devices 4 and 5, port 1.
*
* Verifies the ARP request is flooded out the correct edge ports.
*/
@Test
public void testConfiguredVlanOnInterfaces() {
Host requestor = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(6),
Collections.singleton(IP1));
expect(hostService.getHostsByIp(IP2))
.andReturn(Collections.emptySet());
expect(interfaceService.getInterfacesByIp(IP1))
.andReturn(Collections.emptySet());
expect(hostService.getHost(HID1)).andReturn(requestor);
replay(hostService);
replay(interfaceService);
Ethernet arpRequest = buildArp(ARP.OP_REQUEST, VLAN1, MAC1, null, IP1, IP2);
proxyArp.reply(arpRequest, getLocation(6));
verifyFlood(arpRequest, configVlanCPoints);
}
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:ProxyArpManagerTest.java
示例7: sendPacketIn
import org.onlab.packet.Ethernet; //导入依赖的package包/类
@Override
public void sendPacketIn(PccId pccId) {
TCP tcp = new TCP();
// Set the well known PCEP port. To be used to decide to process/discard the packet while processing.
tcp.setDestinationPort(PCEP_PORT);
IPv4 ipv4 = new IPv4();
ipv4.setProtocol(IPv4.PROTOCOL_TCP);
ipv4.setPayload(tcp);
Ethernet eth = new Ethernet();
eth.setEtherType(Ethernet.TYPE_IPV4);
eth.setDestinationMACAddress(MacAddress.NONE);
eth.setPayload(ipv4);
// Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
String lsrId = String.valueOf(pccId.ipAddress());
DeviceId pccDeviceId = DeviceId.deviceId(lsrId);
InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(pccDeviceId,
PortNumber.portNumber(PCEP_PORT)),
eth, null);
packetProviderService.processPacket(new PcepPacketContext(inPkt, null));
}
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:PcepPacketProvider.java
示例8: transitFlow
import org.onlab.packet.Ethernet; //导入依赖的package包/类
private FlowRule transitFlow(PortNumber inPort, Link link,
MplsPathIntent intent,
MplsLabel prevLabel,
MplsLabel outLabel) {
// Ignore the ingress Traffic Selector and use only the MPLS label
// assigned in the previous link
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchInPort(inPort).matchEthType(Ethernet.MPLS_UNICAST)
.matchMplsLabel(prevLabel);
TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
// Set the new label only if the label on the packet is
// different
if (!prevLabel.equals(outLabel)) {
treat.setMpls(outLabel);
}
treat.setOutput(link.src().port());
return createFlowRule(intent, link.src().deviceId(), selector.build(), treat.build());
}
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:MplsPathIntentCompiler.java
示例9: populateRuleToGateway
import org.onlab.packet.Ethernet; //导入依赖的package包/类
private void populateRuleToGateway(Device d, Device gatewayDevice, long vni) {
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
.matchTunnelId(vni)
.matchEthDst(GATEWAYMAC);
tBuilder.extension(buildNiciraExtenstion(d.id(), config.nodes().get(gatewayDevice.id())), d.id())
.setOutput(getTunnelPort(d.id()));
ForwardingObjective fo = DefaultForwardingObjective.builder()
.withSelector(sBuilder.build())
.withTreatment(tBuilder.build())
.withFlag(ForwardingObjective.Flag.SPECIFIC)
.withPriority(ROUTING_RULE_PRIORITY)
.fromApp(appId)
.add();
flowObjectiveService.forward(d.id(), fo);
}
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:OpenstackRoutingRulePopulator.java
示例10: inPacket
import org.onlab.packet.Ethernet; //导入依赖的package包/类
@Override
public InboundPacket inPacket() {
IPv4 ipv4 = new IPv4();
ipv4.setDestinationAddress("10.0.0.1");
ipv4.setSourceAddress(IP_ADDRESS.toString());
Ethernet eth = new Ethernet();
eth.setEtherType(Ethernet.TYPE_IPV4)
.setVlanID(VLAN.toShort())
.setSourceMACAddress(MAC)
.setDestinationMACAddress(MacAddress.valueOf("00:00:00:00:00:01"))
.setPayload(ipv4);
ConnectPoint receivedFrom = new ConnectPoint(deviceId(deviceId),
portNumber(INPORT));
return new DefaultInboundPacket(receivedFrom, eth,
ByteBuffer.wrap(eth.serialize()));
}
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:HostLocationProviderTest.java
示例11: testReplyUnknownIpv6
import org.onlab.packet.Ethernet; //导入依赖的package包/类
/**
* Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
* destination host is not known.
* Verifies the NDP request is flooded out the correct edge ports.
*/
@Test
public void testReplyUnknownIpv6() {
Host requestor = new DefaultHost(PID, HID4, MAC4, VLAN1, getLocation(NUM_DEVICES),
Collections.singleton(IP4));
expect(hostService.getHostsByIp(IP3))
.andReturn(Collections.emptySet());
expect(interfaceService.getInterfacesByIp(IP4))
.andReturn(Collections.emptySet());
expect(hostService.getHost(HID4)).andReturn(requestor);
replay(hostService);
replay(interfaceService);
Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION,
MAC4, SOLICITED_MAC3,
IP4, IP3);
proxyArp.reply(ndpRequest, getLocation(NUM_DEVICES));
verifyFlood(ndpRequest, noConfigCPoints);
}
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:ProxyArpManagerTest.java
示例12: sendResponsePacketToHost
import org.onlab.packet.Ethernet; //导入依赖的package包/类
private void sendResponsePacketToHost(Ethernet icmpResponseEth, OpenstackPortInfo openstackPortInfo) {
Map.Entry<String, OpenstackPortInfo> entry = openstackSwitchingService.openstackPortInfo().entrySet().stream()
.filter(e -> e.getValue().mac().equals(openstackPortInfo.mac()))
.findAny().orElse(null);
if (entry == null) {
return;
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.setOutput(getPortForAnnotationPortName(openstackPortInfo.deviceId(), entry.getKey()))
.build();
OutboundPacket packet = new DefaultOutboundPacket(openstackPortInfo.deviceId(),
treatment, ByteBuffer.wrap(icmpResponseEth.serialize()));
packetService.emit(packet);
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OpenstackIcmpHandler.java
示例13: testCriteriaOrder
import org.onlab.packet.Ethernet; //导入依赖的package包/类
/**
* Tests criteria order is consistent.
*/
@Test
public void testCriteriaOrder() {
final TrafficSelector selector1 = DefaultTrafficSelector.builder()
.matchInPort(PortNumber.portNumber(11))
.matchEthType(Ethernet.TYPE_ARP)
.build();
final TrafficSelector selector2 = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_ARP)
.matchInPort(PortNumber.portNumber(11))
.build();
List<Criterion> criteria1 = Lists.newArrayList(selector1.criteria());
List<Criterion> criteria2 = Lists.newArrayList(selector2.criteria());
new EqualsTester().addEqualityGroup(criteria1, criteria2).testEquals();
}
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:DefaultTrafficSelectorTest.java
示例14: LinkDiscovery
import org.onlab.packet.Ethernet; //导入依赖的package包/类
/**
* Instantiates discovery manager for the given physical switch. Creates a
* generic LLDP packet that will be customized for the port it is sent out on.
* Starts the the timer for the discovery process.
*
* @param device the physical switch
* @param context discovery context
*/
public LinkDiscovery(Device device, LinkDiscoveryContext context) {
this.device = device;
this.context = context;
ethPacket = new Ethernet();
ethPacket.setEtherType(Ethernet.TYPE_LLDP);
ethPacket.setDestinationMACAddress(ONOSLLDP.LLDP_NICIRA);
ethPacket.setPad(true);
bddpEth = new Ethernet();
bddpEth.setEtherType(Ethernet.TYPE_BSN);
bddpEth.setDestinationMACAddress(ONOSLLDP.BDDP_MULTICAST);
bddpEth.setPad(true);
isStopped = true;
start();
log.debug("Started discovery manager for switch {}", device.id());
}
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:LinkDiscovery.java
示例15: handlePacketIn
import org.onlab.packet.Ethernet; //导入依赖的package包/类
@Override
public void handlePacketIn(Bmv2Device device, int inputPort, ImmutableByteSequence packet) {
Ethernet ethPkt = new Ethernet();
ethPkt.deserialize(packet.asArray(), 0, packet.size());
DeviceId deviceId = device.asDeviceId();
ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(inputPort));
ByteBuffer rawData = ByteBuffer.wrap(packet.asArray());
InboundPacket inPkt = new DefaultInboundPacket(receivedFrom, ethPkt, rawData);
OutboundPacket outPkt = new DefaultOutboundPacket(deviceId, null, rawData);
PacketContext pktCtx = new Bmv2PacketContext(System.currentTimeMillis(), inPkt, outPkt, false);
providerService.processPacket(pktCtx);
}
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:Bmv2PacketProvider.java
示例16: generateIntents
import org.onlab.packet.Ethernet; //导入依赖的package包/类
private List<Intent> generateIntents(ConnectPoint ingress, ConnectPoint egress) {
TrafficSelector.Builder selectorBldr = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4);
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
List<Intent> intents = Lists.newArrayList();
for (int i = 0; i < count; i++) {
TrafficSelector selector = selectorBldr
.matchEthSrc(MacAddress.valueOf(i + keyOffset))
.build();
intents.add(
PointToPointIntent.builder()
.appId(appId())
.key(Key.of(i + keyOffset, appId()))
.selector(selector)
.treatment(treatment)
.ingressPoint(ingress)
.egressPoint(egress)
.build());
}
return intents;
}
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:IntentCycleCommand.java
示例17: generateIntents
import org.onlab.packet.Ethernet; //导入依赖的package包/类
private List<Intent> generateIntents(ConnectPoint ingress, ConnectPoint egress) {
TrafficSelector.Builder selectorBldr = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4);
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
List<Intent> intents = Lists.newArrayList();
for (int i = 0; i < count; i++) {
TrafficSelector selector = selectorBldr
.matchEthSrc(MacAddress.valueOf(i + keyOffset))
.build();
intents.add(PointToPointIntent.builder()
.appId(appId())
.key(Key.of(i + keyOffset, appId()))
.selector(selector)
.treatment(treatment)
.ingressPoint(ingress)
.egressPoint(egress)
.build());
keysForInstall.add(Key.of(i + keyOffset, appId()));
keysForWithdraw.add(Key.of(i + keyOffset, appId()));
}
return intents;
}
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:IntentPushTestCommand.java
示例18: testReplyDifferentVlan
import org.onlab.packet.Ethernet; //导入依赖的package包/类
/**
* Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
* destination host is known for that IP address, but is not on the same
* VLAN as the source host.
* An host is connected on device 6, port 1 where no interfaces are defined. It sends
* ARP requests from VLAN10, not configured anywhere in the network. Another host with
* the IP address requested lives on device 5, port 1 in the network. Anyway, since the
* host uses another VLAN it's not found and the ARP packet is flooded out of port
* 4 and 5.
*
* Verifies the ARP request is flooded out the correct edge ports.
*/
@Test
public void testReplyDifferentVlan() {
Host requestor = new DefaultHost(PID, HID10, MAC10, VLAN10, getLocation(NUM_DEVICES),
Collections.singleton(IP1));
Host replyer = new DefaultHost(PID, HID2, MAC2, VLAN2, getLocation(NUM_DEVICES - 1),
Collections.singleton(IP2));
expect(hostService.getHostsByIp(IP2))
.andReturn(Collections.singleton(replyer));
expect(interfaceService.getInterfacesByIp(IP1))
.andReturn(Collections.emptySet());
expect(hostService.getHost(HID10)).andReturn(requestor);
replay(hostService);
replay(interfaceService);
Ethernet arpRequest = buildArp(ARP.OP_REQUEST, VLAN10, MAC10, null, IP1, IP2);
proxyArp.reply(arpRequest, getLocation(NUM_DEVICES));
verifyFlood(arpRequest, noConfigCPoints);
}
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:ProxyArpManagerTest.java
示例19: process
import org.onlab.packet.Ethernet; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
// Stop processing if the packet has been handled, since we
// can't do any more to it.
if (context.isHandled()) {
return;
}
Ethernet packet = context.inPacket().parsed();
if (packet == null) {
return;
}
if (packet.getEtherType() == Ethernet.TYPE_IPV4) {
IPv4 ipv4Packet = (IPv4) packet.getPayload();
if (ipv4Packet.getProtocol() == IPv4.PROTOCOL_TCP) {
TCP tcpPacket = (TCP) ipv4Packet.getPayload();
if (tcpPacket.getDestinationPort() == BGP_PORT ||
tcpPacket.getSourcePort() == BGP_PORT) {
forward(context);
}
}
}
}
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:TunnellingConnectivityManager.java
示例20: process
import org.onlab.packet.Ethernet; //导入依赖的package包/类
@Override
public void process(PacketContext context) {
if (context.isHandled()) {
return;
}
InboundPacket pkt = context.inPacket();
Ethernet ethernet = pkt.parsed();
log.trace("Rcvd pktin: {}", ethernet);
if (ethernet.getEtherType() == Ethernet.TYPE_ARP) {
arpHandler.processPacketIn(pkt);
} else if (ethernet.getEtherType() == Ethernet.TYPE_IPV4) {
IPv4 ipPacket = (IPv4) ethernet.getPayload();
ipHandler.addToPacketBuffer(ipPacket);
if (ipPacket.getProtocol() == IPv4.PROTOCOL_ICMP) {
icmpHandler.processPacketIn(pkt);
} else {
ipHandler.processPacketIn(pkt);
}
}
}
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:SegmentRoutingManager.java
注:本文中的org.onlab.packet.Ethernet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论