import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.packet.Ethernet;
import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService;
+import org.opendaylight.controller.sal.packet.PacketException;
import org.opendaylight.controller.sal.packet.PacketResult;
import org.opendaylight.controller.sal.packet.RawPacket;
import org.opendaylight.controller.sal.utils.GlobalConstants;
import org.opendaylight.controller.sal.utils.HexEncode;
+import org.opendaylight.controller.sal.utils.NetUtils;
import org.openflow.protocol.OFMessage;
import org.openflow.protocol.OFPacketIn;
import org.openflow.protocol.OFPacketOut;
@Override
public void receive(ISwitch sw, OFMessage msg) {
- if (sw == null || msg == null
- || this.pluginOutDataPacketServices == null) {
+ if (sw == null || msg == null || this.pluginOutDataPacketServices == null) {
// Something fishy, we cannot do anything
- logger.debug(
- "sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!",
- new Object[] { sw, msg, this.pluginOutDataPacketServices });
+ logger.debug("sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!", new Object[] { sw,
+ msg, this.pluginOutDataPacketServices });
return;
}
logger.debug("Connection service refused DataPacketMuxDemux receive {} {}", sw, msg);
return;
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
return;
}
// pass the parsed packet simply because once the
// packet infra is settled all the packets will passed
// around as parsed and read-only
- for (int i = 0; i < this.iDataPacketListen.size(); i++) {
- IDataPacketListen s = this.iDataPacketListen.get(i);
- if (s.receiveDataPacket(dataPacket).equals(
- PacketResult.CONSUME)) {
+ for (IDataPacketListen s : this.iDataPacketListen) {
+ if (s.receiveDataPacket(dataPacket).equals(PacketResult.CONSUME)) {
logger.trace("Consumed locally data packet");
return;
}
}
- // Now dispatch the packet toward SAL at least for
- // default container, we need to revisit this in a general
- // slicing architecture refresh
+ // Now dispatch the packet toward SAL for default container
IPluginOutDataPacketService defaultOutService = this.pluginOutDataPacketServices
.get(GlobalConstants.DEFAULT.toString());
if (defaultOutService != null) {
defaultOutService.receiveDataPacket(dataPacket);
if (logger.isTraceEnabled()) {
- logger.trace(
- "Dispatched to apps a frame of size: {} on " +
- "container: {}: {}", new Object[] {
- ofPacket.getPacketData().length,
- GlobalConstants.DEFAULT.toString(),
- HexEncode.bytesToHexString(dataPacket
- .getPacketData()) });
+ logger.trace("Dispatched to apps a frame of size: {} on " + "container: {}: {}",
+ new Object[] { ofPacket.getPacketData().length, GlobalConstants.DEFAULT.toString(),
+ HexEncode.bytesToHexString(dataPacket.getPacketData()) });
}
}
// Now check the mapping between nodeConnector and
// flowSpec
List<String> containersRX = this.nc2Container.get(p);
if (containersRX != null) {
- for (int i = 0; i < containersRX.size(); i++) {
- String container = containersRX.get(i);
- IPluginOutDataPacketService s = this.pluginOutDataPacketServices
- .get(container);
- if (s != null) {
- // TODO add filtering on a per-flowSpec base
- s.receiveDataPacket(dataPacket);
- if (logger.isTraceEnabled()) {
- logger.trace(
- "Dispatched to apps a frame of size: {}" +
- " on container: {}: {}", new Object[] {
- ofPacket.getPacketData().length,
- container,
- HexEncode.bytesToHexString(dataPacket
- .getPacketData()) });
+ Ethernet frame = new Ethernet();
+ byte data[] = dataPacket.getPacketData();
+ frame.deserialize(data, 0, data.length * NetUtils.NumBitsInAByte);
+ Match packetMatch = frame.getMatch();
+ for (String container : containersRX) {
+ boolean notify = true;
+ List<ContainerFlow> containerFlows = this.container2FlowSpecs.get(container);
+ if (containerFlows != null) {
+ notify = false;
+ for (ContainerFlow cFlow : containerFlows) {
+ if (cFlow.allowsMatch(packetMatch)) {
+ notify = true;
+ break;
+ }
+ }
+ if (notify) {
+ IPluginOutDataPacketService s = this.pluginOutDataPacketServices.get(container);
+ if (s != null) {
+ s.receiveDataPacket(dataPacket);
+ if (logger.isTraceEnabled()) {
+ logger.trace(
+ "Dispatched to apps a frame of size: {}" + " on container: {}: {}",
+ new Object[] { ofPacket.getPacketData().length, container,
+ HexEncode.bytesToHexString(dataPacket.getPacketData()) });
+ }
+ }
}
}
}
}
-
// This is supposed to be the catch all for all the
// DataPacket hence we will assume it has been handled
return;
} catch (ConstructionException cex) {
+ } catch (PacketException e) {
+ logger.debug("Failed to deserialize raw packet: ", e.getMessage());
}
-
// If we reach this point something went wrong.
return;
} else {
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
ARP other = (ARP) obj;
if (fieldValues == null) {
- if (other.fieldValues != null)
+ if (other.fieldValues != null) {
return false;
- } else if (!fieldValues.equals(other.fieldValues))
+ }
+ } else if (!fieldValues.equals(other.fieldValues)) {
return false;
+ }
return true;
}
}
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
import org.opendaylight.controller.sal.utils.EtherTypes;
import org.opendaylight.controller.sal.utils.NetUtils;
return this;
}
+ @Override
+ public void populateMatch(Match match) {
+ match.setField(MatchType.DL_SRC, this.getSourceMACAddress());
+ match.setField(MatchType.DL_DST, this.getDestinationMACAddress());
+ match.setField(MatchType.DL_TYPE, this.getEtherType());
+ }
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import java.util.Map;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
/**
* Class that represents the IEEE 802.1Q objects
return this;
}
+ @Override
+ public void populateMatch(Match match) {
+ match.setField(MatchType.DL_VLAN, this.getVid());
+ match.setField(MatchType.DL_VLAN_PR, this.getPcp());
+ match.setField(MatchType.DL_TYPE, this.getEtherType());
+ }
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
import org.opendaylight.controller.sal.utils.IPProtocols;
import org.opendaylight.controller.sal.utils.NetUtils;
import org.slf4j.Logger;
corrupted = true;
}
}
+
+ @Override
+ public void populateMatch(Match match) {
+ match.setField(MatchType.NW_SRC, NetUtils.getInetAddress(this.getSourceAddress()));
+ match.setField(MatchType.NW_DST, NetUtils.getInetAddress(this.getDestinationAddress()));
+ match.setField(MatchType.NW_PROTO, this.getProtocol());
+ match.setField(MatchType.NW_TOS, this.getDiffServ());
+ }
}
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+
import org.opendaylight.controller.sal.utils.HexEncode;
import org.opendaylight.controller.sal.utils.NetUtils;
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
LLDPTLV other = (LLDPTLV) obj;
if (fieldValues == null) {
- if (other.fieldValues != null)
+ if (other.fieldValues != null) {
return false;
- } else if (!fieldValues.equals(other.fieldValues))
+ }
+ } else if (!fieldValues.equals(other.fieldValues)) {
return false;
+ }
return true;
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import java.util.Map.Entry;
import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
import org.opendaylight.controller.sal.utils.HexEncode;
import org.opendaylight.controller.sal.utils.NetUtils;
import org.slf4j.Logger;
return true;
}
+ /**
+ * Adds to the passed Match this packet's header fields
+ *
+ * @param match
+ * The Match object to populate
+ */
+ public void populateMatch(Match match) {
+ // To be overridden by derived packet classes which have well known
+ // header fields so that Packet.getMatch would return desired result
+ }
+
+ /**
+ * Returns the Match object containing this packet and its payload
+ * encapsulated packets' header fields
+ *
+ * @return The Match containing the header fields of this packet and of its
+ * payload encapsulated packets
+ */
+ public Match getMatch() {
+ Match match = new Match();
+ Packet packet = this;
+ while (packet != null) {
+ packet.populateMatch(match);
+ packet = packet.getPayload();
+ }
+ return match;
+ }
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
/**
* Class that represents the TCP segment objects
return (BitBufferHelper.getShort(fieldValues.get(CHECKSUM)));
}
+ @Override
+ public void populateMatch(Match match) {
+ match.setField(MatchType.TP_SRC, this.getSourcePort());
+ match.setField(MatchType.TP_DST, this.getDestinationPort());
+ }
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
/**
* Class that represents the UDP datagram objects
fieldValues.put(CHECKSUM, checksum);
return this;
}
+
+ @Override
+ public void populateMatch(Match match) {
+ match.setField(MatchType.TP_SRC, this.getSourcePort());
+ match.setField(MatchType.TP_DST, this.getDestinationPort());
+ }
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.controller.sal.packet;
+import java.util.Arrays;
+
import junit.framework.Assert;
import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
+import org.opendaylight.controller.sal.utils.EtherTypes;
public class EthernetTest {
}
+ @Test
+ public void testGetMatch() throws Exception {
+ Ethernet eth = new Ethernet();
+ byte smac[] = { (byte) 0xf0, (byte) 0xde, (byte) 0xf1, (byte) 0x71, (byte) 0x72, (byte) 0x8d };
+ byte dmac[] = { (byte) 0xde, (byte) 0x28, (byte) 0xdb, (byte) 0xb3, (byte) 0x7c, (byte) 0xf8 };
+ short ethType = EtherTypes.IPv4.shortValue();
+ eth.setDestinationMACAddress(dmac);
+ eth.setSourceMACAddress(smac);
+ eth.setEtherType(ethType);
+
+ Match match = eth.getMatch();
+
+ Assert.assertTrue(Arrays.equals(smac, (byte[]) match.getField(MatchType.DL_SRC).getValue()));
+ Assert.assertTrue(Arrays.equals(dmac, (byte[]) match.getField(MatchType.DL_DST).getValue()));
+ Assert.assertEquals(ethType, (short) match.getField(MatchType.DL_TYPE).getValue());
+
+ }
+
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.controller.sal.packet;
import junit.framework.Assert;
+
import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
+import org.opendaylight.controller.sal.utils.EtherTypes;
import org.opendaylight.controller.sal.utils.NetUtils;
public class IEEE8021QTest {
Assert.assertTrue(data[44] == (byte) 0x09);
Assert.assertTrue(data[45] == (byte) 0xFE);
}
+
+ @Test
+ public void testGetMatchFullPacket() throws Exception {
+ IEEE8021Q dot1q = new IEEE8021Q();
+ byte priority = 4;
+ short vlanId = 59;
+ short ethType = EtherTypes.IPv4.shortValue();
+ dot1q.setPcp(priority);
+ dot1q.setVid(vlanId);
+ dot1q.setEtherType(ethType);
+
+ Match match = dot1q.getMatch();
+
+ Assert.assertEquals(priority, (byte) match.getField(MatchType.DL_VLAN_PR).getValue());
+ Assert.assertEquals(vlanId, (short) match.getField(MatchType.DL_VLAN).getValue());
+ Assert.assertEquals(ethType, (short) match.getField(MatchType.DL_TYPE).getValue());
+ }
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import junit.framework.Assert;
import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
import org.opendaylight.controller.sal.utils.EtherTypes;
import org.opendaylight.controller.sal.utils.IPProtocols;
import org.opendaylight.controller.sal.utils.NetUtils;
Assert.assertFalse(decIcmp.isCorrupted());
Assert.assertTrue(Arrays.equals(icmpRawPayload, decIcmp.getRawPayload()));
}
+
+ @Test
+ public void testGetMatch() throws Exception {
+ IPv4 ip = new IPv4();
+ InetAddress sourceAddress = InetAddress.getByName("172.168.190.15");
+ InetAddress destintationAddress = InetAddress.getByName("23.128.0.11");
+ byte protocol = IPProtocols.TCP.byteValue();
+ byte tos = 7;
+ ip.setVersion((byte) 4);
+ ip.setIdentification((short) 5);
+ ip.setDiffServ(tos);
+ ip.setECN((byte) 0);
+ ip.setTotalLength((short) 84);
+ ip.setFlags((byte) 2);
+ ip.setFragmentOffset((short) 0);
+ ip.setTtl((byte) 64);
+ ip.setProtocol(protocol);
+ ip.setDestinationAddress(destintationAddress);
+ ip.setSourceAddress(sourceAddress);
+
+ Match match = ip.getMatch();
+
+ Assert.assertEquals(sourceAddress, match.getField(MatchType.NW_SRC).getValue());
+ Assert.assertEquals(destintationAddress, match.getField(MatchType.NW_DST).getValue());
+ Assert.assertEquals(protocol, (byte) match.getField(MatchType.NW_PROTO).getValue());
+ Assert.assertEquals(tos, (byte) match.getField(MatchType.NW_TOS).getValue());
+ }
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.controller.sal.packet;
+import java.net.InetAddress;
+import java.util.Arrays;
import java.util.Map;
import junit.framework.Assert;
import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
+import org.opendaylight.controller.sal.utils.EtherTypes;
+import org.opendaylight.controller.sal.utils.IPProtocols;
public class PacketTest {
eth.setSourceMACAddress(sMAC);
eth.setEtherType(etherType);
- dMACdata = (byte[]) fCValues.get("DestinationMACAddress");
- sMACdata = (byte[]) fCValues.get("SourceMACAddress");
- etherTypedata = (byte[]) fCValues.get("EtherType");
+ dMACdata = fCValues.get("DestinationMACAddress");
+ sMACdata = fCValues.get("SourceMACAddress");
+ etherTypedata = fCValues.get("EtherType");
Assert.assertTrue(dMACdata[0] == 10);
Assert.assertTrue(dMACdata[1] == 12);
Assert.assertTrue(data[13] == 6);
}
+
+ @Test
+ public void testGetMatch() throws Exception {
+ TCP tcp = new TCP();
+ short sport = (short) 11093;
+ short dport = (short) 23;
+ tcp.setSourcePort(sport);
+ tcp.setDestinationPort(dport);
+
+ IPv4 ip = new IPv4();
+ InetAddress sourceAddress = InetAddress.getByName("192.168.100.100");
+ InetAddress destintationAddress = InetAddress.getByName("192.168.100.101");
+ byte protocol = IPProtocols.TCP.byteValue();
+ byte tos = 5;
+ ip.setVersion((byte) 4);
+ ip.setIdentification((short) 5);
+ ip.setDiffServ(tos);
+ ip.setECN((byte) 0);
+ ip.setTotalLength((short) 84);
+ ip.setFlags((byte) 2);
+ ip.setFragmentOffset((short) 0);
+ ip.setTtl((byte) 64);
+ ip.setProtocol(protocol);
+ ip.setDestinationAddress(destintationAddress);
+ ip.setSourceAddress(sourceAddress);
+ ip.setPayload(tcp);
+
+ IEEE8021Q dot1q = new IEEE8021Q();
+ byte priority = 4;
+ short vlanId = 59;
+ short ethType = EtherTypes.IPv4.shortValue();
+ dot1q.setPcp(priority);
+ dot1q.setVid(vlanId);
+ dot1q.setEtherType(ethType);
+ dot1q.setPayload(ip);
+
+ Ethernet eth = new Ethernet();
+ byte smac[] = { (byte) 0xf0, (byte) 0xde, (byte) 0xf1, (byte) 0x71, (byte) 0x72, (byte) 0x8d };
+ byte dmac[] = { (byte) 0xde, (byte) 0x28, (byte) 0xdb, (byte) 0xb3, (byte) 0x7c, (byte) 0xf8 };
+ eth.setDestinationMACAddress(dmac);
+ eth.setSourceMACAddress(smac);
+ eth.setEtherType(EtherTypes.VLANTAGGED.shortValue());
+ eth.setPayload(dot1q);
+
+ Match match = eth.getMatch();
+
+ Assert.assertTrue(Arrays.equals(smac, (byte[]) match.getField(MatchType.DL_SRC).getValue()));
+ Assert.assertTrue(Arrays.equals(dmac, (byte[]) match.getField(MatchType.DL_DST).getValue()));
+ Assert.assertEquals(priority, (byte) match.getField(MatchType.DL_VLAN_PR).getValue());
+ Assert.assertEquals(vlanId, (short) match.getField(MatchType.DL_VLAN).getValue());
+ Assert.assertEquals(ethType, (short) match.getField(MatchType.DL_TYPE).getValue());
+ Assert.assertEquals(sourceAddress, match.getField(MatchType.NW_SRC).getValue());
+ Assert.assertEquals(destintationAddress, match.getField(MatchType.NW_DST).getValue());
+ Assert.assertEquals(protocol, (byte) match.getField(MatchType.NW_PROTO).getValue());
+ Assert.assertEquals(tos, (byte) match.getField(MatchType.NW_TOS).getValue());
+ Assert.assertEquals(sport, (short) match.getField(MatchType.TP_SRC).getValue());
+ Assert.assertEquals(dport, (short) match.getField(MatchType.TP_DST).getValue());
+ }
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import junit.framework.Assert;
import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
public class TCPTest {
short checksum = tcp.getChecksum();
Assert.assertTrue(checksum == 200);
}
+
+ @Test
+ public void testGetMatch() throws Exception {
+ TCP tcp = new TCP();
+ short sport = (short) 52012;
+ short dport = (short) 40345;
+ tcp.setSourcePort(sport);
+ tcp.setDestinationPort(dport);
+
+ Match match = tcp.getMatch();
+
+ Assert.assertEquals(sport, (short) match.getField(MatchType.TP_SRC).getValue());
+ Assert.assertEquals(dport, (short) match.getField(MatchType.TP_DST).getValue());
+ }
}
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import junit.framework.Assert;
import org.junit.Test;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
public class UDPTest {
}
+ @Test
+ public void testGetMatch() throws Exception {
+ UDP udp = new UDP();
+ short sport = (short) 33000;
+ short dport = (short) 843;
+ udp.setSourcePort(sport);
+ udp.setDestinationPort(dport);
+
+ Match match = udp.getMatch();
+
+ Assert.assertEquals(sport, (short) match.getField(MatchType.TP_SRC).getValue());
+ Assert.assertEquals(dport, (short) match.getField(MatchType.TP_DST).getValue());
+
+ }
+
}