diff --git a/src/main/java/org.onosproject.xran/XranStore.java b/src/main/java/org.onosproject.xran/XranStore.java
new file mode 100644
index 0000000..e925cf0
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/XranStore.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.store.Store;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.MMEUES1APID;
+import org.onosproject.xran.controller.XranController;
+import org.onosproject.xran.entities.RnibCell;
+import org.onosproject.xran.entities.RnibLink;
+import org.onosproject.xran.entities.RnibSlice;
+import org.onosproject.xran.entities.RnibUe;
+import org.onosproject.xran.identifiers.LinkId;
+
+import java.util.List;
+
+/**
+ * Created by dimitris on 7/22/17.
+ */
+public interface XranStore extends Store {
+
+    // LINKS STORE
+
+    List<RnibLink> getLinks();
+
+    List<RnibLink> getLinksByECGI(ECGI ecgi);
+
+    List<RnibLink> getLinksByCellId(String eciHex);
+
+    List<RnibLink> getLinksByUeId(long euId);
+
+    RnibLink getLinkBetweenCellIdUeId(String cellId, long euId);
+
+    boolean createLinkBetweenCellIdUeId(String cellId, long euId, String type);
+
+    RnibLink getLink(ECGI ecgi, MMEUES1APID mme);
+
+    void storeLink(RnibLink link);
+
+    boolean removeLink(LinkId link);
+
+    // NODES
+
+    List<Object> getNodes();
+
+    List<RnibCell> getCellNodes();
+
+    List<RnibUe> getUeNodes();
+
+    Object getByNodeId(String nodeId);
+
+    // CELL
+
+    RnibCell getCell(String eci);
+
+    RnibCell getCell(ECGI cellId);
+
+    boolean modifyCellRrmConf(String eci, JsonNode rrmConf);
+
+    void storeCell(RnibCell cell);
+
+    boolean removeCell(ECGI ecgi);
+
+    // SLICE
+
+    RnibSlice getSlice(long sliceId);
+
+    boolean createSlice(ObjectNode attributes);
+
+    boolean removeCell(long sliceId);
+
+    // CONTROLLER
+
+    XranController getController();
+
+    void setController(XranController controller);
+
+    // UE
+
+    RnibUe getUe(long euId);
+
+    RnibUe getUe(MMEUES1APID mme);
+
+    void storeUe(RnibUe ue);
+
+    boolean removeUe(MMEUES1APID mme);
+}
diff --git a/src/main/java/org.onosproject.xran/annotations/Patch.java b/src/main/java/org.onosproject.xran/annotations/Patch.java
new file mode 100644
index 0000000..8058902
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/annotations/Patch.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.annotations;
+
+import javax.ws.rs.HttpMethod;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Created by dimitris on 7/21/17.
+ */
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@HttpMethod("Patch")
+public @interface Patch { }
diff --git a/src/main/java/org.onosproject.xran/annotations/package-info.java b/src/main/java/org.onosproject.xran/annotations/package-info.java
new file mode 100644
index 0000000..e035cf2
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/annotations/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Created by dimitris on 7/21/17.
+ */
+package org.onosproject.xran.annotations;
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ARFCNValue.java b/src/main/java/org.onosproject.xran/codecs/api/ARFCNValue.java
new file mode 100644
index 0000000..cffdb07
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ARFCNValue.java
@@ -0,0 +1,44 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.types.BerInteger;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+
+
+public class ARFCNValue extends BerInteger {
+
+	private static final long serialVersionUID = 1L;
+
+	public ARFCNValue() {
+	}
+
+	public ARFCNValue(byte[] code) {
+		super(code);
+	}
+
+	public ARFCNValue(BigInteger value) {
+		super(value);
+	}
+
+	public ARFCNValue(long value) {
+		super(value);
+	}
+
+	@Override
+	public int hashCode() {
+		return value.intValue();
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof ARFCNValue) {
+			return value.intValue() == ((ARFCNValue) obj).value.intValue();
+		}
+		return super.equals(obj);
+	}
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/AdmEstCause.java b/src/main/java/org.onosproject.xran/codecs/api/AdmEstCause.java
new file mode 100644
index 0000000..e344fc5
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/AdmEstCause.java
@@ -0,0 +1,31 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.types.BerEnum;
+
+import java.math.BigInteger;
+
+
+public class AdmEstCause extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public AdmEstCause() {
+	}
+
+	public AdmEstCause(byte[] code) {
+		super(code);
+	}
+
+	public AdmEstCause(BigInteger value) {
+		super(value);
+	}
+
+	public AdmEstCause(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/AdmEstResponse.java b/src/main/java/org.onosproject.xran/codecs/api/AdmEstResponse.java
new file mode 100644
index 0000000..388b64e
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/AdmEstResponse.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class AdmEstResponse extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public AdmEstResponse() {
+	}
+
+	public AdmEstResponse(byte[] code) {
+		super(code);
+	}
+
+	public AdmEstResponse(BigInteger value) {
+		super(value);
+	}
+
+	public AdmEstResponse(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/AdmEstStatus.java b/src/main/java/org.onosproject.xran/codecs/api/AdmEstStatus.java
new file mode 100644
index 0000000..68680a6
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/AdmEstStatus.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class AdmEstStatus extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public AdmEstStatus() {
+	}
+
+	public AdmEstStatus(byte[] code) {
+		super(code);
+	}
+
+	public AdmEstStatus(BigInteger value) {
+		super(value);
+	}
+
+	public AdmEstStatus(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/BitRate.java b/src/main/java/org.onosproject.xran/codecs/api/BitRate.java
new file mode 100644
index 0000000..7b0b49d
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/BitRate.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class BitRate extends BerInteger {
+
+	private static final long serialVersionUID = 1L;
+
+	public BitRate() {
+	}
+
+	public BitRate(byte[] code) {
+		super(code);
+	}
+
+	public BitRate(BigInteger value) {
+		super(value);
+	}
+
+	public BitRate(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/CACap.java b/src/main/java/org.onosproject.xran/codecs/api/CACap.java
new file mode 100644
index 0000000..cd2ef5c
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/CACap.java
@@ -0,0 +1,231 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerBoolean;
+import org.openmuc.jasn1.ber.types.BerEnum;
+import org.openmuc.jasn1.ber.types.BerInteger;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class CACap implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private BerInteger band = null;
+	private BerEnum caclassdl = null;
+	private BerEnum caclassul = null;
+	private BerBoolean crossCarrierSched = null;
+	
+	public CACap() {
+	}
+
+	public CACap(byte[] code) {
+		this.code = code;
+	}
+
+	public void setBand(BerInteger band) {
+		this.band = band;
+	}
+
+	public BerInteger getBand() {
+		return band;
+	}
+
+	public void setCaclassdl(BerEnum caclassdl) {
+		this.caclassdl = caclassdl;
+	}
+
+	public BerEnum getCaclassdl() {
+		return caclassdl;
+	}
+
+	public void setCaclassul(BerEnum caclassul) {
+		this.caclassul = caclassul;
+	}
+
+	public BerEnum getCaclassul() {
+		return caclassul;
+	}
+
+	public void setCrossCarrierSched(BerBoolean crossCarrierSched) {
+		this.crossCarrierSched = crossCarrierSched;
+	}
+
+	public BerBoolean getCrossCarrierSched() {
+		return crossCarrierSched;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += crossCarrierSched.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 3
+		os.write(0x83);
+		codeLength += 1;
+		
+		codeLength += caclassul.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += caclassdl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += band.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			band = new BerInteger();
+			subCodeLength += band.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			caclassdl = new BerEnum();
+			subCodeLength += caclassdl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			caclassul = new BerEnum();
+			subCodeLength += caclassul.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
+			crossCarrierSched = new BerBoolean();
+			subCodeLength += crossCarrierSched.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (band != null) {
+			sb.append("\"band\":").append(band);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (caclassdl != null) {
+			sb.append("\"caclassdl\":").append(caclassdl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (caclassul != null) {
+			sb.append("\"caclassul\":").append(caclassul);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crossCarrierSched != null) {
+			sb.append("\"crossCarrierSched\":").append(crossCarrierSched);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/CRNTI.java b/src/main/java/org.onosproject.xran/codecs/api/CRNTI.java
new file mode 100644
index 0000000..69d5f48
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/CRNTI.java
@@ -0,0 +1,56 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+import javax.xml.bind.DatatypeConverter;
+
+
+public class CRNTI extends BerBitString {
+
+	private static final long serialVersionUID = 1L;
+
+	public CRNTI() {
+	}
+
+	public CRNTI(byte[] code) {
+		super(code);
+	}
+
+	public CRNTI(byte[] value, int numBits) {
+		super(value, numBits);
+	}
+
+	@Override
+	public int hashCode() {
+		return Arrays.hashCode(value);
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof CRNTI) {
+			return Arrays.equals(value, ((CRNTI) obj).value);
+		}
+		return super.equals(obj);
+	}
+
+	@Override
+	public String toString() {
+		return "\"" + DatatypeConverter.printHexBinary(value) + "\"";
+	}
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/CandScell.java b/src/main/java/org.onosproject.xran/codecs/api/CandScell.java
new file mode 100644
index 0000000..7b954d0
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/CandScell.java
@@ -0,0 +1,165 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class CandScell implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private PhysCellId pci = null;
+	private ARFCNValue earfcnDl = null;
+	
+	public CandScell() {
+	}
+
+	public CandScell(byte[] code) {
+		this.code = code;
+	}
+
+	public void setPci(PhysCellId pci) {
+		this.pci = pci;
+	}
+
+	public PhysCellId getPci() {
+		return pci;
+	}
+
+	public void setEarfcnDl(ARFCNValue earfcnDl) {
+		this.earfcnDl = earfcnDl;
+	}
+
+	public ARFCNValue getEarfcnDl() {
+		return earfcnDl;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += earfcnDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += pci.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			pci = new PhysCellId();
+			subCodeLength += pci.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			earfcnDl = new ARFCNValue();
+			subCodeLength += earfcnDl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pci != null) {
+			sb.append("\"pci\": ").append(pci);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (earfcnDl != null) {
+			sb.append("\"earfcnDl\": ").append(earfcnDl);
+		}
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/DCCap.java b/src/main/java/org.onosproject.xran/codecs/api/DCCap.java
new file mode 100644
index 0000000..f3f7c61
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/DCCap.java
@@ -0,0 +1,136 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerEnum;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class DCCap implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private BerEnum drbTypeSplit = null;
+	
+	public DCCap() {
+	}
+
+	public DCCap(byte[] code) {
+		this.code = code;
+	}
+
+	public void setDrbTypeSplit(BerEnum drbTypeSplit) {
+		this.drbTypeSplit = drbTypeSplit;
+	}
+
+	public BerEnum getDrbTypeSplit() {
+		return drbTypeSplit;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += drbTypeSplit.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			drbTypeSplit = new BerEnum();
+			subCodeLength += drbTypeSplit.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (drbTypeSplit != null) {
+			sb.append("\"drbTypeSplit\": ").append(drbTypeSplit);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/DuplexMode.java b/src/main/java/org.onosproject.xran/codecs/api/DuplexMode.java
new file mode 100644
index 0000000..cfbd191
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/DuplexMode.java
@@ -0,0 +1,31 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.types.BerEnum;
+
+import java.math.BigInteger;
+
+
+public class DuplexMode extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public DuplexMode() {
+	}
+
+	public DuplexMode(byte[] code) {
+		super(code);
+	}
+
+	public DuplexMode(BigInteger value) {
+		super(value);
+	}
+
+	public DuplexMode(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ECGI.java b/src/main/java/org.onosproject.xran/codecs/api/ECGI.java
new file mode 100644
index 0000000..01789f2
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ECGI.java
@@ -0,0 +1,180 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class ECGI implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private PLMNIdentity pLMNIdentity = null;
+	private EUTRANCellIdentifier eUTRANcellIdentifier = null;
+	
+	public ECGI() {
+	}
+
+	public ECGI(byte[] code) {
+		this.code = code;
+	}
+
+	public void setPLMNIdentity(PLMNIdentity pLMNIdentity) {
+		this.pLMNIdentity = pLMNIdentity;
+	}
+
+	public PLMNIdentity getPLMNIdentity() {
+		return pLMNIdentity;
+	}
+
+	public void setEUTRANcellIdentifier(EUTRANCellIdentifier eUTRANcellIdentifier) {
+		this.eUTRANcellIdentifier = eUTRANcellIdentifier;
+	}
+
+	public EUTRANCellIdentifier getEUTRANcellIdentifier() {
+		return eUTRANcellIdentifier;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += eUTRANcellIdentifier.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += pLMNIdentity.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			pLMNIdentity = new PLMNIdentity();
+			subCodeLength += pLMNIdentity.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			eUTRANcellIdentifier = new EUTRANCellIdentifier();
+			subCodeLength += eUTRANcellIdentifier.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pLMNIdentity != null) {
+			sb.append("\"pLMNIdentity\": ").append(pLMNIdentity);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (eUTRANcellIdentifier != null) {
+			sb.append("\"eUTRANcellIdentifier\": ").append(eUTRANcellIdentifier);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+	@Override
+	public boolean equals(Object o) {
+		if (this == o) return true;
+		if (o == null || getClass() != o.getClass()) return false;
+
+		ECGI ecgi = (ECGI) o;
+
+		return eUTRANcellIdentifier.equals(ecgi.eUTRANcellIdentifier);
+	}
+
+	@Override
+	public int hashCode() {
+		return eUTRANcellIdentifier.hashCode();
+	}
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ENBUES1APID.java b/src/main/java/org.onosproject.xran/codecs/api/ENBUES1APID.java
new file mode 100644
index 0000000..2bb7c15
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ENBUES1APID.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class ENBUES1APID extends BerInteger {
+
+	private static final long serialVersionUID = 1L;
+
+	public ENBUES1APID() {
+	}
+
+	public ENBUES1APID(byte[] code) {
+		super(code);
+	}
+
+	public ENBUES1APID(BigInteger value) {
+		super(value);
+	}
+
+	public ENBUES1APID(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ERABDecision.java b/src/main/java/org.onosproject.xran/codecs/api/ERABDecision.java
new file mode 100644
index 0000000..7d50dc7
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ERABDecision.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class ERABDecision extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public ERABDecision() {
+	}
+
+	public ERABDecision(byte[] code) {
+		super(code);
+	}
+
+	public ERABDecision(BigInteger value) {
+		super(value);
+	}
+
+	public ERABDecision(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ERABDirection.java b/src/main/java/org.onosproject.xran/codecs/api/ERABDirection.java
new file mode 100644
index 0000000..d29502c
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ERABDirection.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class ERABDirection extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public ERABDirection() {
+	}
+
+	public ERABDirection(byte[] code) {
+		super(code);
+	}
+
+	public ERABDirection(BigInteger value) {
+		super(value);
+	}
+
+	public ERABDirection(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ERABID.java b/src/main/java/org.onosproject.xran/codecs/api/ERABID.java
new file mode 100644
index 0000000..92875c8
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ERABID.java
@@ -0,0 +1,52 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class ERABID extends BerInteger {
+
+	private static final long serialVersionUID = 1L;
+
+	public ERABID() {
+	}
+
+	public ERABID(byte[] code) {
+		super(code);
+	}
+
+	public ERABID(BigInteger value) {
+		super(value);
+	}
+
+	public ERABID(long value) {
+		super(value);
+	}
+
+	@Override
+	public int hashCode() {
+		return value.intValue();
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof ERABID) {
+			return value.intValue() == ((ERABID) obj).intValue();
+		}
+		return super.equals(obj);
+	}
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ERABParams.java b/src/main/java/org.onosproject.xran/codecs/api/ERABParams.java
new file mode 100644
index 0000000..237c5d9
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ERABParams.java
@@ -0,0 +1,154 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class ERABParams implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+	public byte[] code = null;
+	private List<ERABParamsItem> seqOf = null;
+
+	public ERABParams() {
+		seqOf = new ArrayList<ERABParamsItem>();
+	}
+
+	public ERABParams(byte[] code) {
+		this.code = code;
+	}
+
+	public List<ERABParamsItem> getERABParamsItem() {
+		if (seqOf == null) {
+			seqOf = new ArrayList<ERABParamsItem>();
+		}
+		return seqOf;
+	}
+
+	public void setERABParamsItem(ArrayList<ERABParamsItem> erabParamsItem) {
+		seqOf = erabParamsItem;
+	}
+
+	public void addERABParamsItem(ERABParamsItem erabParamsItem) {
+		seqOf.add(erabParamsItem);
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		for (int i = (seqOf.size() - 1); i >= 0; i--) {
+			codeLength += seqOf.get(i).encode(os, true);
+		}
+
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+		int totalLength = length.val;
+
+		while (subCodeLength < totalLength) {
+			ERABParamsItem element = new ERABParamsItem();
+			subCodeLength += element.decode(is, true);
+			seqOf.add(element);
+		}
+		if (subCodeLength != totalLength) {
+			throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+		}
+		codeLength += subCodeLength;
+
+		return codeLength;
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("[\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (seqOf == null) {
+//			sb.append("null");
+		}
+		else {
+			Iterator<ERABParamsItem> it = seqOf.iterator();
+			if (it.hasNext()) {
+				it.next().appendAsString(sb, indentLevel + 1);
+				while (it.hasNext()) {
+					sb.append(",\n");
+					for (int i = 0; i < indentLevel + 1; i++) {
+						sb.append("\t");
+					}
+					it.next().appendAsString(sb, indentLevel + 1);
+				}
+			}
+		}
+
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("]");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ERABParamsItem.java b/src/main/java/org.onosproject.xran/codecs/api/ERABParamsItem.java
new file mode 100644
index 0000000..9db7698
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ERABParamsItem.java
@@ -0,0 +1,386 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class ERABParamsItem implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ERABID id = null;
+	private ERABDirection direction = null;
+	private ERABType type = null;
+	private QCI qci = null;
+	private BerInteger arp = null;
+	private BitRate gbrDl = null;
+	private BitRate gbrUl = null;
+	private BitRate mbrDl = null;
+	private BitRate mbrUl = null;
+	
+	public ERABParamsItem() {
+	}
+
+	public ERABParamsItem(byte[] code) {
+		this.code = code;
+	}
+
+	public void setId(ERABID id) {
+		this.id = id;
+	}
+
+	public ERABID getId() {
+		return id;
+	}
+
+	public void setDirection(ERABDirection direction) {
+		this.direction = direction;
+	}
+
+	public ERABDirection getDirection() {
+		return direction;
+	}
+
+	public void setType(ERABType type) {
+		this.type = type;
+	}
+
+	public ERABType getType() {
+		return type;
+	}
+
+	public void setQci(QCI qci) {
+		this.qci = qci;
+	}
+
+	public QCI getQci() {
+		return qci;
+	}
+
+	public void setArp(BerInteger arp) {
+		this.arp = arp;
+	}
+
+	public BerInteger getArp() {
+		return arp;
+	}
+
+	public void setGbrDl(BitRate gbrDl) {
+		this.gbrDl = gbrDl;
+	}
+
+	public BitRate getGbrDl() {
+		return gbrDl;
+	}
+
+	public void setGbrUl(BitRate gbrUl) {
+		this.gbrUl = gbrUl;
+	}
+
+	public BitRate getGbrUl() {
+		return gbrUl;
+	}
+
+	public void setMbrDl(BitRate mbrDl) {
+		this.mbrDl = mbrDl;
+	}
+
+	public BitRate getMbrDl() {
+		return mbrDl;
+	}
+
+	public void setMbrUl(BitRate mbrUl) {
+		this.mbrUl = mbrUl;
+	}
+
+	public BitRate getMbrUl() {
+		return mbrUl;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += mbrUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 8
+		os.write(0x88);
+		codeLength += 1;
+		
+		codeLength += mbrDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 7
+		os.write(0x87);
+		codeLength += 1;
+		
+		codeLength += gbrUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 6
+		os.write(0x86);
+		codeLength += 1;
+		
+		codeLength += gbrDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 5
+		os.write(0x85);
+		codeLength += 1;
+		
+		codeLength += arp.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 4
+		os.write(0x84);
+		codeLength += 1;
+		
+		codeLength += qci.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 3
+		os.write(0x83);
+		codeLength += 1;
+		
+		codeLength += type.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += direction.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += id.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			id = new ERABID();
+			subCodeLength += id.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			direction = new ERABDirection();
+			subCodeLength += direction.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			type = new ERABType();
+			subCodeLength += type.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
+			qci = new QCI();
+			subCodeLength += qci.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
+			arp = new BerInteger();
+			subCodeLength += arp.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 5)) {
+			gbrDl = new BitRate();
+			subCodeLength += gbrDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
+			gbrUl = new BitRate();
+			subCodeLength += gbrUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) {
+			mbrDl = new BitRate();
+			subCodeLength += mbrDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
+			mbrUl = new BitRate();
+			subCodeLength += mbrUl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (id != null) {
+			sb.append("\"id\": ").append(id);
+		}
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (direction != null) {
+			sb.append("\"direction\": ").append(direction);
+		}
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (type != null) {
+			sb.append("\"type\": ").append(type);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (qci != null) {
+			sb.append("\"qci\": ").append(qci);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (arp != null) {
+			sb.append("\"arp\": ").append(arp);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (gbrDl != null) {
+			sb.append("\"gbrDl\": ").append(gbrDl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (gbrUl != null) {
+			sb.append("\"gbrUl\": ").append(gbrUl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (mbrDl != null) {
+			sb.append("\"mbrDl\": ").append(mbrDl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (mbrUl != null) {
+			sb.append("\"mbrUl\": ").append(mbrUl);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ERABResponse.java b/src/main/java/org.onosproject.xran/codecs/api/ERABResponse.java
new file mode 100644
index 0000000..fdf66fa
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ERABResponse.java
@@ -0,0 +1,150 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class ERABResponse implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+	public byte[] code = null;
+	private List<ERABResponseItem> seqOf = null;
+
+	public ERABResponse() {
+		seqOf = new ArrayList<ERABResponseItem>();
+	}
+
+	public ERABResponse(byte[] code) {
+		this.code = code;
+	}
+
+	public List<ERABResponseItem> getERABResponseItem() {
+		if (seqOf == null) {
+			seqOf = new ArrayList<ERABResponseItem>();
+		}
+		return seqOf;
+	}
+
+	public void setERABResponse(ERABResponseItem erabResponseItem) {
+		seqOf.add(erabResponseItem);
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		for (int i = (seqOf.size() - 1); i >= 0; i--) {
+			codeLength += seqOf.get(i).encode(os, true);
+		}
+
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+		int totalLength = length.val;
+
+		while (subCodeLength < totalLength) {
+			ERABResponseItem element = new ERABResponseItem();
+			subCodeLength += element.decode(is, true);
+			seqOf.add(element);
+		}
+		if (subCodeLength != totalLength) {
+			throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+		}
+		codeLength += subCodeLength;
+
+		return codeLength;
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("[\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (seqOf == null) {
+			// sb.append("null");
+		}
+		else {
+			Iterator<ERABResponseItem> it = seqOf.iterator();
+			if (it.hasNext()) {
+				it.next().appendAsString(sb, indentLevel + 1);
+				while (it.hasNext()) {
+					sb.append(",\n");
+					for (int i = 0; i < indentLevel + 1; i++) {
+						sb.append("\t");
+					}
+					it.next().appendAsString(sb, indentLevel + 1);
+				}
+			}
+		}
+
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("]");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ERABResponseItem.java b/src/main/java/org.onosproject.xran/codecs/api/ERABResponseItem.java
new file mode 100644
index 0000000..7608bed
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ERABResponseItem.java
@@ -0,0 +1,171 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class ERABResponseItem implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ERABID id = null;
+	private ERABDecision decision = null;
+	
+	public ERABResponseItem() {
+	}
+
+	public ERABResponseItem(byte[] code) {
+		this.code = code;
+	}
+
+	public void setId(ERABID id) {
+		this.id = id;
+	}
+
+	public ERABID getId() {
+		return id;
+	}
+
+	public void setDecision(ERABDecision decision) {
+		this.decision = decision;
+	}
+
+	public ERABDecision getDecision() {
+		return decision;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += decision.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += id.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			id = new ERABID();
+			subCodeLength += id.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			decision = new ERABDecision();
+			subCodeLength += decision.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (id != null) {
+			sb.append("\"id\": ").append(id);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (decision != null) {
+			sb.append("\"decision\": ").append(decision);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ERABType.java b/src/main/java/org.onosproject.xran/codecs/api/ERABType.java
new file mode 100644
index 0000000..9f2449c
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ERABType.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class ERABType extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public ERABType() {
+	}
+
+	public ERABType(byte[] code) {
+		super(code);
+	}
+
+	public ERABType(BigInteger value) {
+		super(value);
+	}
+
+	public ERABType(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/EUTRANCellIdentifier.java b/src/main/java/org.onosproject.xran/codecs/api/EUTRANCellIdentifier.java
new file mode 100644
index 0000000..7c7f2a2
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/EUTRANCellIdentifier.java
@@ -0,0 +1,45 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.types.*;
+
+import javax.xml.bind.DatatypeConverter;
+import java.util.Arrays;
+
+
+public class EUTRANCellIdentifier extends BerBitString {
+
+	private static final long serialVersionUID = 1L;
+
+	public EUTRANCellIdentifier() {
+	}
+
+	public EUTRANCellIdentifier(byte[] code) {
+		super(code);
+	}
+
+	public EUTRANCellIdentifier(byte[] value, int numBits) {
+		super(value, numBits);
+	}
+
+	@Override
+	public int hashCode() {
+		return Arrays.hashCode(value);
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof EUTRANCellIdentifier) {
+			return Arrays.equals(value, ((EUTRANCellIdentifier) obj).value);
+		}
+		return super.equals(obj);
+	}
+
+	@Override
+	public String toString() {
+		return "\"" + DatatypeConverter.printHexBinary(value) + "\"";
+	}
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/HOFailureCause.java b/src/main/java/org.onosproject.xran/codecs/api/HOFailureCause.java
new file mode 100644
index 0000000..67be0de
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/HOFailureCause.java
@@ -0,0 +1,31 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.types.BerEnum;
+
+import java.math.BigInteger;
+
+
+public class HOFailureCause extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public HOFailureCause() {
+	}
+
+	public HOFailureCause(byte[] code) {
+		super(code);
+	}
+
+	public HOFailureCause(BigInteger value) {
+		super(value);
+	}
+
+	public HOFailureCause(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/MMEUES1APID.java b/src/main/java/org.onosproject.xran/codecs/api/MMEUES1APID.java
new file mode 100644
index 0000000..4967941
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/MMEUES1APID.java
@@ -0,0 +1,54 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import java.util.Objects;
+
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class MMEUES1APID extends BerInteger {
+
+	private static final long serialVersionUID = 1L;
+
+	public MMEUES1APID() {
+	}
+
+	public MMEUES1APID(byte[] code) {
+		super(code);
+	}
+
+	public MMEUES1APID(BigInteger value) {
+		super(value);
+	}
+
+	public MMEUES1APID(long value) {
+		super(value);
+	}
+
+	@Override
+	public int hashCode() {
+		return value.hashCode();
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof MMEUES1APID) {
+			return Objects.equals(value, ((MMEUES1APID) obj).value);
+		}
+		return super.equals(obj);
+	}
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/PCIARFCN.java b/src/main/java/org.onosproject.xran/codecs/api/PCIARFCN.java
new file mode 100644
index 0000000..e3bd88f
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/PCIARFCN.java
@@ -0,0 +1,181 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class PCIARFCN implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private PhysCellId pci = null;
+	private ARFCNValue earfcnDl = null;
+	
+	public PCIARFCN() {
+	}
+
+	public PCIARFCN(byte[] code) {
+		this.code = code;
+	}
+
+	public void setPci(PhysCellId pci) {
+		this.pci = pci;
+	}
+
+	public PhysCellId getPci() {
+		return pci;
+	}
+
+	public void setEarfcnDl(ARFCNValue earfcnDl) {
+		this.earfcnDl = earfcnDl;
+	}
+
+	public ARFCNValue getEarfcnDl() {
+		return earfcnDl;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += earfcnDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += pci.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			pci = new PhysCellId();
+			subCodeLength += pci.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			earfcnDl = new ARFCNValue();
+			subCodeLength += earfcnDl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pci != null) {
+			sb.append("\"pci\": ").append(pci);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (earfcnDl != null) {
+			sb.append("\"earfcnDl\": ").append(earfcnDl);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+	@Override
+	public boolean equals(Object o) {
+		if (o instanceof PCIARFCN) {
+			return pci.equals(((PCIARFCN) o).getPci()) && earfcnDl.equals(((PCIARFCN) o).getEarfcnDl());
+		}
+
+		return super.equals(o);
+	}
+
+	@Override
+	public int hashCode() {
+		int result = pci.hashCode();
+		result = 31 * result + earfcnDl.hashCode();
+		return result;
+	}
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/PLMNIdentity.java b/src/main/java/org.onosproject.xran/codecs/api/PLMNIdentity.java
new file mode 100644
index 0000000..5fe0d69
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/PLMNIdentity.java
@@ -0,0 +1,21 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.types.BerOctetString;
+
+
+public class PLMNIdentity extends BerOctetString {
+
+	private static final long serialVersionUID = 1L;
+
+	public PLMNIdentity() {
+	}
+
+	public PLMNIdentity(byte[] value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/PRBUsage.java b/src/main/java/org.onosproject.xran/codecs/api/PRBUsage.java
new file mode 100644
index 0000000..a36141c
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/PRBUsage.java
@@ -0,0 +1,431 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class PRBUsage implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class PrbUsageDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PrbUsageDl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PrbUsageDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class PrbUsageUl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PrbUsageUl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PrbUsageUl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private PrbUsageDl prbUsageDl = null;
+	private PrbUsageUl prbUsageUl = null;
+	
+	public PRBUsage() {
+	}
+
+	public PRBUsage(byte[] code) {
+		this.code = code;
+	}
+
+	public void setPrbUsageDl(PrbUsageDl prbUsageDl) {
+		this.prbUsageDl = prbUsageDl;
+	}
+
+	public PrbUsageDl getPrbUsageDl() {
+		return prbUsageDl;
+	}
+
+	public void setPrbUsageUl(PrbUsageUl prbUsageUl) {
+		this.prbUsageUl = prbUsageUl;
+	}
+
+	public PrbUsageUl getPrbUsageUl() {
+		return prbUsageUl;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += prbUsageUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += prbUsageDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			prbUsageDl = new PrbUsageDl();
+			subCodeLength += prbUsageDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			prbUsageUl = new PrbUsageUl();
+			subCodeLength += prbUsageUl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (prbUsageDl != null) {
+			sb.append("\"prbUsageDl\": ");
+			prbUsageDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (prbUsageUl != null) {
+			sb.append("\"prbUsageUl\": ");
+			prbUsageUl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/PhysCellId.java b/src/main/java/org.onosproject.xran/codecs/api/PhysCellId.java
new file mode 100644
index 0000000..e05df5b
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/PhysCellId.java
@@ -0,0 +1,43 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.types.BerInteger;
+
+import java.math.BigInteger;
+
+
+public class PhysCellId extends BerInteger {
+
+	private static final long serialVersionUID = 1L;
+
+	public PhysCellId() {
+	}
+
+	public PhysCellId(byte[] code) {
+		super(code);
+	}
+
+	public PhysCellId(BigInteger value) {
+		super(value);
+	}
+
+	public PhysCellId(long value) {
+		super(value);
+	}
+
+	@Override
+	public int hashCode() {
+		return value.intValue();
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof PhysCellId) {
+			return value.intValue() == ((PhysCellId) obj).value.intValue();
+		}
+		return super.equals(obj);
+	}
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/PropScell.java b/src/main/java/org.onosproject.xran/codecs/api/PropScell.java
new file mode 100644
index 0000000..9d473be
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/PropScell.java
@@ -0,0 +1,244 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerBoolean;
+import org.openmuc.jasn1.ber.types.BerEnum;
+import org.openmuc.jasn1.ber.types.BerInteger;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class PropScell implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private PCIARFCN pciArfcn = null;
+	private BerBoolean crossCarrierSchedEnable = null;
+	private BerEnum caDirection = null;
+	private BerInteger deactTimer = null;
+	
+	public PropScell() {
+	}
+
+	public PropScell(byte[] code) {
+		this.code = code;
+	}
+
+	public void setPciArfcn(PCIARFCN pciArfcn) {
+		this.pciArfcn = pciArfcn;
+	}
+
+	public PCIARFCN getPciArfcn() {
+		return pciArfcn;
+	}
+
+	public void setCrossCarrierSchedEnable(BerBoolean crossCarrierSchedEnable) {
+		this.crossCarrierSchedEnable = crossCarrierSchedEnable;
+	}
+
+	public BerBoolean getCrossCarrierSchedEnable() {
+		return crossCarrierSchedEnable;
+	}
+
+	public void setCaDirection(BerEnum caDirection) {
+		this.caDirection = caDirection;
+	}
+
+	public BerEnum getCaDirection() {
+		return caDirection;
+	}
+
+	public void setDeactTimer(BerInteger deactTimer) {
+		this.deactTimer = deactTimer;
+	}
+
+	public BerInteger getDeactTimer() {
+		return deactTimer;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += deactTimer.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 3
+		os.write(0x83);
+		codeLength += 1;
+		
+		codeLength += caDirection.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += crossCarrierSchedEnable.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += pciArfcn.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			pciArfcn = new PCIARFCN();
+			subCodeLength += pciArfcn.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			crossCarrierSchedEnable = new BerBoolean();
+			subCodeLength += crossCarrierSchedEnable.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			caDirection = new BerEnum();
+			subCodeLength += caDirection.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
+			deactTimer = new BerInteger();
+			subCodeLength += deactTimer.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pciArfcn != null) {
+			sb.append("pciArfcn: ");
+			pciArfcn.appendAsString(sb, indentLevel + 1);
+		}
+		else {
+			sb.append("pciArfcn: <empty-required-field>");
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crossCarrierSchedEnable != null) {
+			sb.append("crossCarrierSchedEnable: ").append(crossCarrierSchedEnable);
+		}
+		else {
+			sb.append("crossCarrierSchedEnable: <empty-required-field>");
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (caDirection != null) {
+			sb.append("caDirection: ").append(caDirection);
+		}
+		else {
+			sb.append("caDirection: <empty-required-field>");
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (deactTimer != null) {
+			sb.append("deactTimer: ").append(deactTimer);
+		}
+		else {
+			sb.append("deactTimer: <empty-required-field>");
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/QCI.java b/src/main/java/org.onosproject.xran/codecs/api/QCI.java
new file mode 100644
index 0000000..adee94e
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/QCI.java
@@ -0,0 +1,31 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.types.BerInteger;
+
+import java.math.BigInteger;
+
+
+public class QCI extends BerInteger {
+
+	private static final long serialVersionUID = 1L;
+
+	public QCI() {
+	}
+
+	public QCI(byte[] code) {
+		super(code);
+	}
+
+	public QCI(BigInteger value) {
+		super(value);
+	}
+
+	public QCI(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/RSRPRange.java b/src/main/java/org.onosproject.xran/codecs/api/RSRPRange.java
new file mode 100644
index 0000000..592f41e
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/RSRPRange.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class RSRPRange extends BerInteger {
+
+	private static final long serialVersionUID = 1L;
+
+	public RSRPRange() {
+	}
+
+	public RSRPRange(byte[] code) {
+		super(code);
+	}
+
+	public RSRPRange(BigInteger value) {
+		super(value);
+	}
+
+	public RSRPRange(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/RSRQRange.java b/src/main/java/org.onosproject.xran/codecs/api/RSRQRange.java
new file mode 100644
index 0000000..4d74e85
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/RSRQRange.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class RSRQRange extends BerInteger {
+
+	private static final long serialVersionUID = 1L;
+
+	public RSRQRange() {
+	}
+
+	public RSRQRange(byte[] code) {
+		super(code);
+	}
+
+	public RSRQRange(BigInteger value) {
+		super(value);
+	}
+
+	public RSRQRange(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/RXSigMeasRepInterval.java b/src/main/java/org.onosproject.xran/codecs/api/RXSigMeasRepInterval.java
new file mode 100644
index 0000000..8ce29aa
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/RXSigMeasRepInterval.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class RXSigMeasRepInterval extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public RXSigMeasRepInterval() {
+	}
+
+	public RXSigMeasRepInterval(byte[] code) {
+		super(code);
+	}
+
+	public RXSigMeasRepInterval(BigInteger value) {
+		super(value);
+	}
+
+	public RXSigMeasRepInterval(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/RXSigRepQty.java b/src/main/java/org.onosproject.xran/codecs/api/RXSigRepQty.java
new file mode 100644
index 0000000..8794f09
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/RXSigRepQty.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class RXSigRepQty extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public RXSigRepQty() {
+	}
+
+	public RXSigRepQty(byte[] code) {
+		super(code);
+	}
+
+	public RXSigRepQty(BigInteger value) {
+		super(value);
+	}
+
+	public RXSigRepQty(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/RXSigReport.java b/src/main/java/org.onosproject.xran/codecs/api/RXSigReport.java
new file mode 100644
index 0000000..f07dd09
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/RXSigReport.java
@@ -0,0 +1,202 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class RXSigReport implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private PCIARFCN pciArfcn = null;
+	private RSRPRange rsrp = null;
+	private RSRQRange rsrq = null;
+	
+	public RXSigReport() {
+	}
+
+	public RXSigReport(byte[] code) {
+		this.code = code;
+	}
+
+	public void setPciArfcn(PCIARFCN pciArfcn) {
+		this.pciArfcn = pciArfcn;
+	}
+
+	public PCIARFCN getPciArfcn() {
+		return pciArfcn;
+	}
+
+	public void setRsrp(RSRPRange rsrp) {
+		this.rsrp = rsrp;
+	}
+
+	public RSRPRange getRsrp() {
+		return rsrp;
+	}
+
+	public void setRsrq(RSRQRange rsrq) {
+		this.rsrq = rsrq;
+	}
+
+	public RSRQRange getRsrq() {
+		return rsrq;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += rsrq.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += rsrp.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += pciArfcn.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			pciArfcn = new PCIARFCN();
+			subCodeLength += pciArfcn.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			rsrp = new RSRPRange();
+			subCodeLength += rsrp.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			rsrq = new RSRQRange();
+			subCodeLength += rsrq.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pciArfcn != null) {
+			sb.append("\"pciArfcn\": ");
+			pciArfcn.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (rsrp != null) {
+			sb.append("\"rsrp\": ").append(rsrp);
+		}
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (rsrq != null) {
+			sb.append("\"rsrq\": ").append(rsrq);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/RadioRepPerServCell.java b/src/main/java/org.onosproject.xran/codecs/api/RadioRepPerServCell.java
new file mode 100644
index 0000000..525fb0a
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/RadioRepPerServCell.java
@@ -0,0 +1,790 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerInteger;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+public class RadioRepPerServCell implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class CqiHist implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public CqiHist() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public CqiHist(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class RiHist implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public RiHist() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public RiHist(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static class PuschSinrHist implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PuschSinrHist() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PuschSinrHist(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class PucchSinrHist implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PucchSinrHist() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PucchSinrHist(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private PCIARFCN pciArfcn = null;
+	private CqiHist cqiHist = null;
+	private RiHist riHist = null;
+	private PuschSinrHist puschSinrHist = null;
+	private PucchSinrHist pucchSinrHist = null;
+	
+	public RadioRepPerServCell() {
+	}
+
+	public RadioRepPerServCell(byte[] code) {
+		this.code = code;
+	}
+
+	public void setPciArfcn(PCIARFCN pciArfcn) {
+		this.pciArfcn = pciArfcn;
+	}
+
+	public PCIARFCN getPciArfcn() {
+		return pciArfcn;
+	}
+
+	public void setCqiHist(CqiHist cqiHist) {
+		this.cqiHist = cqiHist;
+	}
+
+	public CqiHist getCqiHist() {
+		return cqiHist;
+	}
+
+	public void setRiHist(RiHist riHist) {
+		this.riHist = riHist;
+	}
+
+	public RiHist getRiHist() {
+		return riHist;
+	}
+
+	public void setPuschSinrHist(PuschSinrHist puschSinrHist) {
+		this.puschSinrHist = puschSinrHist;
+	}
+
+	public PuschSinrHist getPuschSinrHist() {
+		return puschSinrHist;
+	}
+
+	public void setPucchSinrHist(PucchSinrHist pucchSinrHist) {
+		this.pucchSinrHist = pucchSinrHist;
+	}
+
+	public PucchSinrHist getPucchSinrHist() {
+		return pucchSinrHist;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += pucchSinrHist.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 4
+		os.write(0xA4);
+		codeLength += 1;
+		
+		codeLength += puschSinrHist.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+		os.write(0xA3);
+		codeLength += 1;
+		
+		codeLength += riHist.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += cqiHist.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += pciArfcn.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			pciArfcn = new PCIARFCN();
+			subCodeLength += pciArfcn.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			cqiHist = new CqiHist();
+			subCodeLength += cqiHist.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			riHist = new RiHist();
+			subCodeLength += riHist.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			puschSinrHist = new PuschSinrHist();
+			subCodeLength += puschSinrHist.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
+			pucchSinrHist = new PucchSinrHist();
+			subCodeLength += pucchSinrHist.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pciArfcn != null) {
+			sb.append("\"pciArfcn\": ");
+			pciArfcn.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (cqiHist != null) {
+			sb.append("\"cqiHist\": ");
+			cqiHist.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (riHist != null) {
+			sb.append("\"riHist\": ");
+			riHist.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (puschSinrHist != null) {
+			sb.append("\"puschSinrHist\": ");
+			puschSinrHist.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pucchSinrHist != null) {
+			sb.append("\"pucchSinrHist\": ");
+			pucchSinrHist.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/ReconfIndReason.java b/src/main/java/org.onosproject.xran/codecs/api/ReconfIndReason.java
new file mode 100644
index 0000000..6ab2221
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/ReconfIndReason.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class ReconfIndReason extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public ReconfIndReason() {
+	}
+
+	public ReconfIndReason(byte[] code) {
+		super(code);
+	}
+
+	public ReconfIndReason(BigInteger value) {
+		super(value);
+	}
+
+	public ReconfIndReason(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/RelCause.java b/src/main/java/org.onosproject.xran/codecs/api/RelCause.java
new file mode 100644
index 0000000..c983d06
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/RelCause.java
@@ -0,0 +1,40 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class RelCause extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public RelCause() {
+	}
+
+	public RelCause(byte[] code) {
+		super(code);
+	}
+
+	public RelCause(BigInteger value) {
+		super(value);
+	}
+
+	public RelCause(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/SchedMeasRepPerServCell.java b/src/main/java/org.onosproject.xran/codecs/api/SchedMeasRepPerServCell.java
new file mode 100644
index 0000000..a2ed8fb
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/SchedMeasRepPerServCell.java
@@ -0,0 +1,1307 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class SchedMeasRepPerServCell implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class QciVals implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<QCI> seqOf = null;
+
+		public QciVals() {
+			seqOf = new ArrayList<QCI>();
+		}
+
+		public QciVals(byte[] code) {
+			this.code = code;
+		}
+
+		public List<QCI> getQCI() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<QCI>();
+			}
+			return seqOf;
+		}
+
+		public void setQCI(QCI qci) {
+			seqOf.add(qci);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				QCI element = new QCI();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<QCI> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class McsDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public McsDl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public McsDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class NumSchedTtisDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public NumSchedTtisDl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public NumSchedTtisDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class McsUl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public McsUl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public McsUl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class NumSchedTtisUl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public NumSchedTtisUl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public NumSchedTtisUl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class RankDl1 implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public RankDl1() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public RankDl1(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class RankDl2 implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public RankDl2() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public RankDl2(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private PCIARFCN pciArfcn = null;
+	private QciVals qciVals = null;
+	private PRBUsage prbUsage = null;
+	private McsDl mcsDl = null;
+	private NumSchedTtisDl numSchedTtisDl = null;
+	private McsUl mcsUl = null;
+	private NumSchedTtisUl numSchedTtisUl = null;
+	private RankDl1 rankDl1 = null;
+	private RankDl2 rankDl2 = null;
+	
+	public SchedMeasRepPerServCell() {
+	}
+
+	public SchedMeasRepPerServCell(byte[] code) {
+		this.code = code;
+	}
+
+	public void setPciArfcn(PCIARFCN pciArfcn) {
+		this.pciArfcn = pciArfcn;
+	}
+
+	public PCIARFCN getPciArfcn() {
+		return pciArfcn;
+	}
+
+	public void setQciVals(QciVals qciVals) {
+		this.qciVals = qciVals;
+	}
+
+	public QciVals getQciVals() {
+		return qciVals;
+	}
+
+	public void setPrbUsage(PRBUsage prbUsage) {
+		this.prbUsage = prbUsage;
+	}
+
+	public PRBUsage getPrbUsage() {
+		return prbUsage;
+	}
+
+	public void setMcsDl(McsDl mcsDl) {
+		this.mcsDl = mcsDl;
+	}
+
+	public McsDl getMcsDl() {
+		return mcsDl;
+	}
+
+	public void setNumSchedTtisDl(NumSchedTtisDl numSchedTtisDl) {
+		this.numSchedTtisDl = numSchedTtisDl;
+	}
+
+	public NumSchedTtisDl getNumSchedTtisDl() {
+		return numSchedTtisDl;
+	}
+
+	public void setMcsUl(McsUl mcsUl) {
+		this.mcsUl = mcsUl;
+	}
+
+	public McsUl getMcsUl() {
+		return mcsUl;
+	}
+
+	public void setNumSchedTtisUl(NumSchedTtisUl numSchedTtisUl) {
+		this.numSchedTtisUl = numSchedTtisUl;
+	}
+
+	public NumSchedTtisUl getNumSchedTtisUl() {
+		return numSchedTtisUl;
+	}
+
+	public void setRankDl1(RankDl1 rankDl1) {
+		this.rankDl1 = rankDl1;
+	}
+
+	public RankDl1 getRankDl1() {
+		return rankDl1;
+	}
+
+	public void setRankDl2(RankDl2 rankDl2) {
+		this.rankDl2 = rankDl2;
+	}
+
+	public RankDl2 getRankDl2() {
+		return rankDl2;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += rankDl2.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 8
+		os.write(0xA8);
+		codeLength += 1;
+		
+		codeLength += rankDl1.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 7
+		os.write(0xA7);
+		codeLength += 1;
+		
+		codeLength += numSchedTtisUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 6
+		os.write(0xA6);
+		codeLength += 1;
+		
+		codeLength += mcsUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 5
+		os.write(0xA5);
+		codeLength += 1;
+		
+		codeLength += numSchedTtisDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 4
+		os.write(0xA4);
+		codeLength += 1;
+		
+		codeLength += mcsDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+		os.write(0xA3);
+		codeLength += 1;
+		
+		codeLength += prbUsage.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += qciVals.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += pciArfcn.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			pciArfcn = new PCIARFCN();
+			subCodeLength += pciArfcn.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			qciVals = new QciVals();
+			subCodeLength += qciVals.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			prbUsage = new PRBUsage();
+			subCodeLength += prbUsage.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			mcsDl = new McsDl();
+			subCodeLength += mcsDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
+			numSchedTtisDl = new NumSchedTtisDl();
+			subCodeLength += numSchedTtisDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
+			mcsUl = new McsUl();
+			subCodeLength += mcsUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
+			numSchedTtisUl = new NumSchedTtisUl();
+			subCodeLength += numSchedTtisUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) {
+			rankDl1 = new RankDl1();
+			subCodeLength += rankDl1.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) {
+			rankDl2 = new RankDl2();
+			subCodeLength += rankDl2.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pciArfcn != null) {
+			sb.append("\"pciArfcn\": ");
+			pciArfcn.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (qciVals != null) {
+			sb.append("\"qciVals\": ");
+			qciVals.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (prbUsage != null) {
+			sb.append("\"prbUsage\": ");
+			prbUsage.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (mcsDl != null) {
+			sb.append("\"mcsDl\": ");
+			mcsDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (numSchedTtisDl != null) {
+			sb.append("\"numSchedTtisDl\": ");
+			numSchedTtisDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (mcsUl != null) {
+			sb.append("\"mcsUl\": ");
+			mcsUl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (numSchedTtisUl != null) {
+			sb.append("\"numSchedTtisUl\": ");
+			numSchedTtisUl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (rankDl1 != null) {
+			sb.append("\"rankDl1\": ");
+			rankDl1.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (rankDl2 != null) {
+			sb.append("\"rankDl2\": ");
+			rankDl2.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/TrafficSplitPercentage.java b/src/main/java/org.onosproject.xran/codecs/api/TrafficSplitPercentage.java
new file mode 100644
index 0000000..bf3031a
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/TrafficSplitPercentage.java
@@ -0,0 +1,210 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+public class TrafficSplitPercentage implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private BerInteger trafficPercentDl = null;
+	private BerInteger trafficPercentUl = null;
+	
+	public TrafficSplitPercentage() {
+	}
+
+	public TrafficSplitPercentage(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setTrafficPercentDl(BerInteger trafficPercentDl) {
+		this.trafficPercentDl = trafficPercentDl;
+	}
+
+	public BerInteger getTrafficPercentDl() {
+		return trafficPercentDl;
+	}
+
+	public void setTrafficPercentUl(BerInteger trafficPercentUl) {
+		this.trafficPercentUl = trafficPercentUl;
+	}
+
+	public BerInteger getTrafficPercentUl() {
+		return trafficPercentUl;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		if (trafficPercentUl != null) {
+			codeLength += trafficPercentUl.encode(os, false);
+			// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+			os.write(0x82);
+			codeLength += 1;
+		}
+		
+		if (trafficPercentDl != null) {
+			codeLength += trafficPercentDl.encode(os, false);
+			// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+			os.write(0x81);
+			codeLength += 1;
+		}
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			trafficPercentDl = new BerInteger();
+			subCodeLength += trafficPercentDl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			trafficPercentUl = new BerInteger();
+			subCodeLength += trafficPercentUl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (trafficPercentDl != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"trafficPercentDl\": ").append(trafficPercentDl);
+		}
+		
+		if (trafficPercentUl != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"trafficPercentUl\": ").append(trafficPercentUl);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/UEAMBR.java b/src/main/java/org.onosproject.xran/codecs/api/UEAMBR.java
new file mode 100644
index 0000000..eeadfa2
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/UEAMBR.java
@@ -0,0 +1,166 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class UEAMBR implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private BitRate ambrDl = null;
+	private BitRate ambrUl = null;
+	
+	public UEAMBR() {
+	}
+
+	public UEAMBR(byte[] code) {
+		this.code = code;
+	}
+
+	public void setAmbrDl(BitRate ambrDl) {
+		this.ambrDl = ambrDl;
+	}
+
+	public BitRate getAmbrDl() {
+		return ambrDl;
+	}
+
+	public void setAmbrUl(BitRate ambrUl) {
+		this.ambrUl = ambrUl;
+	}
+
+	public BitRate getAmbrUl() {
+		return ambrUl;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += ambrUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += ambrDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			ambrDl = new BitRate();
+			subCodeLength += ambrDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			ambrUl = new BitRate();
+			subCodeLength += ambrUl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ambrDl != null) {
+			sb.append("\"ambrDl\": ").append(ambrDl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ambrUl != null) {
+			sb.append("\"ambrUl\": ").append(ambrUl);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/api/XICICPA.java b/src/main/java/org.onosproject.xran/codecs/api/XICICPA.java
new file mode 100644
index 0000000..4586eac
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/XICICPA.java
@@ -0,0 +1,31 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.api;
+
+import org.openmuc.jasn1.ber.types.BerEnum;
+
+import java.math.BigInteger;
+
+
+public class XICICPA extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public XICICPA() {
+	}
+
+	public XICICPA(byte[] code) {
+		super(code);
+	}
+
+	public XICICPA(BigInteger value) {
+		super(value);
+	}
+
+	public XICICPA(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/api/package-info.java b/src/main/java/org.onosproject.xran/codecs/api/package-info.java
new file mode 100644
index 0000000..e3949c9
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/api/package-info.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.codecs.api;
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/BearerAdmissionRequest.java b/src/main/java/org.onosproject.xran/codecs/pdu/BearerAdmissionRequest.java
new file mode 100644
index 0000000..7f86f7c
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/BearerAdmissionRequest.java
@@ -0,0 +1,266 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.ERABParams;
+import org.onosproject.xran.codecs.api.UEAMBR;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class BearerAdmissionRequest implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private UEAMBR ueAmbr = null;
+	private BerInteger numErabs = null;
+	private ERABParams erabParams = null;
+	
+	public BearerAdmissionRequest() {
+	}
+
+	public BearerAdmissionRequest(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setUeAmbr(UEAMBR ueAmbr) {
+		this.ueAmbr = ueAmbr;
+	}
+
+	public UEAMBR getUeAmbr() {
+		return ueAmbr;
+	}
+
+	public void setNumErabs(BerInteger numErabs) {
+		this.numErabs = numErabs;
+	}
+
+	public BerInteger getNumErabs() {
+		return numErabs;
+	}
+
+	public void setErabParams(ERABParams erabParams) {
+		this.erabParams = erabParams;
+	}
+
+	public ERABParams getErabParams() {
+		return erabParams;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += erabParams.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 4
+		os.write(0xA4);
+		codeLength += 1;
+		
+		codeLength += numErabs.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 3
+		os.write(0x83);
+		codeLength += 1;
+		
+		codeLength += ueAmbr.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			ueAmbr = new UEAMBR();
+			subCodeLength += ueAmbr.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
+			numErabs = new BerInteger();
+			subCodeLength += numErabs.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
+			erabParams = new ERABParams();
+			subCodeLength += erabParams.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ueAmbr != null) {
+			sb.append("\"ueAmbr\": ");
+			ueAmbr.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (numErabs != null) {
+			sb.append("\"numErabs\": ").append(numErabs);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (erabParams != null) {
+			sb.append("\"erabParams\": ");
+			erabParams.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/BearerAdmissionResponse.java b/src/main/java/org.onosproject.xran/codecs/pdu/BearerAdmissionResponse.java
new file mode 100644
index 0000000..8f6ad01
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/BearerAdmissionResponse.java
@@ -0,0 +1,233 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.ERABResponse;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class BearerAdmissionResponse implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private BerInteger numErabList = null;
+	private ERABResponse erabResponse = null;
+	
+	public BearerAdmissionResponse() {
+	}
+
+	public BearerAdmissionResponse(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setNumErabList(BerInteger numErabList) {
+		this.numErabList = numErabList;
+	}
+
+	public BerInteger getNumErabList() {
+		return numErabList;
+	}
+
+	public void setErabResponse(ERABResponse erabResponse) {
+		this.erabResponse = erabResponse;
+	}
+
+	public ERABResponse getErabResponse() {
+		return erabResponse;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += erabResponse.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+		os.write(0xA3);
+		codeLength += 1;
+		
+		codeLength += numErabList.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			numErabList = new BerInteger();
+			subCodeLength += numErabList.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			erabResponse = new ERABResponse();
+			subCodeLength += erabResponse.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (numErabList != null) {
+			sb.append("\"numErabList\": ").append(numErabList);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (erabResponse != null) {
+			sb.append("\"erabResponse\": ");
+			erabResponse.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/BearerAdmissionStatus.java b/src/main/java/org.onosproject.xran/codecs/pdu/BearerAdmissionStatus.java
new file mode 100644
index 0000000..16e85e1
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/BearerAdmissionStatus.java
@@ -0,0 +1,233 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.ERABResponse;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class BearerAdmissionStatus implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private BerInteger numErabs = null;
+	private ERABResponse erabResponse = null;
+	
+	public BearerAdmissionStatus() {
+	}
+
+	public BearerAdmissionStatus(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setNumErabs(BerInteger numErabs) {
+		this.numErabs = numErabs;
+	}
+
+	public BerInteger getNumErabs() {
+		return numErabs;
+	}
+
+	public void setErabResponse(ERABResponse erabResponse) {
+		this.erabResponse = erabResponse;
+	}
+
+	public ERABResponse getErabResponse() {
+		return erabResponse;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += erabResponse.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+		os.write(0xA3);
+		codeLength += 1;
+		
+		codeLength += numErabs.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			numErabs = new BerInteger();
+			subCodeLength += numErabs.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			erabResponse = new ERABResponse();
+			subCodeLength += erabResponse.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (numErabs != null) {
+			sb.append("\"numErabs\": ").append(numErabs);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (erabResponse != null) {
+			sb.append("\"erabResponse\": ");
+			erabResponse.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/BearerReleaseInd.java b/src/main/java/org.onosproject.xran/codecs/pdu/BearerReleaseInd.java
new file mode 100644
index 0000000..89cfa2d
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/BearerReleaseInd.java
@@ -0,0 +1,362 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.ERABID;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class BearerReleaseInd implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class ErabIds implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<ERABID> seqOf = null;
+
+		public ErabIds() {
+			seqOf = new ArrayList<ERABID>();
+		}
+
+		public ErabIds(byte[] code) {
+			this.code = code;
+		}
+
+		public List<ERABID> getERABID() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<ERABID>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				ERABID element = new ERABID();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<ERABID> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private BerInteger numErabs = null;
+	private ErabIds erabIds = null;
+	
+	public BearerReleaseInd() {
+	}
+
+	public BearerReleaseInd(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setNumErabs(BerInteger numErabs) {
+		this.numErabs = numErabs;
+	}
+
+	public BerInteger getNumErabs() {
+		return numErabs;
+	}
+
+	public void setErabIds(ErabIds erabIds) {
+		this.erabIds = erabIds;
+	}
+
+	public ErabIds getErabIds() {
+		return erabIds;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += erabIds.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+		os.write(0xA3);
+		codeLength += 1;
+		
+		codeLength += numErabs.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			numErabs = new BerInteger();
+			subCodeLength += numErabs.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			erabIds = new ErabIds();
+			subCodeLength += erabIds.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (numErabs != null) {
+			sb.append("\"numErabs\": ").append(numErabs);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (erabIds != null) {
+			sb.append("\"erabIds\": ");
+			erabIds.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/CellConfigReport.java b/src/main/java/org.onosproject.xran/codecs/pdu/CellConfigReport.java
new file mode 100644
index 0000000..c858d2e
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/CellConfigReport.java
@@ -0,0 +1,735 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerBoolean;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.onosproject.xran.codecs.api.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class CellConfigReport implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class CandScells implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<CandScell> seqOf = null;
+
+		public CandScells() {
+			seqOf = new ArrayList<CandScell>();
+		}
+
+		public CandScells(byte[] code) {
+			this.code = code;
+		}
+
+		public List<CandScell> getCandScells() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<CandScell>();
+			}
+			return seqOf;
+		}
+
+		public void setCandScells(CandScell candScell) {
+			seqOf.add(candScell);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				CandScell element = new CandScell();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<CandScell> it = seqOf.iterator();
+				if (it.hasNext()) {
+					it.next().appendAsString(sb, indentLevel + 1);
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						it.next().appendAsString(sb, indentLevel + 1);
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private PhysCellId pci = null;
+	private CandScells candScells = null;
+	private ARFCNValue earfcnDl = null;
+	private ARFCNValue earfcnUl = null;
+	private BerInteger rbsPerTtiDl = null;
+	private BerInteger rbsPerTtiUl = null;
+	private BerInteger numTxAntenna = null;
+	private DuplexMode duplexMode = null;
+	private BerInteger tddConfig = null;
+	private BerInteger tddSplSfConfig = null;
+	private BerInteger maxNumConnectedUes = null;
+	private BerInteger maxNumConnectedBearers = null;
+	private BerInteger maxNumUesSchedPerTtiDl = null;
+	private BerInteger maxNumUesSchedPerTtiUl = null;
+	private BerBoolean dlfsSchedEnable = null;
+	
+	public CellConfigReport() {
+	}
+
+	public CellConfigReport(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setPci(PhysCellId pci) {
+		this.pci = pci;
+	}
+
+	public PhysCellId getPci() {
+		return pci;
+	}
+
+	public void setCandScells(CandScells candScells) {
+		this.candScells = candScells;
+	}
+
+	public CandScells getCandScells() {
+		return candScells;
+	}
+
+	public void setEarfcnDl(ARFCNValue earfcnDl) {
+		this.earfcnDl = earfcnDl;
+	}
+
+	public ARFCNValue getEarfcnDl() {
+		return earfcnDl;
+	}
+
+	public void setEarfcnUl(ARFCNValue earfcnUl) {
+		this.earfcnUl = earfcnUl;
+	}
+
+	public ARFCNValue getEarfcnUl() {
+		return earfcnUl;
+	}
+
+	public void setRbsPerTtiDl(BerInteger rbsPerTtiDl) {
+		this.rbsPerTtiDl = rbsPerTtiDl;
+	}
+
+	public BerInteger getRbsPerTtiDl() {
+		return rbsPerTtiDl;
+	}
+
+	public void setRbsPerTtiUl(BerInteger rbsPerTtiUl) {
+		this.rbsPerTtiUl = rbsPerTtiUl;
+	}
+
+	public BerInteger getRbsPerTtiUl() {
+		return rbsPerTtiUl;
+	}
+
+	public void setNumTxAntenna(BerInteger numTxAntenna) {
+		this.numTxAntenna = numTxAntenna;
+	}
+
+	public BerInteger getNumTxAntenna() {
+		return numTxAntenna;
+	}
+
+	public void setDuplexMode(DuplexMode duplexMode) {
+		this.duplexMode = duplexMode;
+	}
+
+	public DuplexMode getDuplexMode() {
+		return duplexMode;
+	}
+
+	public void setTddConfig(BerInteger tddConfig) {
+		this.tddConfig = tddConfig;
+	}
+
+	public BerInteger getTddConfig() {
+		return tddConfig;
+	}
+
+	public void setTddSplSfConfig(BerInteger tddSplSfConfig) {
+		this.tddSplSfConfig = tddSplSfConfig;
+	}
+
+	public BerInteger getTddSplSfConfig() {
+		return tddSplSfConfig;
+	}
+
+	public void setMaxNumConnectedUes(BerInteger maxNumConnectedUes) {
+		this.maxNumConnectedUes = maxNumConnectedUes;
+	}
+
+	public BerInteger getMaxNumConnectedUes() {
+		return maxNumConnectedUes;
+	}
+
+	public void setMaxNumConnectedBearers(BerInteger maxNumConnectedBearers) {
+		this.maxNumConnectedBearers = maxNumConnectedBearers;
+	}
+
+	public BerInteger getMaxNumConnectedBearers() {
+		return maxNumConnectedBearers;
+	}
+
+	public void setMaxNumUesSchedPerTtiDl(BerInteger maxNumUesSchedPerTtiDl) {
+		this.maxNumUesSchedPerTtiDl = maxNumUesSchedPerTtiDl;
+	}
+
+	public BerInteger getMaxNumUesSchedPerTtiDl() {
+		return maxNumUesSchedPerTtiDl;
+	}
+
+	public void setMaxNumUesSchedPerTtiUl(BerInteger maxNumUesSchedPerTtiUl) {
+		this.maxNumUesSchedPerTtiUl = maxNumUesSchedPerTtiUl;
+	}
+
+	public BerInteger getMaxNumUesSchedPerTtiUl() {
+		return maxNumUesSchedPerTtiUl;
+	}
+
+	public void setDlfsSchedEnable(BerBoolean dlfsSchedEnable) {
+		this.dlfsSchedEnable = dlfsSchedEnable;
+	}
+
+	public BerBoolean getDlfsSchedEnable() {
+		return dlfsSchedEnable;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += dlfsSchedEnable.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 15
+		os.write(0x8F);
+		codeLength += 1;
+		
+		codeLength += maxNumUesSchedPerTtiUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 14
+		os.write(0x8E);
+		codeLength += 1;
+		
+		codeLength += maxNumUesSchedPerTtiDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 13
+		os.write(0x8D);
+		codeLength += 1;
+		
+		codeLength += maxNumConnectedBearers.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 12
+		os.write(0x8C);
+		codeLength += 1;
+		
+		codeLength += maxNumConnectedUes.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 11
+		os.write(0x8B);
+		codeLength += 1;
+		
+		if (tddSplSfConfig != null) {
+			codeLength += tddSplSfConfig.encode(os, false);
+			// write tag: CONTEXT_CLASS, PRIMITIVE, 10
+			os.write(0x8A);
+			codeLength += 1;
+		}
+		
+		if (tddConfig != null) {
+			codeLength += tddConfig.encode(os, false);
+			// write tag: CONTEXT_CLASS, PRIMITIVE, 9
+			os.write(0x89);
+			codeLength += 1;
+		}
+		
+		codeLength += duplexMode.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 8
+		os.write(0x88);
+		codeLength += 1;
+		
+		codeLength += numTxAntenna.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 7
+		os.write(0x87);
+		codeLength += 1;
+		
+		codeLength += rbsPerTtiUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 6
+		os.write(0x86);
+		codeLength += 1;
+		
+		codeLength += rbsPerTtiDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 5
+		os.write(0x85);
+		codeLength += 1;
+		
+		codeLength += earfcnUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 4
+		os.write(0x84);
+		codeLength += 1;
+		
+		codeLength += earfcnDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 3
+		os.write(0x83);
+		codeLength += 1;
+		
+		codeLength += candScells.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += pci.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			pci = new PhysCellId();
+			subCodeLength += pci.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			candScells = new CandScells();
+			subCodeLength += candScells.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
+			earfcnDl = new ARFCNValue();
+			subCodeLength += earfcnDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
+			earfcnUl = new ARFCNValue();
+			subCodeLength += earfcnUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 5)) {
+			rbsPerTtiDl = new BerInteger();
+			subCodeLength += rbsPerTtiDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
+			rbsPerTtiUl = new BerInteger();
+			subCodeLength += rbsPerTtiUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) {
+			numTxAntenna = new BerInteger();
+			subCodeLength += numTxAntenna.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
+			duplexMode = new DuplexMode();
+			subCodeLength += duplexMode.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
+			tddConfig = new BerInteger();
+			subCodeLength += tddConfig.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) {
+			tddSplSfConfig = new BerInteger();
+			subCodeLength += tddSplSfConfig.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 11)) {
+			maxNumConnectedUes = new BerInteger();
+			subCodeLength += maxNumConnectedUes.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 12)) {
+			maxNumConnectedBearers = new BerInteger();
+			subCodeLength += maxNumConnectedBearers.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 13)) {
+			maxNumUesSchedPerTtiDl = new BerInteger();
+			subCodeLength += maxNumUesSchedPerTtiDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 14)) {
+			maxNumUesSchedPerTtiUl = new BerInteger();
+			subCodeLength += maxNumUesSchedPerTtiUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 15)) {
+			dlfsSchedEnable = new BerBoolean();
+			subCodeLength += dlfsSchedEnable.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pci != null) {
+			sb.append("\"pci\": ").append(pci);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (candScells != null) {
+			sb.append("\"candScells\": ");
+			candScells.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (earfcnDl != null) {
+			sb.append("\"earfcnDl\": ").append(earfcnDl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (earfcnUl != null) {
+			sb.append("\"earfcnUl\": ").append(earfcnUl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (rbsPerTtiDl != null) {
+			sb.append("\"rbsPerTtiDl\": ").append(rbsPerTtiDl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (rbsPerTtiUl != null) {
+			sb.append("\"rbsPerTtiUl\": ").append(rbsPerTtiUl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (numTxAntenna != null) {
+			sb.append("\"numTxAntenna\": ").append(numTxAntenna);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (duplexMode != null) {
+			sb.append("\"duplexMode\": ").append(duplexMode);
+		}
+		
+		if (tddConfig != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"tddConfig\": ").append(tddConfig);
+		}
+		
+		if (tddSplSfConfig != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"tddSplSfConfig\": ").append(tddSplSfConfig);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (maxNumConnectedUes != null) {
+			sb.append("\"maxNumConnectedUes\": ").append(maxNumConnectedUes);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (maxNumConnectedBearers != null) {
+			sb.append("\"maxNumConnectedBearers\": ").append(maxNumConnectedBearers);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (maxNumUesSchedPerTtiDl != null) {
+			sb.append("\"maxNumUesSchedPerTtiDl\": ").append(maxNumUesSchedPerTtiDl);
+		}
+
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (maxNumUesSchedPerTtiUl != null) {
+			sb.append("\"maxNumUesSchedPerTtiUl\": ").append(maxNumUesSchedPerTtiUl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (dlfsSchedEnable != null) {
+			sb.append("\"dlfsSchedEnable\": ").append(dlfsSchedEnable);
+		}
+
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/CellConfigRequest.java b/src/main/java/org.onosproject.xran/codecs/pdu/CellConfigRequest.java
new file mode 100644
index 0000000..9aa3254
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/CellConfigRequest.java
@@ -0,0 +1,136 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.onosproject.xran.codecs.api.ECGI;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class CellConfigRequest implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	
+	public CellConfigRequest() {
+	}
+
+	public CellConfigRequest(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/HOComplete.java b/src/main/java/org.onosproject.xran/codecs/pdu/HOComplete.java
new file mode 100644
index 0000000..7a4290a
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/HOComplete.java
@@ -0,0 +1,201 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class HOComplete implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgiT = null;
+	private ECGI ecgiS = null;
+	private CRNTI crntiNew = null;
+	
+	public HOComplete() {
+	}
+
+	public HOComplete(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgiT(ECGI ecgiT) {
+		this.ecgiT = ecgiT;
+	}
+
+	public ECGI getEcgiT() {
+		return ecgiT;
+	}
+
+	public void setEcgiS(ECGI ecgiS) {
+		this.ecgiS = ecgiS;
+	}
+
+	public ECGI getEcgiS() {
+		return ecgiS;
+	}
+
+	public void setCrntiNew(CRNTI crntiNew) {
+		this.crntiNew = crntiNew;
+	}
+
+	public CRNTI getCrntiNew() {
+		return crntiNew;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += crntiNew.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgiS.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += ecgiT.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgiT = new ECGI();
+			subCodeLength += ecgiT.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgiS = new ECGI();
+			subCodeLength += ecgiS.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			crntiNew = new CRNTI();
+			subCodeLength += crntiNew.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgiT != null) {
+			sb.append("\"ecgiT\": ");
+			ecgiT.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgiS != null) {
+			sb.append("\"ecgiS\": ");
+			ecgiS.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crntiNew != null) {
+			sb.append("\"crntiNew\": ").append(crntiNew);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/HOFailure.java b/src/main/java/org.onosproject.xran/codecs/pdu/HOFailure.java
new file mode 100644
index 0000000..d0d2c90
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/HOFailure.java
@@ -0,0 +1,200 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.HOFailureCause;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class HOFailure implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private HOFailureCause cause = null;
+	
+	public HOFailure() {
+	}
+
+	public HOFailure(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setCause(HOFailureCause cause) {
+		this.cause = cause;
+	}
+
+	public HOFailureCause getCause() {
+		return cause;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += cause.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			cause = new HOFailureCause();
+			subCodeLength += cause.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (cause != null) {
+			sb.append("\"cause\": ").append(cause);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/HORequest.java b/src/main/java/org.onosproject.xran/codecs/pdu/HORequest.java
new file mode 100644
index 0000000..7079944
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/HORequest.java
@@ -0,0 +1,200 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class HORequest implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgiS = null;
+	private ECGI ecgiT = null;
+	
+	public HORequest() {
+	}
+
+	public HORequest(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgiS(ECGI ecgiS) {
+		this.ecgiS = ecgiS;
+	}
+
+	public ECGI getEcgiS() {
+		return ecgiS;
+	}
+
+	public void setEcgiT(ECGI ecgiT) {
+		this.ecgiT = ecgiT;
+	}
+
+	public ECGI getEcgiT() {
+		return ecgiT;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += ecgiT.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += ecgiS.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgiS = new ECGI();
+			subCodeLength += ecgiS.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			ecgiT = new ECGI();
+			subCodeLength += ecgiT.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgiS != null) {
+			sb.append("\"ecgiS\": ");
+			ecgiS.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgiT != null) {
+			sb.append("\"ecgiT\": ");
+			ecgiT.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/L2MeasConfig.java b/src/main/java/org.onosproject.xran/codecs/pdu/L2MeasConfig.java
new file mode 100644
index 0000000..a474ec3
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/L2MeasConfig.java
@@ -0,0 +1,168 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.ECGI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerInteger;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class L2MeasConfig implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private BerInteger  reportIntervalMs = null;
+	
+	public L2MeasConfig() {
+	}
+
+	public L2MeasConfig(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setReportIntervalMs(BerInteger reportIntervalMs) {
+		this.reportIntervalMs = reportIntervalMs;
+	}
+
+	public BerInteger getReportIntervalMs() {
+		return reportIntervalMs;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += reportIntervalMs.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			reportIntervalMs = new BerInteger();
+			subCodeLength += reportIntervalMs.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (reportIntervalMs != null) {
+			sb.append("\"reportIntervalMs\": ").append(reportIntervalMs);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/PDCPMeasReportPerUe.java b/src/main/java/org.onosproject.xran/codecs/pdu/PDCPMeasReportPerUe.java
new file mode 100644
index 0000000..d272974
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/PDCPMeasReportPerUe.java
@@ -0,0 +1,1787 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import java.io.IOException;
+import java.io.EOFException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.io.Serializable;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.QCI;
+import org.openmuc.jasn1.ber.*;
+import org.openmuc.jasn1.ber.types.*;
+import org.openmuc.jasn1.ber.types.string.*;
+
+
+
+public class PDCPMeasReportPerUe implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class QciVals implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<QCI> seqOf = null;
+
+		public QciVals() {
+			seqOf = new ArrayList<QCI>();
+		}
+
+		public QciVals(byte[] code) {
+			this.code = code;
+		}
+
+		public List<QCI> getQCI() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<QCI>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				QCI element = new QCI();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<QCI> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setQCI(QCI qci) {
+			seqOf.add(qci);
+		}
+	}
+
+	public static class DataVolDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public DataVolDl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public DataVolDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static class DataVolUl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public DataVolUl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public DataVolUl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static class PktDelayDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PktDelayDl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PktDelayDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static class PktDelayUl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PktDelayUl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PktDelayUl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static class PktDiscardRateDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PktDiscardRateDl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PktDiscardRateDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static class PktLossRateDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PktLossRateDl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PktLossRateDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static class PktLossRateUl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PktLossRateUl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PktLossRateUl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static class ThroughputDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public ThroughputDl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public ThroughputDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static class ThroughputUl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public ThroughputUl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public ThroughputUl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private CRNTI crnti = null;
+	private QciVals qciVals = null;
+	private DataVolDl dataVolDl = null;
+	private DataVolUl dataVolUl = null;
+	private PktDelayDl pktDelayDl = null;
+	private PktDelayUl pktDelayUl = null;
+	private PktDiscardRateDl pktDiscardRateDl = null;
+	private PktLossRateDl pktLossRateDl = null;
+	private PktLossRateUl pktLossRateUl = null;
+	private ThroughputDl throughputDl = null;
+	private ThroughputUl throughputUl = null;
+	
+	public PDCPMeasReportPerUe() {
+	}
+
+	public PDCPMeasReportPerUe(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setQciVals(QciVals qciVals) {
+		this.qciVals = qciVals;
+	}
+
+	public QciVals getQciVals() {
+		return qciVals;
+	}
+
+	public void setDataVolDl(DataVolDl dataVolDl) {
+		this.dataVolDl = dataVolDl;
+	}
+
+	public DataVolDl getDataVolDl() {
+		return dataVolDl;
+	}
+
+	public void setDataVolUl(DataVolUl dataVolUl) {
+		this.dataVolUl = dataVolUl;
+	}
+
+	public DataVolUl getDataVolUl() {
+		return dataVolUl;
+	}
+
+	public void setPktDelayDl(PktDelayDl pktDelayDl) {
+		this.pktDelayDl = pktDelayDl;
+	}
+
+	public PktDelayDl getPktDelayDl() {
+		return pktDelayDl;
+	}
+
+	public void setPktDelayUl(PktDelayUl pktDelayUl) {
+		this.pktDelayUl = pktDelayUl;
+	}
+
+	public PktDelayUl getPktDelayUl() {
+		return pktDelayUl;
+	}
+
+	public void setPktDiscardRateDl(PktDiscardRateDl pktDiscardRateDl) {
+		this.pktDiscardRateDl = pktDiscardRateDl;
+	}
+
+	public PktDiscardRateDl getPktDiscardRateDl() {
+		return pktDiscardRateDl;
+	}
+
+	public void setPktLossRateDl(PktLossRateDl pktLossRateDl) {
+		this.pktLossRateDl = pktLossRateDl;
+	}
+
+	public PktLossRateDl getPktLossRateDl() {
+		return pktLossRateDl;
+	}
+
+	public void setPktLossRateUl(PktLossRateUl pktLossRateUl) {
+		this.pktLossRateUl = pktLossRateUl;
+	}
+
+	public PktLossRateUl getPktLossRateUl() {
+		return pktLossRateUl;
+	}
+
+	public void setThroughputDl(ThroughputDl throughputDl) {
+		this.throughputDl = throughputDl;
+	}
+
+	public ThroughputDl getThroughputDl() {
+		return throughputDl;
+	}
+
+	public void setThroughputUl(ThroughputUl throughputUl) {
+		this.throughputUl = throughputUl;
+	}
+
+	public ThroughputUl getThroughputUl() {
+		return throughputUl;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += throughputUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 11
+		os.write(0xAB);
+		codeLength += 1;
+		
+		codeLength += throughputDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 10
+		os.write(0xAA);
+		codeLength += 1;
+		
+		codeLength += pktLossRateUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 9
+		os.write(0xA9);
+		codeLength += 1;
+		
+		codeLength += pktLossRateDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 8
+		os.write(0xA8);
+		codeLength += 1;
+		
+		codeLength += pktDiscardRateDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 7
+		os.write(0xA7);
+		codeLength += 1;
+		
+		codeLength += pktDelayUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 6
+		os.write(0xA6);
+		codeLength += 1;
+		
+		codeLength += pktDelayDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 5
+		os.write(0xA5);
+		codeLength += 1;
+		
+		codeLength += dataVolUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 4
+		os.write(0xA4);
+		codeLength += 1;
+		
+		codeLength += dataVolDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+		os.write(0xA3);
+		codeLength += 1;
+		
+		codeLength += qciVals.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			qciVals = new QciVals();
+			subCodeLength += qciVals.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			dataVolDl = new DataVolDl();
+			subCodeLength += dataVolDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
+			dataVolUl = new DataVolUl();
+			subCodeLength += dataVolUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
+			pktDelayDl = new PktDelayDl();
+			subCodeLength += pktDelayDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
+			pktDelayUl = new PktDelayUl();
+			subCodeLength += pktDelayUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) {
+			pktDiscardRateDl = new PktDiscardRateDl();
+			subCodeLength += pktDiscardRateDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) {
+			pktLossRateDl = new PktLossRateDl();
+			subCodeLength += pktLossRateDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 9)) {
+			pktLossRateUl = new PktLossRateUl();
+			subCodeLength += pktLossRateUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 10)) {
+			throughputDl = new ThroughputDl();
+			subCodeLength += throughputDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 11)) {
+			throughputUl = new ThroughputUl();
+			subCodeLength += throughputUl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (qciVals != null) {
+			sb.append("\"qciVals\": ");
+			qciVals.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (dataVolDl != null) {
+			sb.append("\"dataVolDl\": ");
+			dataVolDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (dataVolUl != null) {
+			sb.append("\"dataVolUl\": ");
+			dataVolUl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pktDelayDl != null) {
+			sb.append("\"pktDelayDl\": ");
+			pktDelayDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pktDelayUl != null) {
+			sb.append("\"pktDelayUl\": ");
+			pktDelayUl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pktDiscardRateDl != null) {
+			sb.append("\"pktDiscardRateDl\": ");
+			pktDiscardRateDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pktLossRateDl != null) {
+			sb.append("\"pktLossRateDl\": ");
+			pktLossRateDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pktLossRateUl != null) {
+			sb.append("\"pktLossRateUl\": ");
+			pktLossRateUl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (throughputDl != null) {
+			sb.append("\"throughputDl\": ");
+			throughputDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (throughputUl != null) {
+			sb.append("\"throughputUl\": ");
+			throughputUl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/RRMConfig.java b/src/main/java/org.onosproject.xran/codecs/pdu/RRMConfig.java
new file mode 100644
index 0000000..4de355d
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/RRMConfig.java
@@ -0,0 +1,1585 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.XICICPA;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerBitString;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class RRMConfig implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class Crnti implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<CRNTI> seqOf = null;
+
+		public Crnti() {
+			seqOf = new ArrayList<CRNTI>();
+		}
+
+		public Crnti(byte[] code) {
+			this.code = code;
+		}
+
+		public List<CRNTI> getCRNTI() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<CRNTI>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				CRNTI element = new CRNTI();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<CRNTI> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class Pa implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<XICICPA> seqOf = null;
+
+		public Pa() {
+			seqOf = new ArrayList<XICICPA>();
+		}
+
+		public Pa(byte[] code) {
+			this.code = code;
+		}
+
+		public List<XICICPA> getXICICPA() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<XICICPA>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				XICICPA element = new XICICPA();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<XICICPA> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class StartPrbDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public StartPrbDl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public StartPrbDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class EndPrbDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public EndPrbDl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public EndPrbDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class SubframeBitmaskDl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerBitString> seqOf = null;
+
+		public SubframeBitmaskDl() {
+			seqOf = new ArrayList<BerBitString>();
+		}
+
+		public SubframeBitmaskDl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerBitString> getBerBitString() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerBitString>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerBitString element = new BerBitString();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerBitString> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class P0UePusch implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public P0UePusch() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public P0UePusch(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class StartPrbUl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public StartPrbUl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public StartPrbUl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class EndPrbUl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public EndPrbUl() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public EndPrbUl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class SubframeBitmaskUl implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerBitString> seqOf = null;
+
+		public SubframeBitmaskUl() {
+			seqOf = new ArrayList<BerBitString>();
+		}
+
+		public SubframeBitmaskUl(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerBitString> getBerBitString() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerBitString>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerBitString element = new BerBitString();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerBitString> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private Crnti crnti = null;
+	private Pa pa = null;
+	private StartPrbDl startPrbDl = null;
+	private EndPrbDl endPrbDl = null;
+	private SubframeBitmaskDl subframeBitmaskDl = null;
+	private P0UePusch p0UePusch = null;
+	private StartPrbUl startPrbUl = null;
+	private EndPrbUl endPrbUl = null;
+	private SubframeBitmaskUl subframeBitmaskUl = null;
+	
+	public RRMConfig() {
+	}
+
+	public RRMConfig(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setCrnti(Crnti crnti) {
+		this.crnti = crnti;
+	}
+
+	public Crnti getCrnti() {
+		return crnti;
+	}
+
+	public void setPa(Pa pa) {
+		this.pa = pa;
+	}
+
+	public Pa getPa() {
+		return pa;
+	}
+
+	public void setStartPrbDl(StartPrbDl startPrbDl) {
+		this.startPrbDl = startPrbDl;
+	}
+
+	public StartPrbDl getStartPrbDl() {
+		return startPrbDl;
+	}
+
+	public void setEndPrbDl(EndPrbDl endPrbDl) {
+		this.endPrbDl = endPrbDl;
+	}
+
+	public EndPrbDl getEndPrbDl() {
+		return endPrbDl;
+	}
+
+	public void setSubframeBitmaskDl(SubframeBitmaskDl subframeBitmaskDl) {
+		this.subframeBitmaskDl = subframeBitmaskDl;
+	}
+
+	public SubframeBitmaskDl getSubframeBitmaskDl() {
+		return subframeBitmaskDl;
+	}
+
+	public void setP0UePusch(P0UePusch p0UePusch) {
+		this.p0UePusch = p0UePusch;
+	}
+
+	public P0UePusch getP0UePusch() {
+		return p0UePusch;
+	}
+
+	public void setStartPrbUl(StartPrbUl startPrbUl) {
+		this.startPrbUl = startPrbUl;
+	}
+
+	public StartPrbUl getStartPrbUl() {
+		return startPrbUl;
+	}
+
+	public void setEndPrbUl(EndPrbUl endPrbUl) {
+		this.endPrbUl = endPrbUl;
+	}
+
+	public EndPrbUl getEndPrbUl() {
+		return endPrbUl;
+	}
+
+	public void setSubframeBitmaskUl(SubframeBitmaskUl subframeBitmaskUl) {
+		this.subframeBitmaskUl = subframeBitmaskUl;
+	}
+
+	public SubframeBitmaskUl getSubframeBitmaskUl() {
+		return subframeBitmaskUl;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		if (subframeBitmaskUl != null) {
+			codeLength += subframeBitmaskUl.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 9
+			os.write(0xA9);
+			codeLength += 1;
+		}
+		
+		if (endPrbUl != null) {
+			codeLength += endPrbUl.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 8
+			os.write(0xA8);
+			codeLength += 1;
+		}
+		
+		if (startPrbUl != null) {
+			codeLength += startPrbUl.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 7
+			os.write(0xA7);
+			codeLength += 1;
+		}
+		
+		if (p0UePusch != null) {
+			codeLength += p0UePusch.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 6
+			os.write(0xA6);
+			codeLength += 1;
+		}
+		
+		if (subframeBitmaskDl != null) {
+			codeLength += subframeBitmaskDl.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 5
+			os.write(0xA5);
+			codeLength += 1;
+		}
+		
+		if (endPrbDl != null) {
+			codeLength += endPrbDl.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 4
+			os.write(0xA4);
+			codeLength += 1;
+		}
+		
+		if (startPrbDl != null) {
+			codeLength += startPrbDl.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+			os.write(0xA3);
+			codeLength += 1;
+		}
+		
+		if (pa != null) {
+			codeLength += pa.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+			os.write(0xA2);
+			codeLength += 1;
+		}
+		
+		if (crnti != null) {
+			codeLength += crnti.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+			os.write(0xA1);
+			codeLength += 1;
+		}
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			crnti = new Crnti();
+			subCodeLength += crnti.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			pa = new Pa();
+			subCodeLength += pa.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			startPrbDl = new StartPrbDl();
+			subCodeLength += startPrbDl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
+			endPrbDl = new EndPrbDl();
+			subCodeLength += endPrbDl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
+			subframeBitmaskDl = new SubframeBitmaskDl();
+			subCodeLength += subframeBitmaskDl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
+			p0UePusch = new P0UePusch();
+			subCodeLength += p0UePusch.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) {
+			startPrbUl = new StartPrbUl();
+			subCodeLength += startPrbUl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) {
+			endPrbUl = new EndPrbUl();
+			subCodeLength += endPrbUl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 9)) {
+			subframeBitmaskUl = new SubframeBitmaskUl();
+			subCodeLength += subframeBitmaskUl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (crnti != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"crnti\": ");
+			crnti.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (pa != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"pa\": ");
+			pa.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (startPrbDl != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"startPrbDl\": ");
+			startPrbDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (endPrbDl != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"endPrbDl\": ");
+			endPrbDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (subframeBitmaskDl != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"subframeBitmaskDl\": ");
+			subframeBitmaskDl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (p0UePusch != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"p0UePusch\": ");
+			p0UePusch.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (startPrbUl != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"startPrbUl\": ");
+			startPrbUl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (endPrbUl != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"endPrbUl\": ");
+			endPrbUl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (subframeBitmaskUl != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"subframeBitmaskUl\": ");
+			subframeBitmaskUl.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/RRMConfigStatus.java b/src/main/java/org.onosproject.xran/codecs/pdu/RRMConfigStatus.java
new file mode 100644
index 0000000..ab88a6d
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/RRMConfigStatus.java
@@ -0,0 +1,457 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerEnum;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+public class RRMConfigStatus implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class Crnti implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<CRNTI> seqOf = null;
+
+		public Crnti() {
+			seqOf = new ArrayList<CRNTI>();
+		}
+
+		public Crnti(byte[] code) {
+			this.code = code;
+		}
+
+		public List<CRNTI> getCRNTI() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<CRNTI>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				CRNTI element = new CRNTI();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<CRNTI> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class Status implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerEnum> seqOf = null;
+
+		public Status() {
+			seqOf = new ArrayList<BerEnum>();
+		}
+
+		public Status(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerEnum> getBerEnum() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerEnum>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerEnum element = new BerEnum();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerEnum> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private Crnti crnti = null;
+	private Status status = null;
+	
+	public RRMConfigStatus() {
+	}
+
+	public RRMConfigStatus(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setCrnti(Crnti crnti) {
+		this.crnti = crnti;
+	}
+
+	public Crnti getCrnti() {
+		return crnti;
+	}
+
+	public void setStatus(Status status) {
+		this.status = status;
+	}
+
+	public Status getStatus() {
+		return status;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += status.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		if (crnti != null) {
+			codeLength += crnti.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+			os.write(0xA1);
+			codeLength += 1;
+		}
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			crnti = new Crnti();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			status = new Status();
+			subCodeLength += status.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (crnti != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"crnti\": ");
+			crnti.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (status != null) {
+			sb.append("\"status\": ");
+			status.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/RXSigMeasConfig.java b/src/main/java/org.onosproject.xran/codecs/pdu/RXSigMeasConfig.java
new file mode 100644
index 0000000..c6704ce
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/RXSigMeasConfig.java
@@ -0,0 +1,393 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.*;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class RXSigMeasConfig implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class MeasCells implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<PCIARFCN> seqOf = null;
+
+		public MeasCells() {
+			seqOf = new ArrayList<PCIARFCN>();
+		}
+
+		public MeasCells(byte[] code) {
+			this.code = code;
+		}
+
+		public List<PCIARFCN> getPCIARFCN() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<PCIARFCN>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				PCIARFCN element = new PCIARFCN();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<PCIARFCN> it = seqOf.iterator();
+				if (it.hasNext()) {
+					it.next().appendAsString(sb, indentLevel + 1);
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						it.next().appendAsString(sb, indentLevel + 1);
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+        public void setPCIARFCN(PCIARFCN pciarfcn) {
+			seqOf.add(pciarfcn);
+        }
+    }
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private CRNTI crnti = null;
+	private RXSigRepQty reportQty = null;
+	private MeasCells measCells = null;
+	private RXSigMeasRepInterval reportInterval = null;
+	
+	public RXSigMeasConfig() {
+	}
+
+	public RXSigMeasConfig(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setReportQty(RXSigRepQty reportQty) {
+		this.reportQty = reportQty;
+	}
+
+	public RXSigRepQty getReportQty() {
+		return reportQty;
+	}
+
+	public void setMeasCells(MeasCells measCells) {
+		this.measCells = measCells;
+	}
+
+	public MeasCells getMeasCells() {
+		return measCells;
+	}
+
+	public void setReportInterval(RXSigMeasRepInterval reportInterval) {
+		this.reportInterval = reportInterval;
+	}
+
+	public RXSigMeasRepInterval getReportInterval() {
+		return reportInterval;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += reportInterval.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 4
+		os.write(0x84);
+		codeLength += 1;
+		
+		codeLength += measCells.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+		os.write(0xA3);
+		codeLength += 1;
+		
+		codeLength += reportQty.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			reportQty = new RXSigRepQty();
+			subCodeLength += reportQty.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			measCells = new MeasCells();
+			subCodeLength += measCells.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
+			reportInterval = new RXSigMeasRepInterval();
+			subCodeLength += reportInterval.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (reportQty != null) {
+			sb.append("\"reportQty\": ").append(reportQty);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (measCells != null) {
+			sb.append("\"measCells\": ");
+			measCells.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (reportInterval != null) {
+			sb.append("\"reportInterval\": ").append(reportInterval);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/RXSigMeasReport.java b/src/main/java/org.onosproject.xran/codecs/pdu/RXSigMeasReport.java
new file mode 100644
index 0000000..bee7bdd
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/RXSigMeasReport.java
@@ -0,0 +1,333 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.RXSigReport;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class RXSigMeasReport implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class CellMeasReports implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<RXSigReport> seqOf = null;
+
+		public CellMeasReports() {
+			seqOf = new ArrayList<RXSigReport>();
+		}
+
+		public CellMeasReports(byte[] code) {
+			this.code = code;
+		}
+
+		public List<RXSigReport> getRXSigReport() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<RXSigReport>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				RXSigReport element = new RXSigReport();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<RXSigReport> it = seqOf.iterator();
+				if (it.hasNext()) {
+					it.next().appendAsString(sb, indentLevel + 1);
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						it.next().appendAsString(sb, indentLevel + 1);
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setRXSigReport(RXSigReport rxSigReport) {
+			seqOf.add(rxSigReport);
+		}
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private CellMeasReports cellMeasReports = null;
+	
+	public RXSigMeasReport() {
+	}
+
+	public RXSigMeasReport(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setCellMeasReports(CellMeasReports cellMeasReports) {
+		this.cellMeasReports = cellMeasReports;
+	}
+
+	public CellMeasReports getCellMeasReports() {
+		return cellMeasReports;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += cellMeasReports.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			cellMeasReports = new CellMeasReports();
+			subCodeLength += cellMeasReports.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (cellMeasReports != null) {
+			sb.append("\"cellMeasReports\": ");
+			cellMeasReports.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/RadioMeasReportPerCell.java b/src/main/java/org.onosproject.xran/codecs/pdu/RadioMeasReportPerCell.java
new file mode 100644
index 0000000..ac138c6
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/RadioMeasReportPerCell.java
@@ -0,0 +1,464 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.ECGI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerInteger;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+public class RadioMeasReportPerCell implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class PuschIntfPowerHist implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PuschIntfPowerHist() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PuschIntfPowerHist(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class PucchIntfPowerHist implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerInteger> seqOf = null;
+
+		public PucchIntfPowerHist() {
+			seqOf = new ArrayList<BerInteger>();
+		}
+
+		public PucchIntfPowerHist(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerInteger> getBerInteger() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerInteger>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerInteger element = new BerInteger();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerInteger> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setBerInteger(BerInteger berInteger) {
+			seqOf.add(berInteger);
+		}
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private PuschIntfPowerHist puschIntfPowerHist = null;
+	private PucchIntfPowerHist pucchIntfPowerHist = null;
+	
+	public RadioMeasReportPerCell() {
+	}
+
+	public RadioMeasReportPerCell(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setPuschIntfPowerHist(PuschIntfPowerHist puschIntfPowerHist) {
+		this.puschIntfPowerHist = puschIntfPowerHist;
+	}
+
+	public PuschIntfPowerHist getPuschIntfPowerHist() {
+		return puschIntfPowerHist;
+	}
+
+	public void setPucchIntfPowerHist(PucchIntfPowerHist pucchIntfPowerHist) {
+		this.pucchIntfPowerHist = pucchIntfPowerHist;
+	}
+
+	public PucchIntfPowerHist getPucchIntfPowerHist() {
+		return pucchIntfPowerHist;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += pucchIntfPowerHist.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += puschIntfPowerHist.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			puschIntfPowerHist = new PuschIntfPowerHist();
+			subCodeLength += puschIntfPowerHist.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			pucchIntfPowerHist = new PucchIntfPowerHist();
+			subCodeLength += pucchIntfPowerHist.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (puschIntfPowerHist != null) {
+			sb.append("\"puschIntfPowerHist\": ");
+			puschIntfPowerHist.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pucchIntfPowerHist != null) {
+			sb.append("\"pucchIntfPowerHist\": ");
+			pucchIntfPowerHist.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/RadioMeasReportPerUE.java b/src/main/java/org.onosproject.xran/codecs/pdu/RadioMeasReportPerUE.java
new file mode 100644
index 0000000..15f1ea9
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/RadioMeasReportPerUE.java
@@ -0,0 +1,333 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.RadioRepPerServCell;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class RadioMeasReportPerUE implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class RadioReportServCells implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<RadioRepPerServCell> seqOf = null;
+
+		public RadioReportServCells() {
+			seqOf = new ArrayList<RadioRepPerServCell>();
+		}
+
+		public RadioReportServCells(byte[] code) {
+			this.code = code;
+		}
+
+		public List<RadioRepPerServCell> getRadioRepPerServCell() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<RadioRepPerServCell>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				RadioRepPerServCell element = new RadioRepPerServCell();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<RadioRepPerServCell> it = seqOf.iterator();
+				if (it.hasNext()) {
+					it.next().appendAsString(sb, indentLevel + 1);
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						it.next().appendAsString(sb, indentLevel + 1);
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+		public void setRadioRepPerServCell(RadioRepPerServCell radioRepPerServCell) {
+			seqOf.add(radioRepPerServCell);
+		}
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private CRNTI crnti = null;
+	private RadioReportServCells radioReportServCells = null;
+	
+	public RadioMeasReportPerUE() {
+	}
+
+	public RadioMeasReportPerUE(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setRadioReportServCells(RadioReportServCells radioReportServCells) {
+		this.radioReportServCells = radioReportServCells;
+	}
+
+	public RadioReportServCells getRadioReportServCells() {
+		return radioReportServCells;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += radioReportServCells.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			radioReportServCells = new RadioReportServCells();
+			subCodeLength += radioReportServCells.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (radioReportServCells != null) {
+			sb.append("\"radioReportServCells\": ");
+			radioReportServCells.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/ScellAdd.java b/src/main/java/org.onosproject.xran/codecs/pdu/ScellAdd.java
new file mode 100644
index 0000000..a1d6c8f
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/ScellAdd.java
@@ -0,0 +1,330 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.PropScell;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class ScellAdd implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class ScellsProp implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<PropScell> seqOf = null;
+
+		public ScellsProp() {
+			seqOf = new ArrayList<PropScell>();
+		}
+
+		public ScellsProp(byte[] code) {
+			this.code = code;
+		}
+
+		public List<PropScell> getPropScell() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<PropScell>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				PropScell element = new PropScell();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<PropScell> it = seqOf.iterator();
+				if (it.hasNext()) {
+					it.next().appendAsString(sb, indentLevel + 1);
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						it.next().appendAsString(sb, indentLevel + 1);
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private ScellsProp scellsProp = null;
+	
+	public ScellAdd() {
+	}
+
+	public ScellAdd(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setScellsProp(ScellsProp scellsProp) {
+		this.scellsProp = scellsProp;
+	}
+
+	public ScellsProp getScellsProp() {
+		return scellsProp;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += scellsProp.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			scellsProp = new ScellsProp();
+			subCodeLength += scellsProp.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (scellsProp != null) {
+			sb.append("\"scellsProp\": ");
+			scellsProp.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/ScellAddStatus.java b/src/main/java/org.onosproject.xran/codecs/pdu/ScellAddStatus.java
new file mode 100644
index 0000000..99ddadd
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/ScellAddStatus.java
@@ -0,0 +1,489 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.PCIARFCN;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerEnum;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class ScellAddStatus implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class ScellsInd implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<PCIARFCN> seqOf = null;
+
+		public ScellsInd() {
+			seqOf = new ArrayList<PCIARFCN>();
+		}
+
+		public ScellsInd(byte[] code) {
+			this.code = code;
+		}
+
+		public List<PCIARFCN> getPCIARFCN() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<PCIARFCN>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				PCIARFCN element = new PCIARFCN();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<PCIARFCN> it = seqOf.iterator();
+				if (it.hasNext()) {
+					it.next().appendAsString(sb, indentLevel + 1);
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						it.next().appendAsString(sb, indentLevel + 1);
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static class Status implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<BerEnum> seqOf = null;
+
+		public Status() {
+			seqOf = new ArrayList<BerEnum>();
+		}
+
+		public Status(byte[] code) {
+			this.code = code;
+		}
+
+		public List<BerEnum> getBerEnum() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<BerEnum>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				BerEnum element = new BerEnum();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<BerEnum> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private ScellsInd scellsInd = null;
+	private Status status = null;
+	
+	public ScellAddStatus() {
+	}
+
+	public ScellAddStatus(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setScellsInd(ScellsInd scellsInd) {
+		this.scellsInd = scellsInd;
+	}
+
+	public ScellsInd getScellsInd() {
+		return scellsInd;
+	}
+
+	public void setStatus(Status status) {
+		this.status = status;
+	}
+
+	public Status getStatus() {
+		return status;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += status.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+		os.write(0xA3);
+		codeLength += 1;
+		
+		codeLength += scellsInd.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			scellsInd = new ScellsInd();
+			subCodeLength += scellsInd.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			status = new Status();
+			subCodeLength += status.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (scellsInd != null) {
+			sb.append("\"scellsInd\": ");
+			scellsInd.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (status != null) {
+			sb.append("\"status\": ");
+			status.appendAsString(sb, indentLevel + 1);
+		}
+
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/ScellDelete.java b/src/main/java/org.onosproject.xran/codecs/pdu/ScellDelete.java
new file mode 100644
index 0000000..278c7f6
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/ScellDelete.java
@@ -0,0 +1,330 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.PCIARFCN;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class ScellDelete implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class ScellsInd implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<PCIARFCN> seqOf = null;
+
+		public ScellsInd() {
+			seqOf = new ArrayList<PCIARFCN>();
+		}
+
+		public ScellsInd(byte[] code) {
+			this.code = code;
+		}
+
+		public List<PCIARFCN> getPCIARFCN() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<PCIARFCN>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				PCIARFCN element = new PCIARFCN();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<PCIARFCN> it = seqOf.iterator();
+				if (it.hasNext()) {
+					it.next().appendAsString(sb, indentLevel + 1);
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						it.next().appendAsString(sb, indentLevel + 1);
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private ScellsInd scellsInd = null;
+	
+	public ScellDelete() {
+	}
+
+	public ScellDelete(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setScellsInd(ScellsInd scellsInd) {
+		this.scellsInd = scellsInd;
+	}
+
+	public ScellsInd getScellsInd() {
+		return scellsInd;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += scellsInd.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			scellsInd = new ScellsInd();
+			subCodeLength += scellsInd.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (scellsInd != null) {
+			sb.append("\"scellsInd\": ");
+			scellsInd.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/SchedMeasReportPerCell.java b/src/main/java/org.onosproject.xran/codecs/pdu/SchedMeasReportPerCell.java
new file mode 100644
index 0000000..1493c63
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/SchedMeasReportPerCell.java
@@ -0,0 +1,365 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+package org.onosproject.xran.codecs.pdu;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.PRBUsage;
+import org.onosproject.xran.codecs.api.QCI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+public class SchedMeasReportPerCell implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class QciVals implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<QCI> seqOf = null;
+
+		public QciVals() {
+			seqOf = new ArrayList<QCI>();
+		}
+
+		public QciVals(byte[] code) {
+			this.code = code;
+		}
+
+		public List<QCI> getQCI() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<QCI>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				QCI element = new QCI();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<QCI> it = seqOf.iterator();
+				if (it.hasNext()) {
+					sb.append(it.next());
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						sb.append(it.next());
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+        public void setQCI(QCI qci) {
+			seqOf.add(qci);
+        }
+    }
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private QciVals qciVals = null;
+	private PRBUsage prbUsagePcell = null;
+	private PRBUsage prbUsageScell = null;
+	
+	public SchedMeasReportPerCell() {
+	}
+
+	public SchedMeasReportPerCell(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setQciVals(QciVals qciVals) {
+		this.qciVals = qciVals;
+	}
+
+	public QciVals getQciVals() {
+		return qciVals;
+	}
+
+	public void setPrbUsagePcell(PRBUsage prbUsagePcell) {
+		this.prbUsagePcell = prbUsagePcell;
+	}
+
+	public PRBUsage getPrbUsagePcell() {
+		return prbUsagePcell;
+	}
+
+	public void setPrbUsageScell(PRBUsage prbUsageScell) {
+		this.prbUsageScell = prbUsageScell;
+	}
+
+	public PRBUsage getPrbUsageScell() {
+		return prbUsageScell;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += prbUsageScell.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+		os.write(0xA3);
+		codeLength += 1;
+		
+		codeLength += prbUsagePcell.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += qciVals.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			qciVals = new QciVals();
+			subCodeLength += qciVals.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			prbUsagePcell = new PRBUsage();
+			subCodeLength += prbUsagePcell.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			prbUsageScell = new PRBUsage();
+			subCodeLength += prbUsageScell.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (qciVals != null) {
+			sb.append("\"qciVals\": ");
+			qciVals.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (prbUsagePcell != null) {
+			sb.append("\"prbUsagePcell\": ");
+			prbUsagePcell.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (prbUsageScell != null) {
+			sb.append("\"prbUsageScell\": ");
+			prbUsageScell.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/SchedMeasReportPerUE.java b/src/main/java/org.onosproject.xran/codecs/pdu/SchedMeasReportPerUE.java
new file mode 100644
index 0000000..3205e88
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/SchedMeasReportPerUE.java
@@ -0,0 +1,332 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.SchedMeasRepPerServCell;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class SchedMeasReportPerUE implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class SchedReportServCells implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<SchedMeasRepPerServCell> seqOf = null;
+
+		public SchedReportServCells() {
+			seqOf = new ArrayList<SchedMeasRepPerServCell>();
+		}
+
+		public SchedReportServCells(byte[] code) {
+			this.code = code;
+		}
+
+		public List<SchedMeasRepPerServCell> getSchedMeasRepPerServCell() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<SchedMeasRepPerServCell>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				SchedMeasRepPerServCell element = new SchedMeasRepPerServCell();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<SchedMeasRepPerServCell> it = seqOf.iterator();
+				if (it.hasNext()) {
+					it.next().appendAsString(sb, indentLevel + 1);
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						it.next().appendAsString(sb, indentLevel + 1);
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+        public void setSchedMeasRepPerServCell(SchedMeasRepPerServCell schedMeasRepPerServCell) {
+			seqOf.add(schedMeasRepPerServCell);
+        }
+    }
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private CRNTI crnti = null;
+	private SchedReportServCells schedReportServCells = null;
+	
+	public SchedMeasReportPerUE() {
+	}
+
+	public SchedMeasReportPerUE(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setSchedReportServCells(SchedReportServCells schedReportServCells) {
+		this.schedReportServCells = schedReportServCells;
+	}
+
+	public SchedReportServCells getSchedReportServCells() {
+		return schedReportServCells;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += schedReportServCells.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			schedReportServCells = new SchedReportServCells();
+			subCodeLength += schedReportServCells.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (schedReportServCells != null) {
+			sb.append("\"schedReportServCells\": ");
+			schedReportServCells.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/SeNBAdd.java b/src/main/java/org.onosproject.xran/codecs/pdu/SeNBAdd.java
new file mode 100644
index 0000000..d86cf6d
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/SeNBAdd.java
@@ -0,0 +1,199 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class SeNBAdd implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI mEcgi = null;
+	private ECGI sEcgi = null;
+	
+	public SeNBAdd() {
+	}
+
+	public SeNBAdd(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setMEcgi(ECGI mEcgi) {
+		this.mEcgi = mEcgi;
+	}
+
+	public ECGI getMEcgi() {
+		return mEcgi;
+	}
+
+	public void setSEcgi(ECGI sEcgi) {
+		this.sEcgi = sEcgi;
+	}
+
+	public ECGI getSEcgi() {
+		return sEcgi;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += sEcgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += mEcgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			mEcgi = new ECGI();
+			subCodeLength += mEcgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			sEcgi = new ECGI();
+			subCodeLength += sEcgi.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (mEcgi != null) {
+			sb.append("\"mEcgi\": ");
+			mEcgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (sEcgi != null) {
+			sb.append("\"sEcgi\": ");
+			sEcgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/SeNBAddStatus.java b/src/main/java/org.onosproject.xran/codecs/pdu/SeNBAddStatus.java
new file mode 100644
index 0000000..e09c110
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/SeNBAddStatus.java
@@ -0,0 +1,200 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerEnum;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class SeNBAddStatus implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private BerEnum status = null;
+	
+	public SeNBAddStatus() {
+	}
+
+	public SeNBAddStatus(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setStatus(BerEnum status) {
+		this.status = status;
+	}
+
+	public BerEnum getStatus() {
+		return status;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += status.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			status = new BerEnum();
+			subCodeLength += status.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (status != null) {
+			sb.append("\"status\": ").append(status);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/SeNBDelete.java b/src/main/java/org.onosproject.xran/codecs/pdu/SeNBDelete.java
new file mode 100644
index 0000000..8441c3f
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/SeNBDelete.java
@@ -0,0 +1,200 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class SeNBDelete implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI mEcgi = null;
+	private ECGI sEcgi = null;
+	
+	public SeNBDelete() {
+	}
+
+	public SeNBDelete(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setMEcgi(ECGI mEcgi) {
+		this.mEcgi = mEcgi;
+	}
+
+	public ECGI getMEcgi() {
+		return mEcgi;
+	}
+
+	public void setSEcgi(ECGI sEcgi) {
+		this.sEcgi = sEcgi;
+	}
+
+	public ECGI getSEcgi() {
+		return sEcgi;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += sEcgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += mEcgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			mEcgi = new ECGI();
+			subCodeLength += mEcgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			sEcgi = new ECGI();
+			subCodeLength += sEcgi.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (mEcgi != null) {
+			sb.append("\"mEcgi\": ");
+			mEcgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (sEcgi != null) {
+			sb.append("\"sEcgi\": ");
+			sEcgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/TrafficSplitConfig.java b/src/main/java/org.onosproject.xran/codecs/pdu/TrafficSplitConfig.java
new file mode 100644
index 0000000..408b722
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/TrafficSplitConfig.java
@@ -0,0 +1,329 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.TrafficSplitPercentage;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class TrafficSplitConfig implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static class TrafficSplitPercent implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+
+		public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+		public byte[] code = null;
+		private List<TrafficSplitPercentage> seqOf = null;
+
+		public TrafficSplitPercent() {
+			seqOf = new ArrayList<TrafficSplitPercentage>();
+		}
+
+		public TrafficSplitPercent(byte[] code) {
+			this.code = code;
+		}
+
+		public List<TrafficSplitPercentage> getTrafficSplitPercentage() {
+			if (seqOf == null) {
+				seqOf = new ArrayList<TrafficSplitPercentage>();
+			}
+			return seqOf;
+		}
+
+		public int encode(BerByteArrayOutputStream os) throws IOException {
+			return encode(os, true);
+		}
+
+		public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+			if (code != null) {
+				for (int i = code.length - 1; i >= 0; i--) {
+					os.write(code[i]);
+				}
+				if (withTag) {
+					return tag.encode(os) + code.length;
+				}
+				return code.length;
+			}
+
+			int codeLength = 0;
+			for (int i = (seqOf.size() - 1); i >= 0; i--) {
+				codeLength += seqOf.get(i).encode(os, true);
+			}
+
+			codeLength += BerLength.encodeLength(os, codeLength);
+
+			if (withTag) {
+				codeLength += tag.encode(os);
+			}
+
+			return codeLength;
+		}
+
+		public int decode(InputStream is) throws IOException {
+			return decode(is, true);
+		}
+
+		public int decode(InputStream is, boolean withTag) throws IOException {
+			int codeLength = 0;
+			int subCodeLength = 0;
+			if (withTag) {
+				codeLength += tag.decodeAndCheck(is);
+			}
+
+			BerLength length = new BerLength();
+			codeLength += length.decode(is);
+			int totalLength = length.val;
+
+			while (subCodeLength < totalLength) {
+				TrafficSplitPercentage element = new TrafficSplitPercentage();
+				subCodeLength += element.decode(is, true);
+				seqOf.add(element);
+			}
+			if (subCodeLength != totalLength) {
+				throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
+
+			}
+			codeLength += subCodeLength;
+
+			return codeLength;
+		}
+
+		public void encodeAndSave(int encodingSizeGuess) throws IOException {
+			BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+			encode(os, false);
+			code = os.getArray();
+		}
+
+		public String toString() {
+			StringBuilder sb = new StringBuilder();
+			appendAsString(sb, 0);
+			return sb.toString();
+		}
+
+		public void appendAsString(StringBuilder sb, int indentLevel) {
+
+			sb.append("[\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			if (seqOf == null) {
+//				sb.append("null");
+			}
+			else {
+				Iterator<TrafficSplitPercentage> it = seqOf.iterator();
+				if (it.hasNext()) {
+					it.next().appendAsString(sb, indentLevel + 1);
+					while (it.hasNext()) {
+						sb.append(",\n");
+						for (int i = 0; i < indentLevel + 1; i++) {
+							sb.append("\t");
+						}
+						it.next().appendAsString(sb, indentLevel + 1);
+					}
+				}
+			}
+
+			sb.append("\n");
+			for (int i = 0; i < indentLevel; i++) {
+				sb.append("\t");
+			}
+			sb.append("]");
+		}
+
+	}
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private TrafficSplitPercent trafficSplitPercent = null;
+	
+	public TrafficSplitConfig() {
+	}
+
+	public TrafficSplitConfig(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setTrafficSplitPercent(TrafficSplitPercent trafficSplitPercent) {
+		this.trafficSplitPercent = trafficSplitPercent;
+	}
+
+	public TrafficSplitPercent getTrafficSplitPercent() {
+		return trafficSplitPercent;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += trafficSplitPercent.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+		os.write(0xA2);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			trafficSplitPercent = new TrafficSplitPercent();
+			subCodeLength += trafficSplitPercent.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (trafficSplitPercent != null) {
+			sb.append("\"trafficSplitPercent\": ");
+			trafficSplitPercent.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/UEAdmissionRequest.java b/src/main/java/org.onosproject.xran/codecs/pdu/UEAdmissionRequest.java
new file mode 100644
index 0000000..3eb4b9e
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/UEAdmissionRequest.java
@@ -0,0 +1,200 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.onosproject.xran.codecs.api.AdmEstCause;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class UEAdmissionRequest implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private AdmEstCause admEstCause = null;
+	
+	public UEAdmissionRequest() {
+	}
+
+	public UEAdmissionRequest(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setAdmEstCause(AdmEstCause admEstCause) {
+		this.admEstCause = admEstCause;
+	}
+
+	public AdmEstCause getAdmEstCause() {
+		return admEstCause;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += admEstCause.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			admEstCause = new AdmEstCause();
+			subCodeLength += admEstCause.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (admEstCause != null) {
+			sb.append("\"admEstCause\": ").append(admEstCause);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/UEAdmissionResponse.java b/src/main/java/org.onosproject.xran/codecs/pdu/UEAdmissionResponse.java
new file mode 100644
index 0000000..db6ed32
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/UEAdmissionResponse.java
@@ -0,0 +1,200 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.onosproject.xran.codecs.api.AdmEstResponse;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class UEAdmissionResponse implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private AdmEstResponse admEstResponse = null;
+	
+	public UEAdmissionResponse() {
+	}
+
+	public UEAdmissionResponse(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setAdmEstResponse(AdmEstResponse admEstResponse) {
+		this.admEstResponse = admEstResponse;
+	}
+
+	public AdmEstResponse getAdmEstResponse() {
+		return admEstResponse;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += admEstResponse.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			admEstResponse = new AdmEstResponse();
+			subCodeLength += admEstResponse.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (admEstResponse != null) {
+			sb.append("\"admEstResponse\": ").append(admEstResponse);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/UEAdmissionStatus.java b/src/main/java/org.onosproject.xran/codecs/pdu/UEAdmissionStatus.java
new file mode 100644
index 0000000..edfd056
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/UEAdmissionStatus.java
@@ -0,0 +1,200 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.onosproject.xran.codecs.api.AdmEstStatus;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class UEAdmissionStatus implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private AdmEstStatus admEstStatus = null;
+	
+	public UEAdmissionStatus() {
+	}
+
+	public UEAdmissionStatus(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setAdmEstStatus(AdmEstStatus admEstStatus) {
+		this.admEstStatus = admEstStatus;
+	}
+
+	public AdmEstStatus getAdmEstStatus() {
+		return admEstStatus;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += admEstStatus.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			admEstStatus = new AdmEstStatus();
+			subCodeLength += admEstStatus.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (admEstStatus != null) {
+			sb.append("\"admEstStatus\": ").append(admEstStatus);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/UEAttachComplete.java b/src/main/java/org.onosproject.xran/codecs/pdu/UEAttachComplete.java
new file mode 100644
index 0000000..74050d7
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/UEAttachComplete.java
@@ -0,0 +1,232 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.ENBUES1APID;
+import org.onosproject.xran.codecs.api.MMEUES1APID;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class UEAttachComplete implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private MMEUES1APID mMEUES1APID = null;
+	private ENBUES1APID eNBUES1APID = null;
+	
+	public UEAttachComplete() {
+	}
+
+	public UEAttachComplete(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setMMEUES1APID(MMEUES1APID mMEUES1APID) {
+		this.mMEUES1APID = mMEUES1APID;
+	}
+
+	public MMEUES1APID getMMEUES1APID() {
+		return mMEUES1APID;
+	}
+
+	public void setENBUES1APID(ENBUES1APID eNBUES1APID) {
+		this.eNBUES1APID = eNBUES1APID;
+	}
+
+	public ENBUES1APID getENBUES1APID() {
+		return eNBUES1APID;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += eNBUES1APID.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 3
+		os.write(0x83);
+		codeLength += 1;
+		
+		codeLength += mMEUES1APID.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			mMEUES1APID = new MMEUES1APID();
+			subCodeLength += mMEUES1APID.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
+			eNBUES1APID = new ENBUES1APID();
+			subCodeLength += eNBUES1APID.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (mMEUES1APID != null) {
+			sb.append("\"mMEUES1APID\": ").append(mMEUES1APID);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (eNBUES1APID != null) {
+			sb.append("\"eNBUES1APID\": ").append(eNBUES1APID);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/UECapabilityEnquiry.java b/src/main/java/org.onosproject.xran/codecs/pdu/UECapabilityEnquiry.java
new file mode 100644
index 0000000..84758d1
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/UECapabilityEnquiry.java
@@ -0,0 +1,169 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class UECapabilityEnquiry implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	
+	public UECapabilityEnquiry() {
+	}
+
+	public UECapabilityEnquiry(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/UECapabilityInfo.java b/src/main/java/org.onosproject.xran/codecs/pdu/UECapabilityInfo.java
new file mode 100644
index 0000000..a2c017e
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/UECapabilityInfo.java
@@ -0,0 +1,241 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CACap;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.DCCap;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+
+public class UECapabilityInfo implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private CACap caCap = null;
+	private DCCap dcCap = null;
+	
+	public UECapabilityInfo() {
+	}
+
+	public UECapabilityInfo(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setCaCap(CACap caCap) {
+		this.caCap = caCap;
+	}
+
+	public CACap getCaCap() {
+		return caCap;
+	}
+
+	public void setDcCap(DCCap dcCap) {
+		this.dcCap = dcCap;
+	}
+
+	public DCCap getDcCap() {
+		return dcCap;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		if (dcCap != null) {
+			codeLength += dcCap.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+			os.write(0xA3);
+			codeLength += 1;
+		}
+		
+		if (caCap != null) {
+			codeLength += caCap.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+			os.write(0xA2);
+			codeLength += 1;
+		}
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			caCap = new CACap();
+			subCodeLength += caCap.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+			subCodeLength += berTag.decode(is);
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			dcCap = new DCCap();
+			subCodeLength += dcCap.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (caCap != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"caCap\": ");
+			caCap.appendAsString(sb, indentLevel + 1);
+		}
+		
+		if (dcCap != null) {
+			sb.append(",\n");
+			for (int i = 0; i < indentLevel + 1; i++) {
+				sb.append("\t");
+			}
+			sb.append("\"dcCap\": ");
+			dcCap.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/UEReconfigInd.java b/src/main/java/org.onosproject.xran/codecs/pdu/UEReconfigInd.java
new file mode 100644
index 0000000..4a5fd3d
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/UEReconfigInd.java
@@ -0,0 +1,231 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.ReconfIndReason;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class UEReconfigInd implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crntiOld = null;
+	private ECGI ecgi = null;
+	private CRNTI crntiNew = null;
+	private ReconfIndReason reconfigCause = null;
+	
+	public UEReconfigInd() {
+	}
+
+	public UEReconfigInd(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrntiOld(CRNTI crntiOld) {
+		this.crntiOld = crntiOld;
+	}
+
+	public CRNTI getCrntiOld() {
+		return crntiOld;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setCrntiNew(CRNTI crntiNew) {
+		this.crntiNew = crntiNew;
+	}
+
+	public CRNTI getCrntiNew() {
+		return crntiNew;
+	}
+
+	public void setReconfigCause(ReconfIndReason reconfigCause) {
+		this.reconfigCause = reconfigCause;
+	}
+
+	public ReconfIndReason getReconfigCause() {
+		return reconfigCause;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += reconfigCause.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 3
+		os.write(0x83);
+		codeLength += 1;
+		
+		codeLength += crntiNew.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crntiOld.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crntiOld = new CRNTI();
+			subCodeLength += crntiOld.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			crntiNew = new CRNTI();
+			subCodeLength += crntiNew.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
+			reconfigCause = new ReconfIndReason();
+			subCodeLength += reconfigCause.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crntiOld != null) {
+			sb.append("\"crntiOld\": ").append(crntiOld);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crntiNew != null) {
+			sb.append("\"crntiNew\": ").append(crntiNew);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (reconfigCause != null) {
+			sb.append("\"reconfigCause\": ").append(reconfigCause);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/UEReleaseInd.java b/src/main/java/org.onosproject.xran/codecs/pdu/UEReleaseInd.java
new file mode 100644
index 0000000..9b601ad
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/UEReleaseInd.java
@@ -0,0 +1,199 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.RelCause;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class UEReleaseInd implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private CRNTI crnti = null;
+	private ECGI ecgi = null;
+	private RelCause releaseCause = null;
+	
+	public UEReleaseInd() {
+	}
+
+	public UEReleaseInd(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setReleaseCause(RelCause releaseCause) {
+		this.releaseCause = releaseCause;
+	}
+
+	public RelCause getReleaseCause() {
+		return releaseCause;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += releaseCause.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			releaseCause = new RelCause();
+			subCodeLength += releaseCause.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (releaseCause != null) {
+			sb.append("\"releaseCause\": ").append(releaseCause);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/XICICConfig.java b/src/main/java/org.onosproject.xran/codecs/pdu/XICICConfig.java
new file mode 100644
index 0000000..f02d36a
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/XICICConfig.java
@@ -0,0 +1,450 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+package org.onosproject.xran.codecs.pdu;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.PCIARFCN;
+import org.onosproject.xran.codecs.api.XICICPA;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.BerBitString;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class XICICConfig implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private ECGI ecgi = null;
+	private PCIARFCN pciArfcn = null;
+	private CRNTI crnti = null;
+	private XICICPA pa = null;
+	private BerInteger startPrbDl = null;
+	private BerInteger endPrbDl = null;
+	private BerBitString subframeBitmaskDl = null;
+	private BerInteger p0UePusch = null;
+	private BerInteger startPrbUl = null;
+	private BerInteger endPrbUl = null;
+	private BerBitString subframeBitmaskUl = null;
+	
+	public XICICConfig() {
+	}
+
+	public XICICConfig(byte[] code) {
+		this.code = code;
+	}
+
+	public void setEcgi(ECGI ecgi) {
+		this.ecgi = ecgi;
+	}
+
+	public ECGI getEcgi() {
+		return ecgi;
+	}
+
+	public void setPciArfcn(PCIARFCN pciArfcn) {
+		this.pciArfcn = pciArfcn;
+	}
+
+	public PCIARFCN getPciArfcn() {
+		return pciArfcn;
+	}
+
+	public void setCrnti(CRNTI crnti) {
+		this.crnti = crnti;
+	}
+
+	public CRNTI getCrnti() {
+		return crnti;
+	}
+
+	public void setPa(XICICPA pa) {
+		this.pa = pa;
+	}
+
+	public XICICPA getPa() {
+		return pa;
+	}
+
+	public void setStartPrbDl(BerInteger startPrbDl) {
+		this.startPrbDl = startPrbDl;
+	}
+
+	public BerInteger getStartPrbDl() {
+		return startPrbDl;
+	}
+
+	public void setEndPrbDl(BerInteger endPrbDl) {
+		this.endPrbDl = endPrbDl;
+	}
+
+	public BerInteger getEndPrbDl() {
+		return endPrbDl;
+	}
+
+	public void setSubframeBitmaskDl(BerBitString subframeBitmaskDl) {
+		this.subframeBitmaskDl = subframeBitmaskDl;
+	}
+
+	public BerBitString getSubframeBitmaskDl() {
+		return subframeBitmaskDl;
+	}
+
+	public void setP0UePusch(BerInteger p0UePusch) {
+		this.p0UePusch = p0UePusch;
+	}
+
+	public BerInteger getP0UePusch() {
+		return p0UePusch;
+	}
+
+	public void setStartPrbUl(BerInteger startPrbUl) {
+		this.startPrbUl = startPrbUl;
+	}
+
+	public BerInteger getStartPrbUl() {
+		return startPrbUl;
+	}
+
+	public void setEndPrbUl(BerInteger endPrbUl) {
+		this.endPrbUl = endPrbUl;
+	}
+
+	public BerInteger getEndPrbUl() {
+		return endPrbUl;
+	}
+
+	public void setSubframeBitmaskUl(BerBitString subframeBitmaskUl) {
+		this.subframeBitmaskUl = subframeBitmaskUl;
+	}
+
+	public BerBitString getSubframeBitmaskUl() {
+		return subframeBitmaskUl;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += subframeBitmaskUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 10
+		os.write(0x8A);
+		codeLength += 1;
+		
+		codeLength += endPrbUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 9
+		os.write(0x89);
+		codeLength += 1;
+		
+		codeLength += startPrbUl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 8
+		os.write(0x88);
+		codeLength += 1;
+		
+		codeLength += p0UePusch.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 7
+		os.write(0x87);
+		codeLength += 1;
+		
+		codeLength += subframeBitmaskDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 6
+		os.write(0x86);
+		codeLength += 1;
+		
+		codeLength += endPrbDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 5
+		os.write(0x85);
+		codeLength += 1;
+		
+		codeLength += startPrbDl.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 4
+		os.write(0x84);
+		codeLength += 1;
+		
+		codeLength += pa.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 3
+		os.write(0x83);
+		codeLength += 1;
+		
+		codeLength += crnti.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 2
+		os.write(0x82);
+		codeLength += 1;
+		
+		codeLength += pciArfcn.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += ecgi.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			ecgi = new ECGI();
+			subCodeLength += ecgi.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			pciArfcn = new PCIARFCN();
+			subCodeLength += pciArfcn.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
+			crnti = new CRNTI();
+			subCodeLength += crnti.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
+			pa = new XICICPA();
+			subCodeLength += pa.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
+			startPrbDl = new BerInteger();
+			subCodeLength += startPrbDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 5)) {
+			endPrbDl = new BerInteger();
+			subCodeLength += endPrbDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
+			subframeBitmaskDl = new BerBitString();
+			subCodeLength += subframeBitmaskDl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) {
+			p0UePusch = new BerInteger();
+			subCodeLength += p0UePusch.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
+			startPrbUl = new BerInteger();
+			subCodeLength += startPrbUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
+			endPrbUl = new BerInteger();
+			subCodeLength += endPrbUl.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) {
+			subframeBitmaskUl = new BerBitString();
+			subCodeLength += subframeBitmaskUl.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ecgi != null) {
+			sb.append("\"ecgi\": ");
+			ecgi.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pciArfcn != null) {
+			sb.append("\"pciArfcn\": ");
+			pciArfcn.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (crnti != null) {
+			sb.append("\"crnti\": ").append(crnti);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (pa != null) {
+			sb.append("\"pa\": ").append(pa);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (startPrbDl != null) {
+			sb.append("\"startPrbDl\": ").append(startPrbDl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (endPrbDl != null) {
+			sb.append("\"endPrbDl\": ").append(endPrbDl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (subframeBitmaskDl != null) {
+			sb.append("\"subframeBitmaskDl\": ").append(subframeBitmaskDl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (p0UePusch != null) {
+			sb.append("\"p0UePusch\": ").append(p0UePusch);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (startPrbUl != null) {
+			sb.append("\"startPrbUl\": ").append(startPrbUl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (endPrbUl != null) {
+			sb.append("\"endPrbUl\": ").append(endPrbUl);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (subframeBitmaskUl != null) {
+			sb.append("\"subframeBitmaskUl\": ").append(subframeBitmaskUl);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/XrancApiID.java b/src/main/java/org.onosproject.xran/codecs/pdu/XrancApiID.java
new file mode 100644
index 0000000..341b70f
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/XrancApiID.java
@@ -0,0 +1,30 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.types.BerEnum;
+
+import java.math.BigInteger;
+
+public class XrancApiID extends BerEnum {
+
+	private static final long serialVersionUID = 1L;
+
+	public XrancApiID() {
+	}
+
+	public XrancApiID(byte[] code) {
+		super(code);
+	}
+
+	public XrancApiID(BigInteger value) {
+		super(value);
+	}
+
+	public XrancApiID(long value) {
+		super(value);
+	}
+
+}
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/XrancPdu.java b/src/main/java/org.onosproject.xran/codecs/pdu/XrancPdu.java
new file mode 100644
index 0000000..d365a39
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/XrancPdu.java
@@ -0,0 +1,172 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class XrancPdu implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private XrancPduHdr hdr = null;
+	private XrancPduBody body = null;
+	
+	public XrancPdu() {
+	}
+
+	public XrancPdu(byte[] code) {
+		this.code = code;
+	}
+
+	public void setHdr(XrancPduHdr hdr) {
+		this.hdr = hdr;
+	}
+
+	public XrancPduHdr getHdr() {
+		return hdr;
+	}
+
+	public void setBody(XrancPduBody body) {
+		this.body = body;
+	}
+
+	public XrancPduBody getBody() {
+		return body;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		int sublength;
+
+		sublength = body.encode(os);
+		codeLength += sublength;
+		codeLength += BerLength.encodeLength(os, sublength);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+		os.write(0xA1);
+		codeLength += 1;
+		
+		codeLength += hdr.encode(os, false);
+		// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+		os.write(0xA0);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			hdr = new XrancPduHdr();
+			subCodeLength += hdr.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			subCodeLength += length.decode(is);
+			body = new XrancPduBody();
+			subCodeLength += body.decode(is, null);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (hdr != null) {
+			sb.append("\"hdr\": ");
+			hdr.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (body != null) {
+			sb.append("\"body\": ");
+			body.appendAsString(sb, indentLevel + 1);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/XrancPduBody.java b/src/main/java/org.onosproject.xran/codecs/pdu/XrancPduBody.java
new file mode 100644
index 0000000..c0a38fc
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/XrancPduBody.java
@@ -0,0 +1,1098 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerTag;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class XrancPduBody implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public byte[] code = null;
+	private CellConfigRequest cellConfigRequest = null;
+	private CellConfigReport cellConfigReport = null;
+	private UEAdmissionRequest uEAdmissionRequest = null;
+	private UEAdmissionResponse uEAdmissionResponse = null;
+	private UEAttachComplete uEAttachComplete = null;
+	private UEAdmissionStatus uEAdmissionStatus = null;
+	private UEReconfigInd uEReconfigInd = null;
+	private UEReleaseInd uEReleaseInd = null;
+	private BearerAdmissionRequest bearerAdmissionRequest = null;
+	private BearerAdmissionResponse bearerAdmissionResponse = null;
+	private BearerAdmissionStatus bearerAdmissionStatus = null;
+	private BearerReleaseInd bearerReleaseInd = null;
+	private UECapabilityEnquiry uECapabilityEnquiry = null;
+	private UECapabilityInfo uECapabilityInfo = null;
+	private HORequest hORequest = null;
+	private HOFailure hOFailure = null;
+	private HOComplete hOComplete = null;
+	private RXSigMeasConfig rXSigMeasConfig = null;
+	private RXSigMeasReport rXSigMeasReport = null;
+	private L2MeasConfig l2MeasConfig = null;
+	private RadioMeasReportPerUE radioMeasReportPerUE = null;
+	private RadioMeasReportPerCell radioMeasReportPerCell = null;
+	private SchedMeasReportPerUE schedMeasReportPerUE = null;
+	private SchedMeasReportPerCell schedMeasReportPerCell = null;
+	private PDCPMeasReportPerUe pDCPMeasReportPerUe = null;
+	private XICICConfig xICICConfig = null;
+	private RRMConfig rRMConfig = null;
+	private RRMConfigStatus rRMConfigStatus = null;
+	private ScellAdd scellAdd = null;
+	private ScellAddStatus scellAddStatus = null;
+	private ScellDelete scellDelete = null;
+	private SeNBAdd seNBAdd = null;
+	private SeNBAddStatus seNBAddStatus = null;
+	private SeNBDelete seNBDelete = null;
+	private TrafficSplitConfig trafficSplitConfig = null;
+	
+	public XrancPduBody() {
+	}
+
+	public XrancPduBody(byte[] code) {
+		this.code = code;
+	}
+
+	public void setCellConfigRequest(CellConfigRequest cellConfigRequest) {
+		this.cellConfigRequest = cellConfigRequest;
+	}
+
+	public CellConfigRequest getCellConfigRequest() {
+		return cellConfigRequest;
+	}
+
+	public void setCellConfigReport(CellConfigReport cellConfigReport) {
+		this.cellConfigReport = cellConfigReport;
+	}
+
+	public CellConfigReport getCellConfigReport() {
+		return cellConfigReport;
+	}
+
+	public void setUEAdmissionRequest(UEAdmissionRequest uEAdmissionRequest) {
+		this.uEAdmissionRequest = uEAdmissionRequest;
+	}
+
+	public UEAdmissionRequest getUEAdmissionRequest() {
+		return uEAdmissionRequest;
+	}
+
+	public void setUEAdmissionResponse(UEAdmissionResponse uEAdmissionResponse) {
+		this.uEAdmissionResponse = uEAdmissionResponse;
+	}
+
+	public UEAdmissionResponse getUEAdmissionResponse() {
+		return uEAdmissionResponse;
+	}
+
+	public void setUEAttachComplete(UEAttachComplete uEAttachComplete) {
+		this.uEAttachComplete = uEAttachComplete;
+	}
+
+	public UEAttachComplete getUEAttachComplete() {
+		return uEAttachComplete;
+	}
+
+	public void setUEAdmissionStatus(UEAdmissionStatus uEAdmissionStatus) {
+		this.uEAdmissionStatus = uEAdmissionStatus;
+	}
+
+	public UEAdmissionStatus getUEAdmissionStatus() {
+		return uEAdmissionStatus;
+	}
+
+	public void setUEReconfigInd(UEReconfigInd uEReconfigInd) {
+		this.uEReconfigInd = uEReconfigInd;
+	}
+
+	public UEReconfigInd getUEReconfigInd() {
+		return uEReconfigInd;
+	}
+
+	public void setUEReleaseInd(UEReleaseInd uEReleaseInd) {
+		this.uEReleaseInd = uEReleaseInd;
+	}
+
+	public UEReleaseInd getUEReleaseInd() {
+		return uEReleaseInd;
+	}
+
+	public void setBearerAdmissionRequest(BearerAdmissionRequest bearerAdmissionRequest) {
+		this.bearerAdmissionRequest = bearerAdmissionRequest;
+	}
+
+	public BearerAdmissionRequest getBearerAdmissionRequest() {
+		return bearerAdmissionRequest;
+	}
+
+	public void setBearerAdmissionResponse(BearerAdmissionResponse bearerAdmissionResponse) {
+		this.bearerAdmissionResponse = bearerAdmissionResponse;
+	}
+
+	public BearerAdmissionResponse getBearerAdmissionResponse() {
+		return bearerAdmissionResponse;
+	}
+
+	public void setBearerAdmissionStatus(BearerAdmissionStatus bearerAdmissionStatus) {
+		this.bearerAdmissionStatus = bearerAdmissionStatus;
+	}
+
+	public BearerAdmissionStatus getBearerAdmissionStatus() {
+		return bearerAdmissionStatus;
+	}
+
+	public void setBearerReleaseInd(BearerReleaseInd bearerReleaseInd) {
+		this.bearerReleaseInd = bearerReleaseInd;
+	}
+
+	public BearerReleaseInd getBearerReleaseInd() {
+		return bearerReleaseInd;
+	}
+
+	public void setUECapabilityEnquiry(UECapabilityEnquiry uECapabilityEnquiry) {
+		this.uECapabilityEnquiry = uECapabilityEnquiry;
+	}
+
+	public UECapabilityEnquiry getUECapabilityEnquiry() {
+		return uECapabilityEnquiry;
+	}
+
+	public void setUECapabilityInfo(UECapabilityInfo uECapabilityInfo) {
+		this.uECapabilityInfo = uECapabilityInfo;
+	}
+
+	public UECapabilityInfo getUECapabilityInfo() {
+		return uECapabilityInfo;
+	}
+
+	public void setHORequest(HORequest hORequest) {
+		this.hORequest = hORequest;
+	}
+
+	public HORequest getHORequest() {
+		return hORequest;
+	}
+
+	public void setHOFailure(HOFailure hOFailure) {
+		this.hOFailure = hOFailure;
+	}
+
+	public HOFailure getHOFailure() {
+		return hOFailure;
+	}
+
+	public void setHOComplete(HOComplete hOComplete) {
+		this.hOComplete = hOComplete;
+	}
+
+	public HOComplete getHOComplete() {
+		return hOComplete;
+	}
+
+	public void setRXSigMeasConfig(RXSigMeasConfig rXSigMeasConfig) {
+		this.rXSigMeasConfig = rXSigMeasConfig;
+	}
+
+	public RXSigMeasConfig getRXSigMeasConfig() {
+		return rXSigMeasConfig;
+	}
+
+	public void setRXSigMeasReport(RXSigMeasReport rXSigMeasReport) {
+		this.rXSigMeasReport = rXSigMeasReport;
+	}
+
+	public RXSigMeasReport getRXSigMeasReport() {
+		return rXSigMeasReport;
+	}
+
+	public void setL2MeasConfig(L2MeasConfig l2MeasConfig) {
+		this.l2MeasConfig = l2MeasConfig;
+	}
+
+	public L2MeasConfig getL2MeasConfig() {
+		return l2MeasConfig;
+	}
+
+	public void setRadioMeasReportPerUE(RadioMeasReportPerUE radioMeasReportPerUE) {
+		this.radioMeasReportPerUE = radioMeasReportPerUE;
+	}
+
+	public RadioMeasReportPerUE getRadioMeasReportPerUE() {
+		return radioMeasReportPerUE;
+	}
+
+	public void setRadioMeasReportPerCell(RadioMeasReportPerCell radioMeasReportPerCell) {
+		this.radioMeasReportPerCell = radioMeasReportPerCell;
+	}
+
+	public RadioMeasReportPerCell getRadioMeasReportPerCell() {
+		return radioMeasReportPerCell;
+	}
+
+	public void setSchedMeasReportPerUE(SchedMeasReportPerUE schedMeasReportPerUE) {
+		this.schedMeasReportPerUE = schedMeasReportPerUE;
+	}
+
+	public SchedMeasReportPerUE getSchedMeasReportPerUE() {
+		return schedMeasReportPerUE;
+	}
+
+	public void setSchedMeasReportPerCell(SchedMeasReportPerCell schedMeasReportPerCell) {
+		this.schedMeasReportPerCell = schedMeasReportPerCell;
+	}
+
+	public SchedMeasReportPerCell getSchedMeasReportPerCell() {
+		return schedMeasReportPerCell;
+	}
+
+	public void setPDCPMeasReportPerUe(PDCPMeasReportPerUe pDCPMeasReportPerUe) {
+		this.pDCPMeasReportPerUe = pDCPMeasReportPerUe;
+	}
+
+	public PDCPMeasReportPerUe getPDCPMeasReportPerUe() {
+		return pDCPMeasReportPerUe;
+	}
+
+	public void setXICICConfig(XICICConfig xICICConfig) {
+		this.xICICConfig = xICICConfig;
+	}
+
+	public XICICConfig getXICICConfig() {
+		return xICICConfig;
+	}
+
+	public void setRRMConfig(RRMConfig rRMConfig) {
+		this.rRMConfig = rRMConfig;
+	}
+
+	public RRMConfig getRRMConfig() {
+		return rRMConfig;
+	}
+
+	public void setRRMConfigStatus(RRMConfigStatus rRMConfigStatus) {
+		this.rRMConfigStatus = rRMConfigStatus;
+	}
+
+	public RRMConfigStatus getRRMConfigStatus() {
+		return rRMConfigStatus;
+	}
+
+	public void setScellAdd(ScellAdd scellAdd) {
+		this.scellAdd = scellAdd;
+	}
+
+	public ScellAdd getScellAdd() {
+		return scellAdd;
+	}
+
+	public void setScellAddStatus(ScellAddStatus scellAddStatus) {
+		this.scellAddStatus = scellAddStatus;
+	}
+
+	public ScellAddStatus getScellAddStatus() {
+		return scellAddStatus;
+	}
+
+	public void setScellDelete(ScellDelete scellDelete) {
+		this.scellDelete = scellDelete;
+	}
+
+	public ScellDelete getScellDelete() {
+		return scellDelete;
+	}
+
+	public void setSeNBAdd(SeNBAdd seNBAdd) {
+		this.seNBAdd = seNBAdd;
+	}
+
+	public SeNBAdd getSeNBAdd() {
+		return seNBAdd;
+	}
+
+	public void setSeNBAddStatus(SeNBAddStatus seNBAddStatus) {
+		this.seNBAddStatus = seNBAddStatus;
+	}
+
+	public SeNBAddStatus getSeNBAddStatus() {
+		return seNBAddStatus;
+	}
+
+	public void setSeNBDelete(SeNBDelete seNBDelete) {
+		this.seNBDelete = seNBDelete;
+	}
+
+	public SeNBDelete getSeNBDelete() {
+		return seNBDelete;
+	}
+
+	public void setTrafficSplitConfig(TrafficSplitConfig trafficSplitConfig) {
+		this.trafficSplitConfig = trafficSplitConfig;
+	}
+
+	public TrafficSplitConfig getTrafficSplitConfig() {
+		return trafficSplitConfig;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		if (trafficSplitConfig != null) {
+			codeLength += trafficSplitConfig.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 34
+			os.write(0x22);
+			os.write(0xBF);
+			codeLength += 2;
+			return codeLength;
+		}
+		
+		if (seNBDelete != null) {
+			codeLength += seNBDelete.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 33
+			os.write(0x21);
+			os.write(0xBF);
+			codeLength += 2;
+			return codeLength;
+		}
+		
+		if (seNBAddStatus != null) {
+			codeLength += seNBAddStatus.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 32
+			os.write(0x20);
+			os.write(0xBF);
+			codeLength += 2;
+			return codeLength;
+		}
+		
+		if (seNBAdd != null) {
+			codeLength += seNBAdd.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 31
+			os.write(0x1F);
+			os.write(0xBF);
+			codeLength += 2;
+			return codeLength;
+		}
+		
+		if (scellDelete != null) {
+			codeLength += scellDelete.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 30
+			os.write(0xBE);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (scellAddStatus != null) {
+			codeLength += scellAddStatus.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 29
+			os.write(0xBD);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (scellAdd != null) {
+			codeLength += scellAdd.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 28
+			os.write(0xBC);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (rRMConfigStatus != null) {
+			codeLength += rRMConfigStatus.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 27
+			os.write(0xBB);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (rRMConfig != null) {
+			codeLength += rRMConfig.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 26
+			os.write(0xBA);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (xICICConfig != null) {
+			codeLength += xICICConfig.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 25
+			os.write(0xB9);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (pDCPMeasReportPerUe != null) {
+			codeLength += pDCPMeasReportPerUe.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 24
+			os.write(0xB8);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (schedMeasReportPerCell != null) {
+			codeLength += schedMeasReportPerCell.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 23
+			os.write(0xB7);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (schedMeasReportPerUE != null) {
+			codeLength += schedMeasReportPerUE.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 22
+			os.write(0xB6);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (radioMeasReportPerCell != null) {
+			codeLength += radioMeasReportPerCell.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 21
+			os.write(0xB5);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (radioMeasReportPerUE != null) {
+			codeLength += radioMeasReportPerUE.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 20
+			os.write(0xB4);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (l2MeasConfig != null) {
+			codeLength += l2MeasConfig.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 19
+			os.write(0xB3);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (rXSigMeasReport != null) {
+			codeLength += rXSigMeasReport.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 18
+			os.write(0xB2);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (rXSigMeasConfig != null) {
+			codeLength += rXSigMeasConfig.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 17
+			os.write(0xB1);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (hOComplete != null) {
+			codeLength += hOComplete.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 16
+			os.write(0xB0);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (hOFailure != null) {
+			codeLength += hOFailure.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 15
+			os.write(0xAF);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (hORequest != null) {
+			codeLength += hORequest.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 14
+			os.write(0xAE);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (uECapabilityInfo != null) {
+			codeLength += uECapabilityInfo.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 13
+			os.write(0xAD);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (uECapabilityEnquiry != null) {
+			codeLength += uECapabilityEnquiry.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 12
+			os.write(0xAC);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (bearerReleaseInd != null) {
+			codeLength += bearerReleaseInd.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 11
+			os.write(0xAB);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (bearerAdmissionStatus != null) {
+			codeLength += bearerAdmissionStatus.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 10
+			os.write(0xAA);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (bearerAdmissionResponse != null) {
+			codeLength += bearerAdmissionResponse.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 9
+			os.write(0xA9);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (bearerAdmissionRequest != null) {
+			codeLength += bearerAdmissionRequest.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 8
+			os.write(0xA8);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (uEReleaseInd != null) {
+			codeLength += uEReleaseInd.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 7
+			os.write(0xA7);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (uEReconfigInd != null) {
+			codeLength += uEReconfigInd.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 6
+			os.write(0xA6);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (uEAdmissionStatus != null) {
+			codeLength += uEAdmissionStatus.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 5
+			os.write(0xA5);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (uEAttachComplete != null) {
+			codeLength += uEAttachComplete.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 4
+			os.write(0xA4);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (uEAdmissionResponse != null) {
+			codeLength += uEAdmissionResponse.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 3
+			os.write(0xA3);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (uEAdmissionRequest != null) {
+			codeLength += uEAdmissionRequest.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
+			os.write(0xA2);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (cellConfigReport != null) {
+			codeLength += cellConfigReport.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
+			os.write(0xA1);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		if (cellConfigRequest != null) {
+			codeLength += cellConfigRequest.encode(os, false);
+			// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
+			os.write(0xA0);
+			codeLength += 1;
+			return codeLength;
+		}
+		
+		throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, null);
+	}
+
+	public int decode(InputStream is, BerTag berTag) throws IOException {
+
+		int codeLength = 0;
+		BerTag passedTag = berTag;
+
+		if (berTag == null) {
+			berTag = new BerTag();
+			codeLength += berTag.decode(is);
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
+			cellConfigRequest = new CellConfigRequest();
+			codeLength += cellConfigRequest.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
+			cellConfigReport = new CellConfigReport();
+			codeLength += cellConfigReport.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
+			uEAdmissionRequest = new UEAdmissionRequest();
+			codeLength += uEAdmissionRequest.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
+			uEAdmissionResponse = new UEAdmissionResponse();
+			codeLength += uEAdmissionResponse.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
+			uEAttachComplete = new UEAttachComplete();
+			codeLength += uEAttachComplete.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
+			uEAdmissionStatus = new UEAdmissionStatus();
+			codeLength += uEAdmissionStatus.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
+			uEReconfigInd = new UEReconfigInd();
+			codeLength += uEReconfigInd.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) {
+			uEReleaseInd = new UEReleaseInd();
+			codeLength += uEReleaseInd.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) {
+			bearerAdmissionRequest = new BearerAdmissionRequest();
+			codeLength += bearerAdmissionRequest.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 9)) {
+			bearerAdmissionResponse = new BearerAdmissionResponse();
+			codeLength += bearerAdmissionResponse.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 10)) {
+			bearerAdmissionStatus = new BearerAdmissionStatus();
+			codeLength += bearerAdmissionStatus.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 11)) {
+			bearerReleaseInd = new BearerReleaseInd();
+			codeLength += bearerReleaseInd.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) {
+			uECapabilityEnquiry = new UECapabilityEnquiry();
+			codeLength += uECapabilityEnquiry.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) {
+			uECapabilityInfo = new UECapabilityInfo();
+			codeLength += uECapabilityInfo.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 14)) {
+			hORequest = new HORequest();
+			codeLength += hORequest.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 15)) {
+			hOFailure = new HOFailure();
+			codeLength += hOFailure.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 16)) {
+			hOComplete = new HOComplete();
+			codeLength += hOComplete.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 17)) {
+			rXSigMeasConfig = new RXSigMeasConfig();
+			codeLength += rXSigMeasConfig.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 18)) {
+			rXSigMeasReport = new RXSigMeasReport();
+			codeLength += rXSigMeasReport.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 19)) {
+			l2MeasConfig = new L2MeasConfig();
+			codeLength += l2MeasConfig.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 20)) {
+			radioMeasReportPerUE = new RadioMeasReportPerUE();
+			codeLength += radioMeasReportPerUE.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 21)) {
+			radioMeasReportPerCell = new RadioMeasReportPerCell();
+			codeLength += radioMeasReportPerCell.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 22)) {
+			schedMeasReportPerUE = new SchedMeasReportPerUE();
+			codeLength += schedMeasReportPerUE.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 23)) {
+			schedMeasReportPerCell = new SchedMeasReportPerCell();
+			codeLength += schedMeasReportPerCell.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 24)) {
+			pDCPMeasReportPerUe = new PDCPMeasReportPerUe();
+			codeLength += pDCPMeasReportPerUe.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 25)) {
+			xICICConfig = new XICICConfig();
+			codeLength += xICICConfig.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 26)) {
+			rRMConfig = new RRMConfig();
+			codeLength += rRMConfig.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 27)) {
+			rRMConfigStatus = new RRMConfigStatus();
+			codeLength += rRMConfigStatus.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 28)) {
+			scellAdd = new ScellAdd();
+			codeLength += scellAdd.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 29)) {
+			scellAddStatus = new ScellAddStatus();
+			codeLength += scellAddStatus.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) {
+			scellDelete = new ScellDelete();
+			codeLength += scellDelete.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 31)) {
+			seNBAdd = new SeNBAdd();
+			codeLength += seNBAdd.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 32)) {
+			seNBAddStatus = new SeNBAddStatus();
+			codeLength += seNBAddStatus.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 33)) {
+			seNBDelete = new SeNBDelete();
+			codeLength += seNBDelete.decode(is, false);
+			return codeLength;
+		}
+
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 34)) {
+			trafficSplitConfig = new TrafficSplitConfig();
+			codeLength += trafficSplitConfig.decode(is, false);
+			return codeLength;
+		}
+
+		if (passedTag != null) {
+			return 0;
+		}
+
+		throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item.");
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		if (cellConfigRequest != null) {
+			sb.append("\"cellConfigRequest\": ");
+			cellConfigRequest.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (cellConfigReport != null) {
+			sb.append("\"cellConfigReport\": ");
+			cellConfigReport.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (uEAdmissionRequest != null) {
+			sb.append("\"uEAdmissionRequest\": ");
+			uEAdmissionRequest.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (uEAdmissionResponse != null) {
+			sb.append("\"uEAdmissionResponse\": ");
+			uEAdmissionResponse.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (uEAttachComplete != null) {
+			sb.append("\"uEAttachComplete\": ");
+			uEAttachComplete.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (uEAdmissionStatus != null) {
+			sb.append("\"uEAdmissionStatus\": ");
+			uEAdmissionStatus.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (uEReconfigInd != null) {
+			sb.append("\"uEReconfigInd\": ");
+			uEReconfigInd.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (uEReleaseInd != null) {
+			sb.append("\"uEReleaseInd\": ");
+			uEReleaseInd.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (bearerAdmissionRequest != null) {
+			sb.append("\"bearerAdmissionRequest\": ");
+			bearerAdmissionRequest.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (bearerAdmissionResponse != null) {
+			sb.append("\"bearerAdmissionResponse\": ");
+			bearerAdmissionResponse.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (bearerAdmissionStatus != null) {
+			sb.append("\"bearerAdmissionStatus\": ");
+			bearerAdmissionStatus.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (bearerReleaseInd != null) {
+			sb.append("\"bearerReleaseInd\": ");
+			bearerReleaseInd.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (uECapabilityEnquiry != null) {
+			sb.append("\"uECapabilityEnquiry\": ");
+			uECapabilityEnquiry.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (uECapabilityInfo != null) {
+			sb.append("\"uECapabilityInfo\": ");
+			uECapabilityInfo.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (hORequest != null) {
+			sb.append("\"hORequest\": ");
+			hORequest.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (hOFailure != null) {
+			sb.append("\"hOFailure\": ");
+			hOFailure.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (hOComplete != null) {
+			sb.append("\"hOComplete\": ");
+			hOComplete.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (rXSigMeasConfig != null) {
+			sb.append("\"rXSigMeasConfig\": ");
+			rXSigMeasConfig.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (rXSigMeasReport != null) {
+			sb.append("\"rXSigMeasReport\": ");
+			rXSigMeasReport.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (l2MeasConfig != null) {
+			sb.append("\"l2MeasConfig\": ");
+			l2MeasConfig.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (radioMeasReportPerUE != null) {
+			sb.append("\"radioMeasReportPerUE\": ");
+			radioMeasReportPerUE.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (radioMeasReportPerCell != null) {
+			sb.append("\"radioMeasReportPerCell\": ");
+			radioMeasReportPerCell.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (schedMeasReportPerUE != null) {
+			sb.append("\"schedMeasReportPerUE\": ");
+			schedMeasReportPerUE.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (schedMeasReportPerCell != null) {
+			sb.append("\"schedMeasReportPerCell\": ");
+			schedMeasReportPerCell.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (pDCPMeasReportPerUe != null) {
+			sb.append("\"pDCPMeasReportPerUe\": ");
+			pDCPMeasReportPerUe.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (xICICConfig != null) {
+			sb.append("\"xICICConfig\": ");
+			xICICConfig.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (rRMConfig != null) {
+			sb.append("\"rRMConfig\": ");
+			rRMConfig.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (rRMConfigStatus != null) {
+			sb.append("\"rRMConfigStatus\": ");
+			rRMConfigStatus.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (scellAdd != null) {
+			sb.append("\"scellAdd\": ");
+			scellAdd.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (scellAddStatus != null) {
+			sb.append("\"scellAddStatus\": ");
+			scellAddStatus.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (scellDelete != null) {
+			sb.append("\"scellDelete\": ");
+			scellDelete.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (seNBAdd != null) {
+			sb.append("\"seNBAdd\": ");
+			seNBAdd.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (seNBAddStatus != null) {
+			sb.append("\"seNBAddStatus\": ");
+			seNBAddStatus.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (seNBDelete != null) {
+			sb.append("\"seNBDelete\": ");
+			seNBDelete.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		if (trafficSplitConfig != null) {
+			sb.append("\"trafficSplitConfig\": ");
+			trafficSplitConfig.appendAsString(sb, indentLevel + 1);
+			return;
+		}
+
+		sb.append("<none>");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/XrancPduHdr.java b/src/main/java/org.onosproject.xran/codecs/pdu/XrancPduHdr.java
new file mode 100644
index 0000000..63480d4
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/XrancPduHdr.java
@@ -0,0 +1,166 @@
+/**
+ * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
+ */
+
+package org.onosproject.xran.codecs.pdu;
+
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.BerLength;
+import org.openmuc.jasn1.ber.BerTag;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+
+public class XrancPduHdr implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
+
+	public byte[] code = null;
+	private BerUTF8String ver = null;
+	private XrancApiID apiId = null;
+	
+	public XrancPduHdr() {
+	}
+
+	public XrancPduHdr(byte[] code) {
+		this.code = code;
+	}
+
+	public void setVer(BerUTF8String ver) {
+		this.ver = ver;
+	}
+
+	public BerUTF8String getVer() {
+		return ver;
+	}
+
+	public void setApiId(XrancApiID apiId) {
+		this.apiId = apiId;
+	}
+
+	public XrancApiID getApiId() {
+		return apiId;
+	}
+
+	public int encode(BerByteArrayOutputStream os) throws IOException {
+		return encode(os, true);
+	}
+
+	public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
+
+		if (code != null) {
+			for (int i = code.length - 1; i >= 0; i--) {
+				os.write(code[i]);
+			}
+			if (withTag) {
+				return tag.encode(os) + code.length;
+			}
+			return code.length;
+		}
+
+		int codeLength = 0;
+		codeLength += apiId.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 1
+		os.write(0x81);
+		codeLength += 1;
+		
+		codeLength += ver.encode(os, false);
+		// write tag: CONTEXT_CLASS, PRIMITIVE, 0
+		os.write(0x80);
+		codeLength += 1;
+		
+		codeLength += BerLength.encodeLength(os, codeLength);
+
+		if (withTag) {
+			codeLength += tag.encode(os);
+		}
+
+		return codeLength;
+
+	}
+
+	public int decode(InputStream is) throws IOException {
+		return decode(is, true);
+	}
+
+	public int decode(InputStream is, boolean withTag) throws IOException {
+		int codeLength = 0;
+		int subCodeLength = 0;
+		BerTag berTag = new BerTag();
+
+		if (withTag) {
+			codeLength += tag.decodeAndCheck(is);
+		}
+
+		BerLength length = new BerLength();
+		codeLength += length.decode(is);
+
+		int totalLength = length.val;
+		codeLength += totalLength;
+
+		subCodeLength += berTag.decode(is);
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
+			ver = new BerUTF8String();
+			subCodeLength += ver.decode(is, false);
+			subCodeLength += berTag.decode(is);
+		}
+		else {
+			throw new IOException("Tag does not match the mandatory sequence element tag.");
+		}
+		
+		if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
+			apiId = new XrancApiID();
+			subCodeLength += apiId.decode(is, false);
+			if (subCodeLength == totalLength) {
+				return codeLength;
+			}
+		}
+		throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
+
+		
+	}
+
+	public void encodeAndSave(int encodingSizeGuess) throws IOException {
+		BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
+		encode(os, false);
+		code = os.getArray();
+	}
+
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		appendAsString(sb, 0);
+		return sb.toString();
+	}
+
+	public void appendAsString(StringBuilder sb, int indentLevel) {
+
+		sb.append("{");
+		sb.append("\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (ver != null) {
+			sb.append("\"ver\": ").append(ver);
+		}
+		
+		sb.append(",\n");
+		for (int i = 0; i < indentLevel + 1; i++) {
+			sb.append("\t");
+		}
+		if (apiId != null) {
+			sb.append("\"apiId\": ").append(apiId);
+		}
+		
+		sb.append("\n");
+		for (int i = 0; i < indentLevel; i++) {
+			sb.append("\t");
+		}
+		sb.append("}");
+	}
+
+}
+
diff --git a/src/main/java/org.onosproject.xran/codecs/pdu/package-info.java b/src/main/java/org.onosproject.xran/codecs/pdu/package-info.java
new file mode 100644
index 0000000..570aae0
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/codecs/pdu/package-info.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.codecs.pdu;
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/controller/Controller.java b/src/main/java/org.onosproject.xran/controller/Controller.java
new file mode 100644
index 0000000..b5b7f7d
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/controller/Controller.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.controller;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.sctp.SctpChannel;
+import io.netty.channel.sctp.nio.NioSctpServerChannel;
+import io.netty.handler.logging.LogLevel;
+import io.netty.handler.logging.LoggingHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Created by dimitris on 7/27/17.
+ */
+public class Controller {
+    protected static final Logger log = LoggerFactory.getLogger(Controller.class);
+    protected XranDeviceAgent deviceAgent;
+    protected XranHostAgent hostAgent;
+    protected XranPacketProcessor packetAgent;
+    private EventLoopGroup bossGroup;
+    private EventLoopGroup workerGroup;
+    private ChannelFuture channel;
+    private int port = 8007;
+    private boolean isRunning = false;
+
+    public void run() {
+        final Controller ctrl = this;
+        try {
+            ServerBootstrap b = createServerBootStrap();
+            b.childHandler(new ChannelInitializer<SctpChannel>() {
+                @Override
+                public void initChannel(SctpChannel ch) throws Exception {
+                    ch.pipeline().addLast(
+                            //new LoggingHandler(LogLevel.INFO),
+                            new XranChannelHandler(ctrl)
+                    );
+                }
+            });
+            channel = b.bind(this.port).sync();
+        } catch (Exception e) {
+            log.warn(e.getMessage());
+            e.printStackTrace();
+        }
+    }
+
+    private ServerBootstrap createServerBootStrap() {
+        bossGroup = new NioEventLoopGroup(1);
+        workerGroup = new NioEventLoopGroup();
+
+        ServerBootstrap b = new ServerBootstrap();
+        b.group(bossGroup, workerGroup)
+                .channel(NioSctpServerChannel.class)
+                .handler(new LoggingHandler(LogLevel.INFO));
+        return b;
+    }
+
+    public void start(XranDeviceAgent deviceAgent, XranHostAgent hostAgent, XranControllerImpl.InternalXranPacketAgent packetAgent, int port) {
+        if (isRunning && this.port != port) {
+            stop();
+            this.deviceAgent = deviceAgent;
+            this.hostAgent = hostAgent;
+            this.packetAgent = packetAgent;
+            this.port = port;
+            run();
+        } else if (!isRunning) {
+            this.deviceAgent = deviceAgent;
+            this.hostAgent = hostAgent;
+            this.packetAgent = packetAgent;
+            this.port = port;
+            run();
+            isRunning = true;
+        }
+    }
+
+
+    public void stop() {
+        if (isRunning) {
+            channel.channel().close();
+            bossGroup.shutdownGracefully();
+            workerGroup.shutdownGracefully();
+            isRunning = false;
+        }
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/controller/XranChannelHandler.java b/src/main/java/org.onosproject.xran/controller/XranChannelHandler.java
new file mode 100644
index 0000000..15c1e0b
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/controller/XranChannelHandler.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.controller;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandler.Sharable;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.sctp.SctpMessage;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onosproject.net.DeviceId;
+import org.onosproject.xran.codecs.pdu.XrancPdu;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.bind.DatatypeConverter;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.charset.Charset;
+
+import static org.onosproject.net.DeviceId.deviceId;
+
+/**
+ * Created by dimitris on 7/20/17.
+ */
+
+@Sharable
+public class XranChannelHandler extends ChannelInboundHandlerAdapter {
+
+    private static final Logger log =
+            LoggerFactory.getLogger(XranChannelHandler.class);
+
+    private final Controller controller;
+
+    XranChannelHandler(Controller controller) {
+        this.controller = controller;
+    }
+
+    public static SctpMessage getSctpMessage(XrancPdu pdu) throws IOException {
+        BerByteArrayOutputStream os = new BerByteArrayOutputStream(4096);
+
+        pdu.encode(os);
+
+        log.debug("Sending message: {}", pdu);
+        final ByteBuf buf = Unpooled.buffer(os.getArray().length);
+        for (int i = 0; i < buf.capacity(); i++) {
+            buf.writeByte(os.getArray()[i]);
+        }
+        return new SctpMessage(0, 0, buf);
+    }
+
+    @Override
+    public void channelActive(ChannelHandlerContext ctx) throws IOException, URISyntaxException {
+        final SocketAddress address = ctx.channel().remoteAddress();
+        if (!(address instanceof InetSocketAddress)) {
+            log.warn("Invalid client connection. Xran Cell is indentifed based on IP");
+            ctx.close();
+            return;
+        }
+
+        final InetSocketAddress inetAddress = (InetSocketAddress) address;
+        final String host = inetAddress.getHostString();
+        log.info("New client connected to the Server: {}", host);
+
+        log.info("Adding device...");
+
+        controller.deviceAgent.addConnectedCell(host, ctx);
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws IOException {
+        SctpMessage sctpMessage = (SctpMessage) msg;
+        ByteBuf byteBuf = sctpMessage.content();
+
+        byte[] bytes = new byte[byteBuf.readableBytes()];
+        byteBuf.readBytes(bytes);
+
+        XrancPdu recv_pdu = new XrancPdu();
+
+        InputStream inputStream = new ByteArrayInputStream(bytes);
+
+        recv_pdu.decode(inputStream);
+
+        controller.packetAgent.handlePacket(recv_pdu, ctx);
+    }
+
+    @Override
+    public void channelInactive(ChannelHandlerContext ctx) {
+        log.info("Client dropped the connection");
+
+        final SocketAddress address = ctx.channel().remoteAddress();
+        if (!(address instanceof InetSocketAddress)) {
+            log.warn("Invalid client connection. Xran Cell is indentifed based on IP");
+            ctx.close();
+            return;
+        }
+
+        final InetSocketAddress inetAddress = (InetSocketAddress) address;
+        final String host = inetAddress.getHostString();
+
+        controller.deviceAgent.removeConnectedCell(host);
+
+        ctx.close();
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
+        // Close the connection when an exception is raised.
+        log.warn("exceptionCaught: {}", ExceptionUtils.getStackTrace(cause));
+        cause.printStackTrace();
+        ctx.close();
+    }
+}
+
diff --git a/src/main/java/org.onosproject.xran/controller/XranController.java b/src/main/java/org.onosproject.xran/controller/XranController.java
new file mode 100644
index 0000000..19b7537
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/controller/XranController.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.controller;
+
+import org.onosproject.xran.providers.XranDeviceListener;
+import org.onosproject.xran.providers.XranHostListener;
+
+/**
+ * Created by dimitris on 7/27/17.
+ */
+public interface XranController {
+
+    void addListener(XranDeviceListener listener);
+
+    void addListener(XranHostListener listener);
+
+    void removeListener(XranDeviceListener listener);
+
+    void removeListener(XranHostListener listener);
+}
diff --git a/src/main/java/org.onosproject.xran/controller/XranControllerImpl.java b/src/main/java/org.onosproject.xran/controller/XranControllerImpl.java
new file mode 100644
index 0000000..36b4c07
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/controller/XranControllerImpl.java
@@ -0,0 +1,787 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.controller;
+
+import com.google.common.collect.Sets;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.sctp.SctpMessage;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.felix.scr.annotations.*;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.config.*;
+import org.onosproject.net.config.basics.SubjectFactories;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.host.HostEvent;
+import org.onosproject.net.host.HostListener;
+import org.onosproject.net.host.HostService;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.codecs.api.*;
+import org.onosproject.xran.codecs.pdu.*;
+import org.onosproject.xran.entities.RnibCell;
+import org.onosproject.xran.entities.RnibLink;
+import org.onosproject.xran.entities.RnibUe;
+import org.onosproject.xran.identifiers.LinkId;
+import org.onosproject.xran.impl.XranConfig;
+import org.onosproject.xran.providers.XranDeviceListener;
+import org.onosproject.xran.providers.XranHostListener;
+import org.onosproject.xran.samplemessages.*;
+import org.onosproject.xran.wrapper.CellMap;
+import org.onosproject.xran.wrapper.LinkMap;
+import org.onosproject.xran.wrapper.UeMap;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.stream.Collectors;
+
+import static org.onosproject.net.DeviceId.deviceId;
+import static org.onosproject.xran.entities.RnibCell.decodeDeviceId;
+import static org.onosproject.xran.entities.RnibCell.uri;
+import static org.onosproject.xran.entities.RnibUe.UeState;
+import static org.onosproject.xran.entities.RnibUe.hostIdtoMME;
+
+/**
+ * Created by dimitris on 7/20/17.
+ */
+@Component(immediate = true)
+@Service
+public class XranControllerImpl implements XranController {
+    private static final String XRAN_APP_ID = "org.onosproject.xran";
+    private static final Class<XranConfig> CONFIG_CLASS = XranConfig.class;
+
+    private static final Logger log =
+            LoggerFactory.getLogger(XranControllerImpl.class);
+    /* CONFIG */
+    private final InternalNetworkConfigListener configListener =
+            new InternalNetworkConfigListener();
+    /* VARIABLES */
+    private final Controller controller = new Controller();
+    private XranConfig xranConfig;
+    private ApplicationId appId;
+    /* Services */
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private DeviceService deviceService;
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private HostService hostService;
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private NetworkConfigRegistry registry;
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private NetworkConfigService configService;
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private CoreService coreService;
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private XranStore xranStore;
+    private ConfigFactory<ApplicationId, XranConfig> xranConfigFactory =
+            new ConfigFactory<ApplicationId, XranConfig>(
+                    SubjectFactories.APP_SUBJECT_FACTORY, CONFIG_CLASS, "xran") {
+                @Override
+                public XranConfig createConfig() {
+                    return new XranConfig();
+                }
+            };
+    /* WRAPPERS */
+    private CellMap cellMap;
+    private UeMap ueMap;
+    private LinkMap linkMap;
+    /* MAPS */
+    private ConcurrentMap<String, ECGI> legitCells = new ConcurrentHashMap<>();
+    /* AGENTS */
+    private InternalXranDeviceAgent deviceAgent = new InternalXranDeviceAgent();
+    private InternalXranHostAgent hostAgent = new InternalXranHostAgent();
+    private InternalXranPacketAgent packetAgent = new InternalXranPacketAgent();
+    /* LISTENERS */
+    private Set<XranDeviceListener> xranDeviceListeners = new CopyOnWriteArraySet<>();
+    private Set<XranHostListener> xranHostListeners = new CopyOnWriteArraySet<>();
+    private InternalDeviceListener device_listener = new InternalDeviceListener();
+    private InternalHostListener host_listener = new InternalHostListener();
+
+    @Activate
+    public void activate() {
+        appId = coreService.registerApplication(XRAN_APP_ID);
+
+        configService.addListener(configListener);
+        registry.registerConfigFactory(xranConfigFactory);
+        deviceService.addListener(device_listener);
+        hostService.addListener(host_listener);
+
+        cellMap = new CellMap(xranStore);
+        ueMap = new UeMap(xranStore);
+        linkMap = new LinkMap(xranStore);
+
+        xranStore.setController(this);
+
+        log.info("XRAN Controller Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        controller.stop();
+
+        deviceService.removeListener(device_listener);
+        hostService.removeListener(host_listener);
+
+        legitCells.clear();
+
+        configService.removeListener(configListener);
+        registry.unregisterConfigFactory(xranConfigFactory);
+
+        log.info("XRAN Controller Stopped");
+    }
+
+    @Override
+    public void addListener(XranDeviceListener listener) {
+        xranDeviceListeners.add(listener);
+    }
+
+    @Override
+    public void addListener(XranHostListener listener) {
+        xranHostListeners.add(listener);
+    }
+
+    @Override
+    public void removeListener(XranDeviceListener listener) {
+        xranDeviceListeners.remove(listener);
+    }
+
+    @Override
+    public void removeListener(XranHostListener listener) {
+        xranHostListeners.remove(listener);
+    }
+
+    private void restartTimer(RnibUe ue) {
+        Timer timer = new Timer();
+        ue.setTimer(timer);
+        log.info("Starting UE timer...");
+        timer.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                if (ue.getUeState() == UeState.IDLE) {
+                    hostAgent.removeConnectedHost(ue);
+                    log.info("UE is removed after 10 seconds of IDLE");
+                } else {
+                    log.info("UE not removed cause its ACTIVE");
+                }
+            }
+        }, 10000);
+    }
+
+    private void restartTimer(RnibLink link) {
+        Timer timer = new Timer();
+        link.setTimer(timer);
+        log.info("Starting Link timer...");
+        timer.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                LinkId linkId = link.getLinkId();
+                xranStore.removeLink(linkId);
+                log.info("Link is removed after not receiving Meas Reports for 10 seconds");
+            }
+        }, 10000);
+
+    }
+
+    class InternalDeviceListener implements DeviceListener {
+
+        @Override
+        public void event(DeviceEvent event) {
+            log.info("Device Event {}", event);
+            switch (event.type()) {
+                case DEVICE_ADDED: {
+                    try {
+                        ECGI ecgi = decodeDeviceId(event.subject().id());
+                        RnibCell cell = cellMap.get(ecgi);
+                        if (cell != null) {
+                            Timer timer = new Timer();
+                            timer.scheduleAtFixedRate(
+                                    new TimerTask() {
+                                        @Override
+                                        public void run() {
+                                            CellConfigReport conf = cell.getConf();
+                                            if (conf == null) {
+                                                try {
+                                                    ChannelHandlerContext ctx = cellMap.getCtx(ecgi);
+                                                    SctpMessage msg = XranChannelHandler.getSctpMessage(ConfigEncoderDecoder.constructPacket(ecgi));
+                                                    ctx.writeAndFlush(msg);
+                                                } catch (IOException e) {
+                                                    log.error(ExceptionUtils.getFullStackTrace(e));
+                                                    e.printStackTrace();
+                                                }
+                                            } else {
+                                                // FIXME: maybe remove this map.
+                                                cellMap.putPciArfcn(cell);
+                                                try {
+                                                    ChannelHandlerContext ctx = cellMap.
+                                                            getCtx(ecgi);
+                                                    XrancPdu xrancPdu = L2MeasConf.constructPacket(ecgi, xranConfig.getL2MeasInterval());
+                                                    cell.setMeasConfig(xrancPdu.getBody().getL2MeasConfig());
+                                                    SctpMessage sctpMessage = XranChannelHandler.
+                                                            getSctpMessage(xrancPdu);
+                                                    ctx.writeAndFlush(sctpMessage);
+                                                } catch (IOException e) {
+                                                    log.error(ExceptionUtils.getFullStackTrace(e));
+                                                    e.printStackTrace();
+                                                }
+                                                timer.cancel();
+                                                timer.purge();
+                                            }
+                                        }
+                                    },
+                                    0,
+                                    xranConfig.getConfigRequestInterval() * 1000
+                            );
+                        }
+                    } catch (IOException e) {
+                        log.error(ExceptionUtils.getFullStackTrace(e));
+                        e.printStackTrace();
+                    }
+                    break;
+                }
+                default: {
+                    break;
+                }
+            }
+        }
+    }
+
+    class InternalHostListener implements HostListener {
+
+        @Override
+        public void event(HostEvent event) {
+            log.info("Host Event {}", event);
+            switch (event.type()) {
+                case HOST_ADDED:
+                case HOST_MOVED: {
+                    RnibUe ue = ueMap.get(hostIdtoMME(event.subject().id()));
+                    if (ue != null) {
+                        ECGI ecgi_primary = linkMap.getPrimaryCell(ue);
+                        RnibCell primary = cellMap.get(ecgi_primary);
+                        ue.setMeasConfig(null);
+                        if (primary != null) {
+                            Timer timer = new Timer();
+                            timer.scheduleAtFixedRate(
+                                    new TimerTask() {
+                                        @Override
+                                        public void run() {
+                                            if (ue.getCapability() == null) {
+                                                try {
+                                                    ChannelHandlerContext ctx = cellMap.getCtx(primary.getEcgi());
+                                                    SctpMessage msg = XranChannelHandler.
+                                                            getSctpMessage(UECapabilityEnq.constructPacket(
+                                                                    primary.getEcgi(),
+                                                                    ue.getRanId()));
+                                                    ctx.writeAndFlush(msg);
+                                                } catch (IOException e) {
+                                                    log.warn(ExceptionUtils.getFullStackTrace(e));
+                                                    e.printStackTrace();
+                                                }
+                                            } else {
+                                                if (ue.getMeasConfig() == null) {
+                                                    try {
+                                                        ChannelHandlerContext ctx = cellMap.getCtx(primary.getEcgi());
+                                                        RXSigMeasConfig.MeasCells measCells = new RXSigMeasConfig.MeasCells();
+                                                        xranStore.getCellNodes().forEach(cell -> {
+                                                            CellConfigReport cellReport = cell.getConf();
+                                                            if (cellReport != null) {
+                                                                PCIARFCN pciarfcn = new PCIARFCN();
+                                                                pciarfcn.setPci(cellReport.getPci());
+                                                                pciarfcn.setEarfcnDl(cellReport.getEarfcnDl());
+                                                                measCells.setPCIARFCN(pciarfcn);
+                                                            }
+                                                        });
+                                                        XrancPdu xrancPdu = SignalMeasConfig.constructPacket(
+                                                                primary.getEcgi(),
+                                                                ue.getRanId(),
+                                                                measCells,
+                                                                xranConfig.getRxSignalInterval()
+                                                        );
+                                                        ue.setMeasConfig(xrancPdu.getBody().getRXSigMeasConfig());
+                                                        SctpMessage msg = XranChannelHandler.getSctpMessage(xrancPdu);
+                                                        ctx.writeAndFlush(msg);
+                                                    } catch (IOException e) {
+                                                        log.warn(ExceptionUtils.getFullStackTrace(e));
+                                                        e.printStackTrace();
+                                                    }
+                                                }
+                                                timer.cancel();
+                                                timer.purge();
+                                            }
+                                        }
+                                    },
+                                    0,
+                                    xranConfig.getConfigRequestInterval() * 1000
+                            );
+                        }
+                    }
+                    break;
+                }
+                default: {
+                    break;
+                }
+            }
+        }
+    }
+
+    public class InternalXranDeviceAgent implements XranDeviceAgent {
+
+        private final Logger log = LoggerFactory.getLogger(InternalXranDeviceAgent.class);
+
+        @Override
+        public boolean addConnectedCell(String host, ChannelHandlerContext ctx) {
+            ECGI ecgi = legitCells.get(host);
+
+            if (ecgi == null) {
+                log.error("Device is not a legit source; ignoring...");
+            } else {
+                log.info("Device exists in configuration; registering...");
+                RnibCell storeCell = cellMap.get(ecgi);
+                if (storeCell == null) {
+                    storeCell = new RnibCell();
+                    storeCell.setEcgi(ecgi);
+                    cellMap.put(storeCell, ctx);
+
+                    for (XranDeviceListener l : xranDeviceListeners) {
+                        l.deviceAdded(storeCell);
+                    }
+                    return true;
+                } else {
+                    log.error("Device already registered; ignoring...");
+                }
+            }
+            ctx.close();
+            return false;
+        }
+
+        @Override
+        public boolean removeConnectedCell(String host) {
+            ECGI ecgi = legitCells.get(host);
+            List<RnibLink> linksByECGI = xranStore.getLinksByECGI(ecgi);
+
+            linksByECGI.forEach(rnibLink -> xranStore.removeLink(rnibLink.getLinkId()));
+
+            if (cellMap.remove(ecgi)) {
+                for (XranDeviceListener l : xranDeviceListeners) {
+                    l.deviceRemoved(deviceId(uri(ecgi)));
+                }
+                return true;
+            }
+            return false;
+        }
+    }
+
+    public class InternalXranHostAgent implements XranHostAgent {
+
+        @Override
+        public boolean addConnectedHost(RnibUe ue, RnibCell cell, ChannelHandlerContext ctx) {
+
+            if (ueMap.get(ue.getMmeS1apId()) != null) {
+                linkMap.putPrimaryLink(cell, ue);
+
+                Set<ECGI> ecgiSet = xranStore.getLinksByUeId(ue.getMmeS1apId().longValue())
+                        .stream()
+                        .map(l -> l.getLinkId().getSource())
+                        .collect(Collectors.toSet());
+
+                for (XranHostListener l : xranHostListeners) {
+                    l.hostAdded(ue, ecgiSet);
+                }
+                return true;
+            } else {
+                ueMap.put(ue);
+                linkMap.putPrimaryLink(cell, ue);
+
+                Set<ECGI> ecgiSet = Sets.newConcurrentHashSet();
+                ecgiSet.add(cell.getEcgi());
+                for (XranHostListener l : xranHostListeners) {
+                    l.hostAdded(ue, ecgiSet);
+                }
+                return true;
+            }
+
+        }
+
+        @Override
+        public boolean removeConnectedHost(RnibUe ue) {
+            List<RnibLink> links = xranStore.getLinksByUeId(ue.getMmeS1apId().longValue());
+            links.forEach(rnibLink -> xranStore.removeLink(rnibLink.getLinkId()));
+            if (ueMap.remove(ue.getMmeS1apId())) {
+                for (XranHostListener l : xranHostListeners) {
+                    l.hostRemoved(ue.getHostId());
+                }
+                return true;
+            }
+            return false;
+        }
+    }
+
+    public class InternalXranPacketAgent implements XranPacketProcessor {
+        @Override
+        public void handlePacket(XrancPdu recv_pdu, ChannelHandlerContext ctx) throws IOException {
+            XrancPdu send_pdu;
+
+            int apiID = recv_pdu.getHdr().getApiId().intValue();
+            log.debug("Received message: {}", recv_pdu);
+            switch (apiID) {
+                case 1: {
+                    // Decode Cell config report.
+                    CellConfigReport report = recv_pdu.getBody().getCellConfigReport();
+
+                    ECGI ecgi = report.getEcgi();
+
+                    RnibCell cell = xranStore.getCell(ecgi);
+                    cell.setConf(report);
+
+                    break;
+                }
+                case 2: {
+                    // Decode UE Admission Request.
+                    UEAdmissionRequest ueAdmissionRequest = recv_pdu.getBody().getUEAdmissionRequest();
+
+                    ECGI ecgi = ueAdmissionRequest.getEcgi();
+                    if (xranStore.getCell(ecgi) != null) {
+                        CRNTI crnti = ueAdmissionRequest.getCrnti();
+                        send_pdu = UEAdmEncoderDecoder.constructPacket(ecgi, crnti);
+                        ctx.writeAndFlush(XranChannelHandler.getSctpMessage(send_pdu));
+                    } else {
+                        log.warn("Could not find ECGI in registered cells: {}", ecgi);
+                    }
+                    break;
+                }
+                case 4: {
+                    // Decode UE Admission Status.
+                    UEAdmissionStatus ueAdmissionStatus = recv_pdu.getBody().getUEAdmissionStatus();
+
+                    RnibUe ue = ueMap.get(ueAdmissionStatus.getCrnti());
+                    if (ue != null) {
+                        if (ueAdmissionStatus.getAdmEstStatus().value.intValue() == 0) {
+                            ue.setUeState(UeState.ACTIVE);
+                        } else {
+                            ue.setUeState(UeState.IDLE);
+                        }
+                    }
+                    break;
+                }
+                case 5: {
+                    // Decode UE Admission Context Update.
+                    UEAttachComplete ueAttachComplete = recv_pdu.getBody().getUEAttachComplete();
+
+                    RnibCell cell = xranStore.getCell(ueAttachComplete.getEcgi());
+
+                    RnibUe ue = ueMap.get(ueAttachComplete.getMMEUES1APID());
+                    if (ueMap.get(ueAttachComplete.getMMEUES1APID()) == null) {
+                        ue = new RnibUe();
+                    }
+
+                    ue.setMmeS1apId(ueAttachComplete.getMMEUES1APID());
+                    ue.setEnbS1apId(ueAttachComplete.getENBUES1APID());
+                    ue.setRanId(ueAttachComplete.getCrnti());
+
+                    hostAgent.addConnectedHost(ue, cell, ctx);
+                    break;
+                }
+                case 6: {
+                    // Decode UE Reconfig_Ind.
+                    UEReconfigInd ueReconfigInd = recv_pdu.getBody().getUEReconfigInd();
+                    RnibUe ue = ueMap.get(ueReconfigInd.getCrntiOld());
+
+                    if (ue != null) {
+                        ue.setRanId(ueReconfigInd.getCrntiNew());
+                    } else {
+                        log.warn("Could not find UE with this CRNTI: {}", ueReconfigInd.getCrntiOld());
+                    }
+                    break;
+                }
+                case 7: {
+                    // If xRANc wants to deactivate UE, we pass UEReleaseInd from xRANc to eNB.
+                    // Decode UE Release_Ind.
+                    UEReleaseInd ueReleaseInd = recv_pdu.getBody().getUEReleaseInd();
+                    RnibUe ue = ueMap.get(ueReleaseInd.getCrnti());
+                    if (ue != null) {
+                        ue.setUeState(UeState.IDLE);
+                        restartTimer(ue);
+                    }
+                    break;
+                }
+                case 8: {
+                    // Decode Bearer Adm Request
+                    BearerAdmissionRequest bearerAdmissionRequest = recv_pdu.getBody().getBearerAdmissionRequest();
+
+                    ECGI ecgi = bearerAdmissionRequest.getEcgi();
+                    CRNTI crnti = bearerAdmissionRequest.getCrnti();
+                    ERABParams erabParams = bearerAdmissionRequest.getErabParams();
+                    RnibLink link = linkMap.get(ecgi, crnti);
+                    if (link != null) {
+                        link.setBearerParameters(erabParams);
+                    } else {
+                        log.warn("Could not find link between {}-{}", ecgi, crnti);
+                    }
+
+                    BerInteger numErabs = bearerAdmissionRequest.getNumErabs();
+
+                    send_pdu = BearerEncoderDecoder.constructPacket(ecgi, crnti, erabParams, numErabs);
+                    // Encode and send Bearer Admission Response - API ID 9
+                    ctx.writeAndFlush(XranChannelHandler.getSctpMessage(send_pdu));
+                    break;
+                }
+                case 10: {
+                    //Decode Bearer Admission Status
+                    BearerAdmissionStatus bearerAdmissionStatus = recv_pdu.getBody().getBearerAdmissionStatus();
+
+//                    ECGI ecgi = bearerAdmissionStatus.getEcgi();
+//                    CRNTI crnti = bearerAdmissionStatus.getCrnti();
+//
+//                    RnibLink link = linkMap.get(ecgi, crnti);
+
+                    break;
+                }
+                case 11: {
+                    //Decode Bearer Release Ind
+                    BearerReleaseInd bearerReleaseInd = recv_pdu.getBody().getBearerReleaseInd();
+
+                    ECGI ecgi = bearerReleaseInd.getEcgi();
+                    CRNTI crnti = bearerReleaseInd.getCrnti();
+                    RnibLink link = linkMap.get(ecgi, crnti);
+
+                    List<ERABID> erabidsRelease = bearerReleaseInd.getErabIds().getERABID();
+                    List<ERABParamsItem> erabParamsItem = link.getBearerParameters().getERABParamsItem();
+
+                    List<ERABParamsItem> unreleased = erabParamsItem
+                            .stream()
+                            .filter(item -> {
+                                Optional<ERABID> any = erabidsRelease.stream().filter(id -> id.equals(item.getId())).findAny();
+                                return !any.isPresent();
+                            }).collect(Collectors.toList());
+
+                    link.getBearerParameters().setERABParamsItem(new ArrayList<>(unreleased));
+
+                    break;
+                }
+                case 12: {
+                    // Don't know what will invoke sending UE CAPABILITY ENQUIRY
+                    // Encode and send UE CAPABILITY ENQUIRY
+                    UECapabilityEnquiry ueCapabilityEnquiry = recv_pdu.getBody().getUECapabilityEnquiry();
+                    XrancPdu xrancPdu = UECapabilityEnq.constructPacket(ueCapabilityEnquiry.getEcgi(), ueCapabilityEnquiry.getCrnti());
+                    ctx.writeAndFlush(XranChannelHandler.getSctpMessage(xrancPdu));
+                    break;
+                }
+                case 13: {
+                    // Decode UE Capability Info
+                    UECapabilityInfo capabilityInfo = recv_pdu.getBody().getUECapabilityInfo();
+
+                    RnibUe ue = ueMap.get(capabilityInfo.getCrnti());
+                    if (ue != null) {
+                        ue.setCapability(capabilityInfo);
+                    } else {
+                        log.warn("Could not find UE with this CRNTI: {}", capabilityInfo.getCrnti());
+                    }
+                    break;
+
+                    //14, 15, 16 are handoff
+                }
+                case 18: {
+                    // Decode RX Sig Meas Report.
+                    RXSigMeasReport rxSigMeasReport = recv_pdu.getBody().getRXSigMeasReport();
+                    List<RXSigReport> rxSigReportList = rxSigMeasReport.getCellMeasReports().getRXSigReport();
+
+                    if (!rxSigReportList.isEmpty()) {
+                        rxSigReportList.forEach(rxSigReport -> {
+                            RnibCell cell = cellMap.get(rxSigReport.getPciArfcn());
+                            if (cell != null) {
+                                ECGI ecgi = cell.getEcgi();
+                                RnibLink link = linkMap.get(ecgi, rxSigMeasReport.getCrnti());
+                                if (link == null) {
+                                    log.warn("Could not find link between: {}-{} | Creating non-serving link..", ecgi, rxSigMeasReport.getCrnti());
+                                    link = linkMap.putNonServingLink(cell, rxSigMeasReport.getCrnti());
+
+                                    if (link != null) {
+                                        restartTimer(link);
+                                    }
+                                }
+
+                                if (link != null) {
+                                    RSRQRange rsrq = rxSigReport.getRsrq();
+                                    RSRPRange rsrp = rxSigReport.getRsrp();
+
+                                    RnibLink.LinkQuality quality = link.getQuality();
+                                    quality.setRsrp(rsrp.value.intValue() - 140);
+                                    quality.setRsrq((rsrq.value.intValue() * 0.5) - 19.5);
+                                }
+                            } else {
+                                log.warn("Could not find cell with PCI-ARFCN: {}", rxSigReport.getPciArfcn());
+                            }
+                        });
+                    }
+                    break;
+                }
+                case 20: {
+                    RadioMeasReportPerUE radioMeasReportPerUE = recv_pdu.getBody().getRadioMeasReportPerUE();
+
+                    List<RadioRepPerServCell> servCells = radioMeasReportPerUE.getRadioReportServCells().getRadioRepPerServCell();
+
+                    servCells.forEach(servCell -> {
+                        RnibCell cell = cellMap.get(servCell.getPciArfcn());
+                        if (cell != null) {
+                            RnibLink link = linkMap.get(cell.getEcgi(), radioMeasReportPerUE.getCrnti());
+                            if (link != null) {
+                                RadioRepPerServCell.CqiHist cqiHist = servCell.getCqiHist();
+                                RnibLink.LinkQuality quality = link.getQuality();
+                                quality.setCqiHist(cqiHist);
+
+                                final double[] values = {0, 0, 0};
+                                int i = 1;
+                                cqiHist.getBerInteger().forEach(value -> {
+                                    values[0] = Math.max(values[0], value.intValue());
+                                    values[1] += i * value.intValue();
+                                    values[2] += value.intValue();
+                                });
+
+                                quality.setCqiMode(values[0]);
+                                quality.setCqiMean(values[1] / values[2]);
+
+                            } else {
+                                log.warn("Could not find link between: {}-{}", cell.getEcgi(), radioMeasReportPerUE.getCrnti());
+                            }
+                        } else {
+                            log.warn("Could not find cell with PCI-ARFCN: {}", servCell.getPciArfcn());
+                        }
+                    });
+
+                }
+                case 21: {
+                    RadioMeasReportPerCell radioMeasReportPerCell = recv_pdu.getBody().getRadioMeasReportPerCell();
+                    break;
+                }
+                case 22: {
+                    SchedMeasReportPerUE schedMeasReportPerUE = recv_pdu.getBody().getSchedMeasReportPerUE();
+
+                    List<SchedMeasRepPerServCell> servCells = schedMeasReportPerUE.getSchedReportServCells().getSchedMeasRepPerServCell();
+
+                    servCells.forEach(servCell -> {
+                        RnibCell cell = cellMap.get(servCell.getPciArfcn());
+                        if (cell != null) {
+                            RnibLink link = linkMap.get(cell.getEcgi(), schedMeasReportPerUE.getCrnti());
+                            if (link != null) {
+                                link.getQuality().setMcs_dl(servCell.getMcsDl());
+                                link.getQuality().setMcs_ul(servCell.getMcsUl());
+
+                                link.getResourceUsage().setDl(servCell.getPrbUsage().getPrbUsageDl());
+                                link.getResourceUsage().setUl(servCell.getPrbUsage().getPrbUsageUl());
+                            } else {
+                                log.warn("Could not find link between: {}-{}", cell.getEcgi(), schedMeasReportPerUE.getCrnti());
+                            }
+                        } else {
+                            log.warn("Could not find cell with PCI-ARFCN: {}", servCell.getPciArfcn());
+                        }
+                    });
+                    break;
+                }
+                case 23: {
+                    SchedMeasReportPerCell schedMeasReportPerCell = recv_pdu.getBody().getSchedMeasReportPerCell();
+
+                    RnibCell cell = cellMap.get(schedMeasReportPerCell.getEcgi());
+                    if (cell != null) {
+                        cell.setPrimaryPrbUsage(schedMeasReportPerCell.getPrbUsagePcell());
+                        cell.setSecondaryPrbUsage(schedMeasReportPerCell.getPrbUsageScell());
+                        cell.setQci(schedMeasReportPerCell.getQciVals());
+                    } else {
+                        log.warn("Could not find cell with ECGI: {}", schedMeasReportPerCell.getEcgi());
+                    }
+                    break;
+                }
+                case 24: {
+                    PDCPMeasReportPerUe pdcpMeasReportPerUe = recv_pdu.getBody().getPDCPMeasReportPerUe();
+
+                    RnibLink link = linkMap.get(pdcpMeasReportPerUe.getEcgi(), pdcpMeasReportPerUe.getCrnti());
+                    if (link != null) {
+                        link.getPdcpThroughput().setDl(pdcpMeasReportPerUe.getThroughputDl());
+                        link.getPdcpThroughput().setUl(pdcpMeasReportPerUe.getThroughputUl());
+                        link.getPdcpPackDelay().setDl(pdcpMeasReportPerUe.getPktDelayDl());
+                        link.getPdcpPackDelay().setUl(pdcpMeasReportPerUe.getPktDelayUl());
+                    } else {
+                        log.warn("Could not find link between: {}-{}", pdcpMeasReportPerUe.getEcgi(), pdcpMeasReportPerUe.getCrnti());
+                    }
+                    break;
+                }
+                case 34: {
+                    TrafficSplitConfig trafficSplitConfig = recv_pdu.getBody().getTrafficSplitConfig();
+
+                    List<TrafficSplitPercentage> splitPercentages = trafficSplitConfig.getTrafficSplitPercent().getTrafficSplitPercentage();
+
+                    splitPercentages.forEach(trafficSplitPercentage -> {
+                        RnibCell cell = cellMap.get(trafficSplitPercentage.getEcgi());
+                        if (cell != null) {
+                            RnibLink link = linkMap.get(cell.getEcgi(), trafficSplitConfig.getCrnti());
+                            if (link != null) {
+                                link.setTrafficPercent(trafficSplitPercentage);
+                            } else {
+                                log.warn("Could not find link between: {}-{}", cell.getEcgi(), trafficSplitConfig.getCrnti());
+                            }
+                        } else {
+                            log.warn("Could not find cell with ECGI: {}", trafficSplitConfig.getEcgi());
+                        }
+                    });
+                }
+                default: {
+                    log.warn("Wrong API ID");
+                }
+            }
+
+        }
+    }
+
+    class InternalNetworkConfigListener implements NetworkConfigListener {
+
+        @Override
+        public void event(NetworkConfigEvent event) {
+            switch (event.type()) {
+                case CONFIG_REGISTERED:
+                    break;
+                case CONFIG_UNREGISTERED:
+                    break;
+                case CONFIG_ADDED:
+                case CONFIG_UPDATED:
+                    if (event.configClass() == CONFIG_CLASS) {
+                        handleConfigEvent(event.config());
+                    }
+                    break;
+                case CONFIG_REMOVED:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        private void handleConfigEvent(Optional<Config> config) {
+            if (!config.isPresent()) {
+                return;
+            }
+
+            xranConfig = (XranConfig) config.get();
+
+            legitCells.putAll(xranConfig.activeCellSet());
+
+            controller.start(deviceAgent, hostAgent, packetAgent, xranConfig.getXrancPort());
+        }
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/controller/XranDeviceAgent.java b/src/main/java/org.onosproject.xran/controller/XranDeviceAgent.java
new file mode 100644
index 0000000..b81a628
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/controller/XranDeviceAgent.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.controller;
+
+import io.netty.channel.ChannelHandlerContext;
+
+/**
+ * Created by dimitris on 7/27/17.
+ */
+public interface XranDeviceAgent {
+
+    boolean addConnectedCell(String host, ChannelHandlerContext ctx);
+
+    boolean removeConnectedCell(String host);
+}
diff --git a/src/main/java/org.onosproject.xran/controller/XranHostAgent.java b/src/main/java/org.onosproject.xran/controller/XranHostAgent.java
new file mode 100644
index 0000000..07ab26e
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/controller/XranHostAgent.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.controller;
+
+import io.netty.channel.ChannelHandlerContext;
+import org.onosproject.xran.entities.RnibCell;
+import org.onosproject.xran.entities.RnibUe;
+
+/**
+ * Created by dimitris on 7/28/17.
+ */
+public interface XranHostAgent {
+    boolean addConnectedHost(RnibUe ue, RnibCell cell, ChannelHandlerContext ctx);
+
+    boolean removeConnectedHost(RnibUe ue);
+}
diff --git a/src/main/java/org.onosproject.xran/controller/XranPacketProcessor.java b/src/main/java/org.onosproject.xran/controller/XranPacketProcessor.java
new file mode 100644
index 0000000..c2e1bbc
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/controller/XranPacketProcessor.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.controller;
+
+import io.netty.channel.ChannelHandlerContext;
+import org.onosproject.net.DeviceId;
+import org.onosproject.xran.codecs.pdu.XrancPdu;
+
+import java.io.IOException;
+
+public interface XranPacketProcessor {
+    void handlePacket(XrancPdu pdu, ChannelHandlerContext ctx) throws IOException;
+}
diff --git a/src/main/java/org.onosproject.xran/controller/package-info.java b/src/main/java/org.onosproject.xran/controller/package-info.java
new file mode 100644
index 0000000..7f4660f
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/controller/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Created by dimitris on 7/21/17.
+ */
+package org.onosproject.xran.controller;
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/entities/RnibCell.java b/src/main/java/org.onosproject.xran/entities/RnibCell.java
new file mode 100644
index 0000000..3aa5c89
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/entities/RnibCell.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.entities;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.onosproject.net.DeviceId;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.MMEUES1APID;
+import org.onosproject.xran.codecs.api.PRBUsage;
+import org.onosproject.xran.codecs.pdu.CellConfigReport;
+import org.onosproject.xran.codecs.pdu.L2MeasConfig;
+import org.onosproject.xran.codecs.pdu.RRMConfig;
+import org.onosproject.xran.codecs.pdu.SchedMeasReportPerCell;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+
+import javax.xml.bind.DatatypeConverter;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Created by dimitris on 7/22/17.
+ */
+public class RnibCell {
+    private static final String SCHEME = "xran";
+
+    private ECGI ecgi;
+    private CellConfigReport conf;
+    private PrbUsageContainer prbUsage;
+    private SchedMeasReportPerCell.QciVals qci;
+    private RRMConfig rrmConfig;
+    private L2MeasConfig measConfig;
+
+    public RnibCell() {
+        prbUsage = new PrbUsageContainer();
+    }
+
+    public static URI uri(ECGI ecgi) {
+        if (ecgi != null) {
+            try {
+                BerByteArrayOutputStream os = new BerByteArrayOutputStream(4096);
+                ecgi.encode(os);
+                String message = DatatypeConverter.printHexBinary(os.getArray());
+                return new URI(SCHEME, message, null);
+            } catch (URISyntaxException | IOException e) {
+                return null;
+            }
+        }
+        return null;
+    }
+
+    public static ECGI decodeDeviceId(DeviceId deviceId) throws IOException {
+        String uri = deviceId.toString();
+        String hexEcgi = uri.substring(uri.lastIndexOf("xran:") + 5);
+
+        ECGI ecgi = new ECGI();
+        byte[] bytearray = DatatypeConverter.parseHexBinary(hexEcgi);
+        InputStream inputStream = new ByteArrayInputStream(bytearray);
+
+        ecgi.decode(inputStream);
+        return ecgi;
+    }
+
+    public ECGI getEcgi() {
+        return ecgi;
+    }
+
+    public void setEcgi(ECGI ecgi) {
+        this.ecgi = ecgi;
+    }
+
+    public CellConfigReport getConf() {
+        return conf;
+    }
+
+    public void setConf(CellConfigReport conf) {
+        this.conf = conf;
+    }
+
+    public RRMConfig getRrmConfig() {
+        return rrmConfig;
+    }
+
+    public void modifyRrmConfig(JsonNode rrmConfig) {
+        // TODO
+    }
+
+    public SchedMeasReportPerCell.QciVals getQci() {
+        return qci;
+    }
+
+    public void setQci(SchedMeasReportPerCell.QciVals qci) {
+        this.qci = qci;
+    }
+
+    public void setPrimaryPrbUsage(PRBUsage primary) {
+        this.prbUsage.primary = primary;
+    }
+
+    public void setSecondaryPrbUsage(PRBUsage secondary) {
+        this.prbUsage.secondary = secondary;
+    }
+
+    public L2MeasConfig getMeasConfig() {
+        return measConfig;
+    }
+
+    public void setMeasConfig(L2MeasConfig measConfig) {
+        this.measConfig = measConfig;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("{\n")
+                .append(ecgi != null ? "\"ecgi\":" + ecgi : "")
+                .append(conf != null ? ",\n\"config-report\":" + conf : "")
+                .append(prbUsage != null ? ",\n\"prb-usage\":" + prbUsage : "")
+                .append(qci != null ? ",\n\"qci-vals\":" + qci : "")
+                .append(rrmConfig != null ? ",\n\"rrm-config\":" + rrmConfig : "")
+                .append(measConfig != null ? ",\n\"l2-meas-config\":" + measConfig : "")
+                .append("\n}\n");
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        RnibCell rnibCell = (RnibCell) o;
+
+        return ecgi.equals(rnibCell.ecgi);
+    }
+
+    @Override
+    public int hashCode() {
+        return ecgi.hashCode();
+    }
+
+    class PrbUsageContainer {
+        PRBUsage primary;
+        PRBUsage secondary;
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("{\n")
+                    .append(primary != null ? "\"primary\":" + primary : "")
+                    .append(secondary != null ? ",\n\"secondary\":" + secondary : "")
+                    .append("\n}\n");
+            return sb.toString();
+        }
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/entities/RnibLink.java b/src/main/java/org.onosproject.xran/entities/RnibLink.java
new file mode 100644
index 0000000..eb61120
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/entities/RnibLink.java
@@ -0,0 +1,370 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.entities;
+
+import org.onosproject.xran.codecs.api.*;
+import org.onosproject.xran.codecs.pdu.PDCPMeasReportPerUe;
+import org.onosproject.xran.codecs.pdu.RRMConfig;
+import org.onosproject.xran.identifiers.LinkId;
+import org.openmuc.jasn1.ber.types.BerInteger;
+
+import java.util.Timer;
+
+/**
+ * Created by dimitris on 7/22/17.
+ */
+public class RnibLink {
+    private LinkId linkId;
+    //    private String type;
+    private RRMConfig rrmParameters;
+
+    private TrafficSplitPercentage trafficPercent;
+    private ERABParams bearerParameters;
+
+    private LinkQuality quality;
+    private PDCPThroughput pdcpThroughput;
+    private PDCPPacketDelay pdcpPackDelay;
+    private ResourceUsage resourceUsage;
+    private Type type;
+    private Timer timer;
+
+    public RnibLink() {
+        trafficPercent = new TrafficSplitPercentage();
+        trafficPercent.setTrafficPercentDl(new BerInteger(100));
+        trafficPercent.setTrafficPercentUl(new BerInteger(100));
+
+        pdcpThroughput = new PDCPThroughput();
+        quality = new LinkQuality();
+        pdcpPackDelay = new PDCPPacketDelay();
+        resourceUsage = new ResourceUsage();
+        timer = new Timer();
+    }
+
+    public Timer getTimer() {
+        return timer;
+    }
+
+    public void setTimer(Timer timer) {
+        this.timer.cancel();
+        this.timer.purge();
+        this.timer = timer;
+    }
+
+    public LinkId getLinkId() {
+        return linkId;
+    }
+
+    public void setLinkId(LinkId linkId) {
+        this.linkId = linkId;
+    }
+
+    public void setLinkId(RnibCell cell, RnibUe ue) {
+        this.linkId = new LinkId(cell.getEcgi(), ue.getMmeS1apId());
+        trafficPercent.setEcgi(cell.getEcgi());
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public void setType(Type type) {
+        this.type = type;
+    }
+
+    public TrafficSplitPercentage getTrafficPercent() {
+        return trafficPercent;
+    }
+
+    public void setTrafficPercent(TrafficSplitPercentage trafficPercent) {
+        this.trafficPercent = trafficPercent;
+    }
+
+    public ERABParams getBearerParameters() {
+        return bearerParameters;
+    }
+
+    public void setBearerParameters(ERABParams bearerParameters) {
+        this.bearerParameters = bearerParameters;
+    }
+
+    public LinkQuality getQuality() {
+        return quality;
+    }
+
+    public void setQuality(LinkQuality quality) {
+        this.quality = quality;
+    }
+
+    public RRMConfig getRrmParameters() {
+        return rrmParameters;
+    }
+
+    public void setRrmParameters(RRMConfig rrmParameters) {
+        this.rrmParameters = rrmParameters;
+    }
+
+    public PDCPThroughput getPdcpThroughput() {
+        return pdcpThroughput;
+    }
+
+    public void setPdcpThroughput(PDCPThroughput pdcpThroughput) {
+        this.pdcpThroughput = pdcpThroughput;
+    }
+
+    public PDCPPacketDelay getPdcpPackDelay() {
+        return pdcpPackDelay;
+    }
+
+    public void setPdcpPackDelay(PDCPPacketDelay pdcpPackDelay) {
+        this.pdcpPackDelay = pdcpPackDelay;
+    }
+
+    public ResourceUsage getResourceUsage() {
+        return resourceUsage;
+    }
+
+    public void setResourceUsage(ResourceUsage resourceUsage) {
+        this.resourceUsage = resourceUsage;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("{\n")
+                .append(linkId != null ? "\"link-id\":" + linkId : "")
+                .append(type != null ? ",\n\"type\":" + type : "")
+                .append(rrmParameters != null ? ",\n\"rrm-params\":" + rrmParameters : "")
+                .append(trafficPercent != null ? ",\n\"traffic-percent\":" + trafficPercent : "")
+                .append(bearerParameters != null ? ",\n\"bearer-params\":" + bearerParameters : "")
+                .append(quality != null ? ",\n\"quality\":" + quality : "")
+                .append(pdcpThroughput != null ? ",\n\"pdcp-throughput\":" + pdcpThroughput : "")
+                .append(pdcpPackDelay != null ? ",\n\"pdcp-packet-delay\":" + pdcpPackDelay : "")
+                .append(resourceUsage != null ? ",\n\"resource-usage\":" + resourceUsage : "")
+                .append("\n}\n");
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        RnibLink link = (RnibLink) o;
+
+        return linkId.equals(link.linkId);
+    }
+
+    @Override
+    public int hashCode() {
+        return linkId.hashCode();
+    }
+
+    public enum Type {
+        SERVING_PRIMARY {
+            @Override
+            public String toString() {
+                return "\"serving/primary\"";
+            }
+        },
+        // TODO: Add CA/DC
+        SERVING_SECONDARY {
+            @Override
+            public String toString() {
+                return "\"serving/secondary\"";
+            }
+        },
+        NON_SERVING {
+            @Override
+            public String toString() {
+                return "\"non-serving\"";
+            }
+        }
+    }
+
+    public class PDCPThroughput {
+        private PDCPMeasReportPerUe.ThroughputDl dl;
+        private PDCPMeasReportPerUe.ThroughputUl ul;
+
+        public PDCPMeasReportPerUe.ThroughputDl getDl() {
+            return dl;
+        }
+
+        public void setDl(PDCPMeasReportPerUe.ThroughputDl dl) {
+            this.dl = dl;
+        }
+
+        public PDCPMeasReportPerUe.ThroughputUl getUl() {
+            return ul;
+        }
+
+        public void setUl(PDCPMeasReportPerUe.ThroughputUl ul) {
+            this.ul = ul;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("{\n")
+                    .append(dl != null ? "\"dl\":" + dl : "")
+                    .append(ul != null ? ",\n\"ul\":" + ul : "")
+                    .append("\n}\n");
+            return sb.toString();
+        }
+    }
+
+    public class PDCPPacketDelay {
+        PDCPMeasReportPerUe.PktDelayDl dl;
+        PDCPMeasReportPerUe.PktDelayUl ul;
+
+        public PDCPMeasReportPerUe.PktDelayDl getDl() {
+            return dl;
+        }
+
+        public void setDl(PDCPMeasReportPerUe.PktDelayDl dl) {
+            this.dl = dl;
+        }
+
+        public PDCPMeasReportPerUe.PktDelayUl getUl() {
+            return ul;
+        }
+
+        public void setUl(PDCPMeasReportPerUe.PktDelayUl ul) {
+            this.ul = ul;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("{\n")
+                    .append(dl != null ? "\"dl\":" + dl : "")
+                    .append(ul != null ? ",\n\"ul\":" + ul : "")
+                    .append("\n}\n");
+            return sb.toString();
+        }
+    }
+
+    public class ResourceUsage {
+        PRBUsage.PrbUsageDl dl;
+        PRBUsage.PrbUsageUl ul;
+
+        public PRBUsage.PrbUsageDl getDl() {
+            return dl;
+        }
+
+        public void setDl(PRBUsage.PrbUsageDl dl) {
+            this.dl = dl;
+        }
+
+        public PRBUsage.PrbUsageUl getUl() {
+            return ul;
+        }
+
+        public void setUl(PRBUsage.PrbUsageUl ul) {
+            this.ul = ul;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("{\n")
+                    .append(dl != null ? "\"dl\":" + dl : "")
+                    .append(ul != null ? ",\n\"ul\":" + ul : "")
+                    .append("\n}\n");
+            return sb.toString();
+        }
+    }
+
+    public class LinkQuality {
+        double rsrp;
+        double rsrq;
+        RadioRepPerServCell.CqiHist cqiHist;
+        double cqiMode;
+        double cqiMean;
+        SchedMeasRepPerServCell.McsDl mcs_dl;
+        SchedMeasRepPerServCell.McsUl mcs_ul;
+
+        public double getRsrp() {
+            return rsrp;
+        }
+
+        public void setRsrp(double rsrp) {
+            this.rsrp = rsrp;
+        }
+
+        public double getRsrq() {
+            return rsrq;
+        }
+
+        public void setRsrq(double rsrq) {
+            this.rsrq = rsrq;
+        }
+
+        public RadioRepPerServCell.CqiHist getCqiHist() {
+            return cqiHist;
+        }
+
+        public void setCqiHist(RadioRepPerServCell.CqiHist cqiHist) {
+            this.cqiHist = cqiHist;
+        }
+
+        public double getCqiMode() {
+            return cqiMode;
+        }
+
+        public void setCqiMode(double cqiMode) {
+            this.cqiMode = cqiMode;
+        }
+
+        public double getCqiMean() {
+            return cqiMean;
+        }
+
+        public void setCqiMean(double cqiMean) {
+            this.cqiMean = cqiMean;
+        }
+
+        public SchedMeasRepPerServCell.McsDl getMcs_dl() {
+            return mcs_dl;
+        }
+
+        public void setMcs_dl(SchedMeasRepPerServCell.McsDl mcs_dl) {
+            this.mcs_dl = mcs_dl;
+        }
+
+        public SchedMeasRepPerServCell.McsUl getMcs_ul() {
+            return mcs_ul;
+        }
+
+        public void setMcs_ul(SchedMeasRepPerServCell.McsUl mcs_ul) {
+            this.mcs_ul = mcs_ul;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("{\n")
+                    .append("\"rsrp\":" + rsrp)
+                    .append(",\n\"rsrq\":" + rsrq)
+                    .append(",\n\"cqiMode\":" + cqiMode)
+                    .append(",\n\"cqiMean\":" + cqiMean)
+                    .append(mcs_dl != null ? ",\n\"mcs-dl\":" + mcs_dl : "")
+                    .append(mcs_ul != null ? ",\n\"mcs-ul\":" + mcs_ul : "")
+                    .append("\n}\n");
+            return sb.toString();
+        }
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/entities/RnibSlice.java b/src/main/java/org.onosproject.xran/entities/RnibSlice.java
new file mode 100644
index 0000000..349e8ee
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/entities/RnibSlice.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.entities;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Created by dimitris on 7/22/17.
+ */
+public class RnibSlice {
+    private long sliceId;
+    private Set<RnibLink> links;
+    private Map<String, String> ran2epc;
+    private long validityPeriod;
+    private Object desiredKpis;
+    private Object deliveredKpis;
+    private Object rrmSonConfiguration;
+
+}
diff --git a/src/main/java/org.onosproject.xran/entities/RnibUe.java b/src/main/java/org.onosproject.xran/entities/RnibUe.java
new file mode 100644
index 0000000..2be3e01
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/entities/RnibUe.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.entities;
+
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.HostId;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ENBUES1APID;
+import org.onosproject.xran.codecs.api.MMEUES1APID;
+import org.onosproject.xran.codecs.pdu.RXSigMeasConfig;
+import org.onosproject.xran.codecs.pdu.UECapabilityInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Timer;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.onosproject.net.HostId.hostId;
+
+/**
+ * Created by dimitris on 7/22/17.
+ */
+public class RnibUe {
+
+    private static final String SCHEME = "xran";
+
+    private static final Logger log =
+            LoggerFactory.getLogger(RnibUe.class);
+
+    private String imsi;
+    private ENBUES1APID enbS1apId;
+    private MMEUES1APID mmeS1apId;
+    private CRNTI ranId;
+    private UeState ueState;
+    private UECapabilityInfo capability;
+    private RXSigMeasConfig measConfig;
+    private Timer timer;
+
+    public RnibUe() {
+        ueState = UeState.ACTIVE;
+        timer = new Timer();
+    }
+
+    public static URI uri(RnibUe ue) {
+        MMEUES1APID mmeS1apId = ue.getMmeS1apId();
+        if (mmeS1apId != null) {
+            try {
+                return new URI(SCHEME, mmeS1apId.toString(), null);
+            } catch (URISyntaxException e) {
+                return null;
+            }
+        }
+        return null;
+    }
+
+    public static MMEUES1APID hostIdtoMME(HostId hostId) {
+        String mac = hostId.mac().toString();
+        mac = mac.replace(":", "");
+        long l = Long.parseLong(mac, 16);
+        return new MMEUES1APID(l);
+    }
+
+    public Timer getTimer() {
+        return timer;
+    }
+
+    public void setTimer(Timer timer) {
+        this.timer.cancel();
+        this.timer.purge();
+        this.timer = timer;
+    }
+
+    public MMEUES1APID getMmeS1apId() {
+        return mmeS1apId;
+    }
+
+    public void setMmeS1apId(MMEUES1APID mmeS1apId) {
+        this.mmeS1apId = mmeS1apId;
+    }
+
+    public ENBUES1APID getEnbS1apId() {
+        return enbS1apId;
+    }
+
+    public void setEnbS1apId(ENBUES1APID enbS1apId) {
+        this.enbS1apId = enbS1apId;
+    }
+
+    public CRNTI getRanId() {
+        return ranId;
+    }
+
+    public void setRanId(CRNTI ranId) {
+        this.ranId = ranId;
+    }
+
+    public String getImsi() {
+        return imsi;
+    }
+
+    public void setImsi(String imsi) {
+        this.imsi = imsi;
+    }
+
+    public HostId getHostId() {
+        try {
+            String text = this.mmeS1apId.value.toString(16),
+                    res = "";
+            int charsLeft = 12 - text.length();
+            if (charsLeft > 0) {
+                res += Stream.generate(() -> "0").limit(charsLeft).collect(Collectors.joining(""));
+            } else if (charsLeft < 0) {
+                return null;
+            }
+            res += text;
+
+            String insert = ":";
+            int period = 2;
+
+            StringBuilder builder = new StringBuilder(
+                    res.length() + insert.length() * (res.length() / period) + 1);
+
+            int index = 0;
+            String prefix = "";
+            while (index < res.length()) {
+                // Don't putPrimaryLink the insert in the very first iteration.
+                // This is easier than appending it *after* each substring
+                builder.append(prefix);
+                prefix = insert;
+                builder.append(res.substring(index,
+                        Math.min(index + period, res.length())));
+                index += period;
+            }
+
+            return hostId(MacAddress.valueOf(builder.toString()));
+        } catch (Exception e) {
+            log.warn(e.getMessage());
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+    public RXSigMeasConfig getMeasConfig() {
+        return measConfig;
+    }
+
+    public void setMeasConfig(RXSigMeasConfig measConfig) {
+        this.measConfig = measConfig;
+    }
+
+    public UECapabilityInfo getCapability() {
+        return capability;
+    }
+
+    public void setCapability(UECapabilityInfo capability) {
+        this.capability = capability;
+    }
+
+    public UeState getUeState() {
+        return ueState;
+    }
+
+    public void setUeState(UeState ueState) {
+        this.ueState = ueState;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("{\n")
+                .append(mmeS1apId != null ? "\n\"mme-s1-ap-id\":" + mmeS1apId : "")
+                .append(enbS1apId != null ? ",\n\"enb-s1-ap-id\":" + enbS1apId : "")
+                .append(imsi != null ? ",\"imsi\":" + imsi : "")
+                .append(ranId != null ? ",\n\"ran-id\":" + ranId : "")
+                .append(ueState != null ? ",\n\"state\":" + ueState : "")
+                .append(capability != null ? ",\n\"capability\":" + capability : "")
+                .append(measConfig != null ? ",\n\"meas-config\":" + measConfig : "")
+                .append("\n}\n");
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        RnibUe rnibUe = (RnibUe) o;
+
+        return mmeS1apId.equals(rnibUe.mmeS1apId) && ranId.equals(rnibUe.ranId);
+    }
+
+    @Override
+    public int hashCode() {
+        int result = mmeS1apId.hashCode();
+        result = 31 * result + ranId.hashCode();
+        return result;
+    }
+
+    public enum UeState {
+        ACTIVE {
+            @Override
+            public String toString() {
+                return "\"ACTIVE\"";
+            }
+        },
+        IDLE {
+            @Override
+            public String toString() {
+                return "\"IDLE\"";
+            }
+        }
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/entities/package-info.java b/src/main/java/org.onosproject.xran/entities/package-info.java
new file mode 100644
index 0000000..6b2c4c4
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/entities/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Created by dimitris on 7/22/17.
+ */
+package org.onosproject.xran.entities;
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/identifiers/LinkId.java b/src/main/java/org.onosproject.xran/identifiers/LinkId.java
new file mode 100644
index 0000000..8531d78
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/identifiers/LinkId.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.identifiers;
+
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.MMEUES1APID;
+import org.onosproject.xran.entities.RnibCell;
+import org.onosproject.xran.entities.RnibUe;
+
+public class LinkId {
+    private ECGI source;
+    private MMEUES1APID destination;
+
+    public LinkId(ECGI source, MMEUES1APID destination) {
+        this.source = source;
+        this.destination = destination;
+    }
+
+    public static LinkId valueOf(RnibCell cell, RnibUe ue) {
+        return new LinkId(cell.getEcgi(), ue.getMmeS1apId());
+    }
+
+    public ECGI getSource() {
+        return source;
+    }
+
+    public void setSource(ECGI source) {
+        this.source = source;
+    }
+
+    public MMEUES1APID getDestination() {
+        return destination;
+    }
+
+    public void setDestination(MMEUES1APID destination) {
+        this.destination = destination;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        return this == o ||
+                o != null &&
+                        o instanceof LinkId &&
+                        destination.equals(((LinkId) o).destination) &&
+                        source.equals(((LinkId) o).source);
+
+    }
+
+    @Override
+    public int hashCode() {
+        int result = source.hashCode();
+        result = 31 * result + destination.hashCode();
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("{\n")
+                .append(source != null ? "\"cell\":" + source : "")
+                .append(destination != null ? ",\n\"ue\":" + destination : "")
+                .append("\n}\n");
+        return sb.toString();
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/identifiers/package-info.java b/src/main/java/org.onosproject.xran/identifiers/package-info.java
new file mode 100644
index 0000000..421cee2
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/identifiers/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Created by dimitris on 7/22/17.
+ */
+package org.onosproject.xran.identifiers;
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/impl/DefaultXranStore.java b/src/main/java/org.onosproject.xran/impl/DefaultXranStore.java
new file mode 100644
index 0000000..7894b74
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/impl/DefaultXranStore.java
@@ -0,0 +1,295 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.impl;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Lists;
+import org.apache.felix.scr.annotations.*;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.store.AbstractStore;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.EUTRANCellIdentifier;
+import org.onosproject.xran.codecs.api.MMEUES1APID;
+import org.onosproject.xran.controller.XranController;
+import org.onosproject.xran.entities.RnibCell;
+import org.onosproject.xran.entities.RnibLink;
+import org.onosproject.xran.entities.RnibSlice;
+import org.onosproject.xran.entities.RnibUe;
+import org.onosproject.xran.identifiers.LinkId;
+import org.slf4j.Logger;
+
+import javax.xml.bind.DatatypeConverter;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.stream.Collectors;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Created by dimitris on 7/22/17.
+ */
+@Component(immediate = true)
+@Service
+public class DefaultXranStore extends AbstractStore implements XranStore {
+    private static final String XRAN_APP_ID = "org.onosproject.xran";
+
+    private final Logger log = getLogger(getClass());
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
+    private ConcurrentMap<LinkId, RnibLink> linkMap = new ConcurrentHashMap<>();
+    private ConcurrentMap<ECGI, RnibCell> cellMap = new ConcurrentHashMap<>();
+    private ConcurrentMap<MMEUES1APID, RnibUe> ueMap = new ConcurrentHashMap<>();
+    private ConcurrentMap<Object, RnibSlice> sliceMap = new ConcurrentHashMap<>();
+    private XranController controller;
+
+    @Activate
+    public void activate() {
+        ApplicationId appId = coreService.getAppId(XRAN_APP_ID);
+        log.info("XRAN Default Store Started");
+    }
+
+    @Deactivate
+    public void deactive() {
+        log.info("XRAN Default Store Stopped");
+    }
+
+    @Override
+    public List<RnibLink> getLinks() {
+        List<RnibLink> list = Lists.newArrayList();
+        list.addAll(linkMap.values());
+        return list;
+    }
+
+    @Override
+    public List<RnibLink> getLinksByECGI(ECGI ecgi) {
+        List<RnibLink> list = Lists.newArrayList();
+        list.addAll(
+                linkMap.keySet()
+                        .stream()
+                        .filter(k -> k.getSource().equals(ecgi))
+                        .map(v -> linkMap.get(v))
+                        .collect(Collectors.toList()));
+
+        return list;
+    }
+
+    @Override
+    public List<RnibLink> getLinksByCellId(String eciHex) {
+        List<RnibLink> list = Lists.newArrayList();
+        EUTRANCellIdentifier eci = hexToECI(eciHex);
+
+        list.addAll(
+                linkMap.keySet()
+                        .stream()
+                        .filter(k -> k.getSource().getEUTRANcellIdentifier().equals(eci))
+                        .map(v -> linkMap.get(v))
+                        .collect(Collectors.toList()));
+
+        return list;
+    }
+
+    @Override
+    public List<RnibLink> getLinksByUeId(long euId) {
+        List<RnibLink> list = Lists.newArrayList();
+        MMEUES1APID mme = new MMEUES1APID(euId);
+
+        list.addAll(
+                linkMap.keySet()
+                        .stream()
+                        .filter(k -> k.getDestination().equals(mme))
+                        .map(v -> linkMap.get(v))
+                        .collect(Collectors.toList()));
+
+        return list;
+    }
+
+    @Override
+    public RnibLink getLinkBetweenCellIdUeId(String eciHex, long euId) {
+        EUTRANCellIdentifier eci = hexToECI(eciHex);
+        MMEUES1APID mme = new MMEUES1APID(euId);
+
+        Optional<LinkId> first = linkMap.keySet()
+                .stream()
+                .filter(linkId -> linkId.getSource().getEUTRANcellIdentifier().equals(eci))
+                .filter(linkId -> linkId.getDestination().equals(mme))
+                .findFirst();
+
+        return first.map(linkId -> linkMap.get(linkId)).orElse(null);
+    }
+
+    @Override
+    public boolean createLinkBetweenCellIdUeId(String eciHex, long euId, String type) {
+        RnibCell cell = getCell(eciHex);
+        RnibUe ue = getUe(euId);
+
+        if (cell != null && ue != null) {
+            RnibLink link = new RnibLink();
+            link.setLinkId(cell, ue);
+
+            // TODO: string to enum mapping
+//            link.setType(type);
+
+            linkMap.put(link.getLinkId(), link);
+            return true;
+        }
+
+        return false;
+    }
+
+    @Override
+    public void storeLink(RnibLink link) {
+        if (link.getLinkId() != null) {
+            linkMap.put(link.getLinkId(), link);
+        }
+    }
+
+    @Override
+    public boolean removeLink(LinkId link) {
+        return linkMap.remove(link) != null;
+    }
+
+    @Override
+    public RnibLink getLink(ECGI ecgi, MMEUES1APID mme) {
+        LinkId linkId = new LinkId(ecgi, mme);
+        return linkMap.get(linkId);
+    }
+
+    @Override
+    public List<Object> getNodes() {
+        List<Object> list = Lists.newArrayList();
+        list.add(cellMap.values());
+        list.add(ueMap.values());
+        return list;
+    }
+
+    @Override
+    public List<RnibCell> getCellNodes() {
+        List<RnibCell> list = Lists.newArrayList();
+        list.addAll(cellMap.values());
+        return list;
+    }
+
+    @Override
+    public List<RnibUe> getUeNodes() {
+        List<RnibUe> list = Lists.newArrayList();
+        list.addAll(ueMap.values());
+        return list;
+    }
+
+    @Override
+    public Object getByNodeId(String nodeId) {
+        try {
+            return getCell(nodeId);
+        } catch (Exception e) {
+
+        }
+        return getUe(Long.parseLong(nodeId));
+    }
+
+    @Override
+    public void storeCell(RnibCell cell) {
+        if (cell.getEcgi() != null) {
+            cellMap.putIfAbsent(cell.getEcgi(), cell);
+        }
+    }
+
+    @Override
+    public boolean removeCell(ECGI ecgi) {
+        return cellMap.remove(ecgi) != null;
+    }
+
+    @Override
+    public RnibCell getCell(String hexeci) {
+        EUTRANCellIdentifier eci = hexToECI(hexeci);
+        Optional<ECGI> first = cellMap.keySet().stream().filter(ecgi -> ecgi.getEUTRANcellIdentifier().equals(eci)).findFirst();
+        return first.map(ecgi -> cellMap.get(ecgi)).orElse(null);
+    }
+
+    @Override
+    public RnibCell getCell(ECGI ecgi) {
+        return cellMap.get(ecgi);
+    }
+
+    @Override
+    public boolean modifyCellRrmConf(String hexeci, JsonNode rrmConf) {
+        EUTRANCellIdentifier eci = hexToECI(hexeci);
+        Optional<ECGI> first = cellMap.keySet().stream().filter(ecgi -> ecgi.getEUTRANcellIdentifier().equals(eci)).findFirst();
+        first.ifPresent(ecgi -> cellMap.get(ecgi).modifyRrmConfig(rrmConf));
+        return false;
+    }
+
+    @Override
+    public RnibSlice getSlice(long sliceId) {
+        if (sliceMap.containsKey(sliceId)) {
+            return sliceMap.get(sliceId);
+        }
+        return null;
+    }
+
+    @Override
+    public boolean createSlice(ObjectNode attributes) {
+        return false;
+    }
+
+    @Override
+    public boolean removeCell(long sliceId) {
+        return sliceMap.remove(sliceId) != null;
+    }
+
+    @Override
+    public XranController getController() {
+        return controller;
+    }
+
+    @Override
+    public void setController(XranController controller) {
+        this.controller = controller;
+    }
+
+    @Override
+    public void storeUe(RnibUe ue) {
+        if (ue.getMmeS1apId() != null) {
+            ueMap.putIfAbsent(ue.getMmeS1apId(), ue);
+        }
+    }
+
+    @Override
+    public boolean removeUe(MMEUES1APID mme) {
+        return ueMap.remove(mme) != null;
+    }
+
+    @Override
+    public RnibUe getUe(long euId) {
+        MMEUES1APID mme = new MMEUES1APID(euId);
+        return ueMap.get(mme);
+    }
+
+    @Override
+    public RnibUe getUe(MMEUES1APID mme) {
+        return ueMap.get(mme);
+    }
+
+    private EUTRANCellIdentifier hexToECI(String eciHex) {
+        byte[] hexBinary = DatatypeConverter.parseHexBinary(eciHex);
+        return new EUTRANCellIdentifier(hexBinary, 28);
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/impl/DistributedXranStore.java b/src/main/java/org.onosproject.xran/impl/DistributedXranStore.java
new file mode 100644
index 0000000..0e9f3d5
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/impl/DistributedXranStore.java
@@ -0,0 +1,311 @@
+///*
+// * Copyright 2015-present Open Networking Laboratory
+// *
+// * Licensed under the Apache License, Version 2.0 (the "License");
+// * you may not use this file except in compliance with the License.
+// * You may obtain a copy of the License at
+// *
+// *     http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+//
+//package org.onosproject.xran.impl;
+//
+//import com.fasterxml.jackson.databind.JsonNode;
+//import com.fasterxml.jackson.databind.node.ObjectNode;
+//import com.google.common.collect.Lists;
+//import org.apache.commons.lang3.tuple.ImmutablePair;
+//import org.apache.felix.scr.annotations.Activate;
+//import org.apache.felix.scr.annotations.Deactivate;
+//import org.apache.felix.scr.annotations.Reference;
+//import org.apache.felix.scr.annotations.ReferenceCardinality;
+//import org.onlab.util.KryoNamespace;
+//import org.onosproject.core.ApplicationId;
+//import org.onosproject.core.CoreService;
+//import org.onosproject.core.IdGenerator;
+//import org.onosproject.store.AbstractStore;
+//import org.onosproject.store.serializers.KryoNamespaces;
+//import org.onosproject.store.service.ConsistentMap;
+//import org.onosproject.store.service.Serializer;
+//import org.onosproject.store.service.StorageService;
+//import org.onosproject.store.service.Versioned;
+//import org.onosproject.xran.XranStore;
+//import org.onosproject.xran.codecs.api.ECGI;
+//import org.onosproject.xran.codecs.api.ENBUES1APID;
+//import org.onosproject.xran.codecs.api.MMEUES1APID;
+//import org.onosproject.xran.codecs.pdu.CellConfigReport;
+//import org.onosproject.xran.controller.XranController;
+//import org.onosproject.xran.entities.RnibCell;
+//import org.onosproject.xran.entities.RnibLink;
+//import org.onosproject.xran.entities.RnibSlice;
+//import org.onosproject.xran.entities.RnibUe;
+//import org.onosproject.xran.identifiers.CellId;
+//import org.onosproject.xran.identifiers.LinkId;
+//import org.onosproject.xran.identifiers.SliceId;
+//import org.onosproject.xran.identifiers.UeId;
+//import org.slf4j.Logger;
+//
+//import java.util.List;
+//
+//import static org.slf4j.LoggerFactory.getLogger;
+//
+///**
+// * Created by dimitris on 7/22/17.
+// */
+////@Component(immediate = true)
+////@Service
+//public class DistributedXranStore extends AbstractStore implements XranStore {
+//    private static final String XRAN_APP_ID = "org.onosproject.xran";
+//
+//    private final Logger log = getLogger(getClass());
+//
+//    private ConsistentMap<LinkId, RnibLink> linkMap;
+//    private ConsistentMap<CellId, RnibCell> cellMap;
+//    private ConsistentMap<UeId, RnibUe> ueMap;
+//    private ConsistentMap<SliceId, RnibSlice> sliceMap;
+//
+//    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+//    protected StorageService storageService;
+//
+//    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+//    protected CoreService coreService;
+//
+//    private IdGenerator cellIdGenerator;
+//    private IdGenerator ueIdGenerator;
+//    private IdGenerator linkIdGenerator;
+//    private IdGenerator sliceIdGenerator;
+//
+//    private XranController controller;
+//
+//    private final String XRAN_CELL_ID = "xran-cell-ids";
+//    private final String XRAN_UE_ID = "xran-eu-ids";
+//    private final String XRAN_LINK_ID = "xran-link-ids";
+//    private final String XRAN_SLICE_ID = "xran-slice-ids";
+//
+//    @Activate
+//    public void activate() {
+//        ApplicationId appId = coreService.getAppId(XRAN_APP_ID);
+//
+//        cellIdGenerator = coreService.getIdGenerator(XRAN_CELL_ID);
+//        ueIdGenerator = coreService.getIdGenerator(XRAN_UE_ID);
+//        linkIdGenerator = coreService.getIdGenerator(XRAN_LINK_ID);
+//        sliceIdGenerator = coreService.getIdGenerator(XRAN_SLICE_ID);
+//
+//        KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
+//                .register(KryoNamespaces.API)
+//                .register(RnibCell.class)
+//                .register(RnibSlice.class)
+//                .register(RnibUe.class)
+//                .register(RnibLink.class)
+//                .register(LinkId.class)
+//                .register(CellId.class)
+//                .register(UeId.class)
+//                .register(SliceId.class)
+//                .register(ImmutablePair.class)
+//                .register(ENBUES1APID.class)
+//                .register(MMEUES1APID.class)
+//                .register(CellConfigReport.class)
+//                .register(ECGI.class);
+//
+//        linkMap = storageService.<LinkId, RnibLink>consistentMapBuilder()
+//                .withSerializer(Serializer.using(serializer.build()))
+//                .withName("xran-link-map")
+//                .withApplicationId(appId)
+//                .withPurgeOnUninstall()
+//                .build();
+//
+//        cellMap = storageService.<CellId, RnibCell>consistentMapBuilder()
+//                .withSerializer(Serializer.using(serializer.build()))
+//                .withName("xran-cell-map")
+//                .withApplicationId(appId)
+//                .withPurgeOnUninstall()
+//                .build();
+//
+//        ueMap = storageService.<UeId, RnibUe>consistentMapBuilder()
+//                .withSerializer(Serializer.using(serializer.build()))
+//                .withName("xran-ue-map")
+//                .withApplicationId(appId)
+//                .withPurgeOnUninstall()
+//                .build();
+//
+//        sliceMap = storageService.<SliceId, RnibSlice>consistentMapBuilder()
+//                .withSerializer(Serializer.using(serializer.build()))
+//                .withName("xran-slice-map")
+//                .withApplicationId(appId)
+//                .withPurgeOnUninstall()
+//                .build();
+//
+//        log.info("XRAN Distributed Store Started");
+//    }
+//
+//    @Deactivate
+//    public void deactive() {
+//        log.info("XRAN Distributed Store Stopped");
+//    }
+//
+//    @Override
+//    public List<RnibLink> getLinksByCellId(long cellId) {
+//        List<RnibLink> list = Lists.newArrayList();
+//        CellId cell = CellId.valueOf(cellId);
+//        linkMap.keySet().forEach(
+//                pair -> {
+//                    if (pair.equals(cell)) {
+//                        list.add(linkMap.get(pair).value());
+//                    }
+//                }
+//        );
+//        return list;
+//    }
+//
+//    @Override
+//    public List<RnibLink> getLinksByUeId(long euId) {
+//        List<RnibLink> list = Lists.newArrayList();
+//        UeId ue = UeId.valueOf(euId);
+//        linkMap.keySet().forEach(
+//                pair -> {
+//                    if (pair.equals(ue)) {
+//                        list.add(linkMap.get(pair).value());
+//                    }
+//                }
+//        );
+//        return list;
+//    }
+//
+//    @Override
+//    public RnibLink getLinkBetweenCellIdUeId(long cellId, long euId) {
+//        LinkId linkId = LinkId.valueOf(cellId, euId);
+//        final Versioned<RnibLink> rnibLinkVersioned = linkMap.get(linkId);
+//        if (rnibLinkVersioned != null) {
+//            return rnibLinkVersioned.value();
+//        }
+//        return null;
+//    }
+//
+//    @Override
+//    public boolean modifyTypeOfLink(long cellId, long euId, String type) {
+//        final RnibLink link = getLinkBetweenCellIdUeId(cellId, euId);
+//        if (link != null) {
+//            link.setType(type);
+//            return true;
+//        }
+//        return false;
+//    }
+//
+//    @Override
+//    public boolean modifyTrafficPercentOfLink(long cellId, long euId, long trafficPercent) {
+//        final RnibLink link = getLinkBetweenCellIdUeId(cellId, euId);
+//        if (link != null) {
+//            link.setTrafficPercent(trafficPercent);
+//            return true;
+//        }
+//        return false;
+//    }
+//
+//    @Override
+//    public boolean createLinkBetweenCellIdUeId(long cellId, long euId, String type) {
+//        LinkId linkId = LinkId.valueOf(cellId, euId);
+//        if (linkMap.containsKey(linkId)) {
+//            return false;
+//        }
+//        RnibLink link = new RnibLink(linkId);
+//        link.setType(type);
+//        linkMap.putPrimaryLink(linkId, link);
+//        return true;
+//    }
+//
+//    @Override
+//    public boolean deleteLink(long linkId) {
+//        return false;
+//    }
+//
+//    @Override
+//    public List<Object> getNodes() {
+//        List<Object> list = Lists.newArrayList();
+//        cellMap.values().forEach(v -> list.add(v.value()));
+//        ueMap.values().forEach(v -> list.add(v.value()));
+//        return list;
+//    }
+//
+//    @Override
+//    public List<RnibCell> getCellNodes() {
+//        List<RnibCell> list = Lists.newArrayList();
+//        cellMap.values().forEach(v -> list.add(v.value()));
+//        return list;
+//    }
+//
+//    @Override
+//    public List<RnibUe> getUeNodes() {
+//        List<RnibUe> list = Lists.newArrayList();
+//        ueMap.values().forEach(v -> list.add(v.value()));
+//        return list;
+//    }
+//
+//    @Override
+//    public Object getByNodeId(long nodeId) {
+//        CellId cellId = CellId.valueOf(nodeId);
+//        if (cellMap.containsKey(cellId)) {
+//            return cellMap.get(cellId).value();
+//        }
+//        UeId ueId = UeId.valueOf(nodeId);
+//        if (ueMap.containsKey(ueId)) {
+//            return ueMap.get(ueId).value();
+//        }
+//        return null;
+//    }
+//
+//    @Override
+//    public void storeCell(RnibCell cell) {
+//        final CellId cellId = CellId.valueOf(cellIdGenerator.getNewId());
+//        cell.setCellId(cellId);
+//        cellMap.putIfAbsent(cellId, cell);
+//    }
+//
+//    @Override
+//    public RnibCell getCell(long cellId) {
+//        CellId cell = CellId.valueOf(cellId);
+//        if (cellMap.containsKey(cell)) {
+////            controller.sendMsg(cellMap.get(cell).value().getDevId(), "skata");
+//            return cellMap.get(cell).value();
+//        }
+//        return null;
+//    }
+//
+//    @Override
+//    public boolean modifyCellRrmConf(JsonNode rrmConf) {
+//        return false;
+//    }
+//
+//    @Override
+//    public RnibSlice getSlice(long sliceId) {
+//        SliceId slice = SliceId.valueOf(sliceId);
+//        if (sliceMap.containsKey(slice)) {
+//            return sliceMap.get(slice).value();
+//        }
+//        return null;
+//    }
+//
+//    @Override
+//    public boolean createSlice(ObjectNode attributes) {
+//        return false;
+//    }
+//
+//    public XranController getController() {
+//        return controller;
+//    }
+//
+//    @Override
+//    public void storeUe(RnibUe ue) {
+//        final UeId ueId = UeId.valueOf(ueIdGenerator.getNewId());
+//        ue.setUeId(ueId);
+//        ueMap.putIfAbsent(ueId, ue);
+//    }
+//
+//    public void setController(XranController controller) {
+//        this.controller = controller;
+//    }
+//}
diff --git a/src/main/java/org.onosproject.xran/impl/XranConfig.java b/src/main/java/org.onosproject.xran/impl/XranConfig.java
new file mode 100644
index 0000000..be27c89
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/impl/XranConfig.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.impl;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.config.Config;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.EUTRANCellIdentifier;
+import org.onosproject.xran.codecs.api.PLMNIdentity;
+import org.openmuc.jasn1.util.HexConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.bind.DatatypeConverter;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.onosproject.net.DeviceId.deviceId;
+
+public class XranConfig extends Config<ApplicationId> {
+
+    private static final String CELLS = "active_cells";
+
+    private static final String PLMN_ID = "plmn_id";
+    private static final String ECI_ID = "eci";
+
+    private static final String IP_ADDR = "ip_addr";
+
+    private static final String XRANC_PORT = "xranc_port";
+
+    private static final String XRANC_CELLCONFIG_INTERVAL = "xranc_cellconfigrequest_interval_seconds";
+
+    private static final String RX_SIGNAL_MEAS_REPORT_INTERVAL = "rx_signal_meas_report_interval_seconds";
+
+    private static final String L2_MEAS_REPORT_INTERVAL = "l2_meas_report_interval_ms";
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    public Map<String, ECGI> activeCellSet() {
+        Map<String, ECGI> cells = new ConcurrentHashMap<>();
+
+        JsonNode cellsNode = object.get(CELLS);
+        if (cellsNode == null) {
+            log.warn("no cells have been provided!");
+            return cells;
+        }
+
+        cellsNode.forEach(cellNode -> {
+            String plmn_id = cellNode.get(PLMN_ID).asText();
+            String eci = cellNode.get(ECI_ID).asText();
+
+            String ipAddress = cellNode.get(IP_ADDR).asText();
+
+            ECGI ecgi = hexToECGI(plmn_id, eci);
+            cells.put(ipAddress, ecgi);
+        });
+
+        return cells;
+    }
+
+    public int getXrancPort() {
+        return object.get(XRANC_PORT).asInt();
+    }
+
+    public int getConfigRequestInterval() {
+        return object.get(XRANC_CELLCONFIG_INTERVAL).asInt();
+    }
+
+    public int getRxSignalInterval() {
+        return object.get(RX_SIGNAL_MEAS_REPORT_INTERVAL).asInt();
+    }
+
+    public int getL2MeasInterval() {
+        return object.get(L2_MEAS_REPORT_INTERVAL).asInt();
+    }
+
+
+    private ECGI hexToECGI(String plmn_id, String eci) {
+        byte[] bytes = HexConverter.fromShortHexString(plmn_id);
+        byte[] bytearray = DatatypeConverter.parseHexBinary(eci);
+
+        InputStream inputStream = new ByteArrayInputStream(bytearray);
+
+        PLMNIdentity plmnIdentity = new PLMNIdentity(bytes);
+        EUTRANCellIdentifier eutranCellIdentifier = new EUTRANCellIdentifier(bytearray, 28);
+
+        ECGI ecgi = new ECGI();
+        ecgi.setEUTRANcellIdentifier(eutranCellIdentifier);
+        ecgi.setPLMNIdentity(plmnIdentity);
+        try {
+            ecgi.decode(inputStream);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        return ecgi;
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/impl/package-info.java b/src/main/java/org.onosproject.xran/impl/package-info.java
new file mode 100644
index 0000000..baf9a19
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Created by dimitris on 7/23/17.
+ */
+package org.onosproject.xran.impl;
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/package-info.java b/src/main/java/org.onosproject.xran/package-info.java
new file mode 100644
index 0000000..55d9357
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * VTN web that used rest to creat vtn resources.
+ */
+package org.onosproject.xran;
diff --git a/src/main/java/org.onosproject.xran/providers/CellDeviceProvider.java b/src/main/java/org.onosproject.xran/providers/CellDeviceProvider.java
new file mode 100644
index 0000000..f89fe09
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/providers/CellDeviceProvider.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.providers;
+
+import org.apache.felix.scr.annotations.*;
+import org.onlab.packet.ChassisId;
+import org.onosproject.net.*;
+import org.onosproject.net.device.*;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.xran.controller.XranController;
+import org.onosproject.xran.entities.RnibCell;
+import org.slf4j.Logger;
+
+import static org.onosproject.net.DeviceId.deviceId;
+import static org.onosproject.xran.entities.RnibCell.*;
+import static org.slf4j.LoggerFactory.getLogger;
+
+
+/**
+ * Created by dimitris on 7/27/17.
+ */
+
+@Component(immediate = true)
+public class CellDeviceProvider extends AbstractProvider implements DeviceProvider {
+
+    private static final Logger log = getLogger(CellDeviceProvider.class);
+    private final InternalDeviceListener listener = new InternalDeviceListener();
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected DeviceProviderRegistry providerRegistry;
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected XranController controller;
+    private DeviceProviderService providerService;
+
+    public CellDeviceProvider() {
+        super(new ProviderId("xran", "org.onosproject.provider.xran"));
+    }
+
+    @Activate
+    public void activate() {
+        providerService = providerRegistry.register(this);
+        controller.addListener(listener);
+
+        log.info("XRAN Device Provider Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        controller.removeListener(listener);
+        providerRegistry.unregister(this);
+
+        providerService = null;
+        log.info("XRAN Device Provider Stopped");
+    }
+
+    @Override
+    public void triggerProbe(DeviceId deviceId) {
+
+    }
+
+    @Override
+    public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
+
+    }
+
+    @Override
+    public boolean isReachable(DeviceId deviceId) {
+        return true;
+    }
+
+    @Override
+    public void changePortState(DeviceId deviceId, PortNumber portNumber, boolean enable) {
+
+    }
+
+    private class InternalDeviceListener implements XranDeviceListener {
+
+        @Override
+        public void deviceAdded(RnibCell cell) {
+            if (providerService == null) {
+                return;
+            }
+
+            DeviceId id = deviceId(uri(cell.getEcgi()));
+
+            ChassisId cId = new ChassisId(id.hashCode());
+
+            Device.Type type = Device.Type.OTHER;
+            SparseAnnotations annotations = DefaultAnnotations.builder()
+                    .set(AnnotationKeys.NAME, "eNodeB #" + cell.getEcgi().getEUTRANcellIdentifier())
+                    .set(AnnotationKeys.PROTOCOL, "SCTP")
+                    .set(AnnotationKeys.CHANNEL_ID, "xxx")
+                    .set(AnnotationKeys.MANAGEMENT_ADDRESS, "127.0.0.1")
+                    .build();
+
+            DeviceDescription descBase =
+                    new DefaultDeviceDescription(id.uri(), type,
+                            "xran", "0.1", "0.1", id.uri().toString(),
+                            cId);
+            DeviceDescription desc = new DefaultDeviceDescription(descBase, annotations);
+
+            providerService.deviceConnected(id, desc);
+        }
+
+        @Override
+        public void deviceRemoved(DeviceId id) {
+            providerService.deviceDisconnected(id);
+        }
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/providers/UeProvider.java b/src/main/java/org.onosproject.xran/providers/UeProvider.java
new file mode 100644
index 0000000..c7a76b9
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/providers/UeProvider.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.providers;
+
+import com.google.common.collect.Sets;
+import org.apache.felix.scr.annotations.*;
+import org.onlab.packet.VlanId;
+import org.onosproject.net.*;
+import org.onosproject.net.host.DefaultHostDescription;
+import org.onosproject.net.host.HostProvider;
+import org.onosproject.net.host.HostProviderRegistry;
+import org.onosproject.net.host.HostProviderService;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.controller.XranController;
+import org.onosproject.xran.entities.RnibUe;
+import org.slf4j.Logger;
+
+import java.util.Set;
+
+import static org.onosproject.net.DeviceId.*;
+import static org.onosproject.xran.entities.RnibCell.*;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Created by dimitris on 7/28/17.
+ */
+
+@Component(immediate = true)
+public class UeProvider extends AbstractProvider implements HostProvider {
+
+    private static final Logger log = getLogger(UeProvider.class);
+    private final InternalHostListener listener = new InternalHostListener();
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private HostProviderRegistry providerRegistry;
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private XranController controller;
+    private HostProviderService providerService;
+
+    public UeProvider() {
+        super(new ProviderId("xran", "org.onosproject.providers.cell"));
+    }
+
+    @Activate
+    public void activate() {
+        providerService = providerRegistry.register(this);
+        controller.addListener(listener);
+
+        log.info("XRAN Host Provider Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        controller.removeListener(listener);
+        providerRegistry.unregister(this);
+
+        providerService = null;
+        log.info("XRAN Host Provider Stopped");
+    }
+
+    @Override
+    public void triggerProbe(Host host) {
+
+    }
+
+    class InternalHostListener implements XranHostListener {
+
+        @Override
+        public void hostAdded(RnibUe ue, Set<ECGI> ecgiSet) {
+            if (providerService == null) {
+                return;
+            }
+
+            if (ue == null) {
+                log.error("UE {} is not found", ue);
+                return;
+            }
+
+            try {
+                Set<HostLocation> hostLocations = Sets.newConcurrentHashSet();
+
+                ecgiSet.forEach(ecgi -> hostLocations.add(new HostLocation(deviceId(uri(ecgi)), PortNumber.portNumber(0), 0)));
+
+                SparseAnnotations annotations = DefaultAnnotations.builder()
+                        .set(AnnotationKeys.NAME, "UE #" + ue.getMmeS1apId())
+                        .build();
+
+                DefaultHostDescription desc = new DefaultHostDescription(
+                        ue.getHostId().mac(),
+                        VlanId.vlanId(VlanId.UNTAGGED),
+                        hostLocations,
+                        Sets.newConcurrentHashSet(),
+                        true,
+                        annotations
+                );
+
+                providerService.hostDetected(ue.getHostId(), desc, false);
+            } catch (Exception e) {
+                log.warn(e.getMessage());
+                e.printStackTrace();
+            }
+        }
+
+        @Override
+        public void hostRemoved(HostId id) {
+            providerService.hostVanished(id);
+        }
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/providers/XranDeviceListener.java b/src/main/java/org.onosproject.xran/providers/XranDeviceListener.java
new file mode 100644
index 0000000..01f0e95
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/providers/XranDeviceListener.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.providers;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.xran.entities.RnibCell;
+
+/**
+ * Created by dimitris on 7/27/17.
+ */
+public interface XranDeviceListener {
+
+    void deviceAdded(RnibCell id);
+
+    void deviceRemoved(DeviceId id);
+}
diff --git a/src/main/java/org.onosproject.xran/providers/XranHostListener.java b/src/main/java/org.onosproject.xran/providers/XranHostListener.java
new file mode 100644
index 0000000..79676e3
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/providers/XranHostListener.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.providers;
+
+import org.onosproject.net.HostId;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.entities.RnibUe;
+
+import java.util.Set;
+
+/**
+ * Created by dimitris on 7/28/17.
+ */
+public interface XranHostListener {
+
+    void hostAdded(RnibUe ue, Set<ECGI> ecgiSet);
+
+    void hostRemoved(HostId id);
+}
diff --git a/src/main/java/org.onosproject.xran/providers/package-info.java b/src/main/java/org.onosproject.xran/providers/package-info.java
new file mode 100644
index 0000000..a3ee964
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/providers/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Created by dimitris on 7/27/17.
+ */
+package org.onosproject.xran.providers;
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/rest/CellWebResource.java b/src/main/java/org.onosproject.xran/rest/CellWebResource.java
new file mode 100644
index 0000000..a2b0eac
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/CellWebResource.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.xran.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.annotations.Patch;
+import org.onosproject.xran.entities.RnibCell;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Cell web resource.
+ */
+@Path("cell")
+public class CellWebResource extends AbstractWebResource {
+
+    private static final Logger log =
+            LoggerFactory.getLogger(CellWebResource.class);
+
+    /**
+     * test.
+     *
+     * @param eciHex test
+     * @return test
+     */
+    @GET
+    @Path("{cellid}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getCell(@PathParam("cellid") String eciHex) {
+        log.debug("GET CELLID {}", eciHex);
+
+        RnibCell cell = get(XranStore.class).getCell(eciHex);
+
+        ObjectNode rootNode = mapper().createObjectNode();
+
+        if (cell != null) {
+            try {
+                JsonNode jsonNode = mapper().readTree(cell.toString());
+                rootNode.put("cell", jsonNode);
+            } catch (IOException e) {
+                log.error(ExceptionUtils.getFullStackTrace(e));
+                e.printStackTrace();
+            }
+        } else {
+            rootNode.put("error", "not found");
+        }
+
+        return ok(rootNode.toString()).build();
+    }
+
+    /**
+     * test.
+     *
+     * @param eciHex test
+     * @param stream test
+     * @return test
+     */
+    @Patch
+    @Path("{cellid}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response patchCell(@PathParam("cellid") String eciHex, InputStream stream) {
+        log.debug("PATCH CELLID {}", eciHex);
+
+        boolean b = false;
+
+        try {
+            ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
+
+            JsonNode rrmConf = jsonTree.get("RRMConf");
+            if (rrmConf != null) {
+                b = get(XranStore.class).modifyCellRrmConf(eciHex, rrmConf);
+            }
+        } catch (Exception e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+
+        return ok(b).build();
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/rest/LinkWebResource.java b/src/main/java/org.onosproject.xran/rest/LinkWebResource.java
new file mode 100644
index 0000000..65772f0
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/LinkWebResource.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.xran.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.annotations.Patch;
+import org.onosproject.xran.entities.RnibLink;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * Link web resource.
+ */
+@Path("links")
+public class LinkWebResource extends AbstractWebResource {
+
+    private static final Logger log =
+            LoggerFactory.getLogger(LinkWebResource.class);
+
+    /**
+     * test.
+     *
+     * @param eciHex test
+     * @param ue     test
+     * @return test
+     */
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getLinksBetween(@DefaultValue("") @QueryParam("cell") String eciHex,
+                             @DefaultValue("-1") @QueryParam("ue") long ue) {
+        log.debug("GET LINKS CELL {} AND UE {}", eciHex, ue);
+
+        List<RnibLink> list = Lists.newArrayList();
+        if (!eciHex.isEmpty() && ue != -1) {
+            RnibLink link = get(XranStore.class).getLinkBetweenCellIdUeId(eciHex, ue);
+            if (link != null) {
+                list.add(link);
+            }
+        } else if (!eciHex.isEmpty()) {
+            list.addAll(get(XranStore.class).getLinksByCellId(eciHex));
+        } else if (ue != -1) {
+            list.addAll(get(XranStore.class).getLinksByUeId(ue));
+        } else {
+            list.addAll(get(XranStore.class).getLinks());
+        }
+
+        ObjectNode rootNode = mapper().createObjectNode();
+
+        try {
+            JsonNode jsonNode = mapper().readTree(list.toString());
+            rootNode.put("links", jsonNode);
+        } catch (IOException e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+        return ok(rootNode.toString()).build();
+    }
+
+    /**
+     * test.
+     *
+     * @param src    test
+     * @param dst    test
+     * @param stream test
+     * @return test
+     */
+    @Patch
+    @Path("{src},{dst}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response patchLinks(@PathParam("src") String src, @PathParam("dst") long dst, InputStream stream) {
+        log.debug("Patch LINKS FROM {} to {}", src, dst);
+
+        boolean b = false;
+        try {
+            ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
+
+            JsonNode type = jsonTree.get("type");
+            if (type != null) {
+
+            }
+
+            JsonNode trafficpercent = jsonTree.get("trafficpercent");
+            if (trafficpercent != null) {
+
+            }
+        } catch (Exception e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+        return ok(b).build();
+    }
+
+    /**
+     * test.
+     *
+     * @param src    test
+     * @param dst    test
+     * @param stream test
+     * @return test
+     */
+    @POST
+    @Path("{src},{dst}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response postLinks(@PathParam("src") String src, @PathParam("dst") long dst, InputStream stream) {
+        log.debug("POST LINKS FROM {} to {}", src, dst);
+
+        boolean b = false;
+        try {
+            ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
+
+            JsonNode type = jsonTree.get("type");
+
+            if (type != null) {
+                b = get(XranStore.class).createLinkBetweenCellIdUeId(src, dst, type.asText());
+            }
+        } catch (Exception e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+        return ok(b).build();
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/rest/NodeWebResource.java b/src/main/java/org.onosproject.xran/rest/NodeWebResource.java
new file mode 100644
index 0000000..1a70ccc
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/NodeWebResource.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.xran.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.entities.RnibCell;
+import org.onosproject.xran.entities.RnibUe;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Node web resource.
+ */
+@Path("nodes")
+public class NodeWebResource extends AbstractWebResource {
+
+    private static final Logger log =
+            LoggerFactory.getLogger(NodeWebResource.class);
+
+    /**
+     * test.
+     *
+     * @param type test
+     * @return test
+     */
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getNodes(@DefaultValue("") @QueryParam("type") String type) {
+        log.debug("GET NODES " + type);
+
+        ObjectNode rootNode = mapper().createObjectNode();
+
+        try {
+            if (StringUtils.isBlank(type)) {
+                List<Object> nodes = get(XranStore.class).getNodes();
+
+                JsonNode jsonNode = mapper().readTree(nodes.get(0).toString());
+                JsonNode jsonNode2 = mapper().readTree(nodes.get(1).toString());
+
+                ObjectNode arrayNode = rootNode.putObject("nodes");
+                arrayNode.put("cells", jsonNode);
+                arrayNode.put("ues", jsonNode2);
+            } else if (type.equals("cell")) {
+                List<RnibCell> cellNodes = get(XranStore.class).getCellNodes();
+                JsonNode jsonNode = mapper().readTree(cellNodes.toString());
+
+                ObjectNode arrayNode = rootNode.putObject("nodes");
+                arrayNode.put("cells", jsonNode);
+            } else if (type.equals("ue")) {
+                List<RnibUe> ueNodes = get(XranStore.class).getUeNodes();
+                JsonNode jsonNode = mapper().readTree(ueNodes.toString());
+
+                ObjectNode arrayNode = rootNode.putObject("nodes");
+                arrayNode.put("ues", jsonNode);
+            }
+        } catch (IOException e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+        return ok(rootNode.toString()).build();
+    }
+
+    /**
+     * test.
+     *
+     * @param nodeid test
+     * @return test
+     */
+    @GET
+    @Path("{nodeid}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getNodeid(@PathParam("nodeid") String nodeid) {
+        log.debug("GET NODEID {}", nodeid);
+
+        Object node = get(XranStore.class).getByNodeId(nodeid);
+
+        ObjectNode rootNode = mapper().createObjectNode();
+
+        if (node != null) {
+            try {
+                JsonNode jsonNode = mapper().readTree(node.toString());
+                rootNode.put("node", jsonNode);
+            } catch (IOException e) {
+                log.error(ExceptionUtils.getFullStackTrace(e));
+                e.printStackTrace();
+            }
+        } else {
+            rootNode.put("error", "not found");
+        }
+
+        return ok(rootNode.toString()).build();
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/rest/SliceWebResource.java b/src/main/java/org.onosproject.xran/rest/SliceWebResource.java
new file mode 100644
index 0000000..2fe8385
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/SliceWebResource.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.xran.rest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.entities.RnibSlice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Slice web resource.
+ */
+@Path("slice")
+public class SliceWebResource extends AbstractWebResource {
+
+    private static final Logger log =
+            LoggerFactory.getLogger(SliceWebResource.class);
+
+    /**
+     * test.
+     *
+     * @param sliceid test
+     * @return test
+     */
+    @GET
+    @Path("{sliceid}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getSlice(@PathParam("sliceid") long sliceid) {
+        log.debug("GET SLICE {}", sliceid);
+
+        RnibSlice slice = get(XranStore.class).getSlice(sliceid);
+
+        ObjectNode rootNode = mapper().createObjectNode();
+
+        if (slice != null) {
+            try {
+                JsonNode jsonNode = mapper().readTree(slice.toString());
+                rootNode.put("slice", jsonNode);
+            } catch (IOException e) {
+                log.error(ExceptionUtils.getFullStackTrace(e));
+                e.printStackTrace();
+            }
+        } else {
+            rootNode.put("error", "not found");
+        }
+
+        return ok(rootNode.toString()).build();
+    }
+
+    /**
+     * test.
+     *
+     * @param stream test
+     * @return test
+     */
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response postSlice(InputStream stream) {
+        log.debug("POST SLICE");
+
+        boolean b = false;
+        try {
+            ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
+
+            b = get(XranStore.class).createSlice(jsonTree);
+        } catch (Exception e) {
+            log.error(ExceptionUtils.getFullStackTrace(e));
+            e.printStackTrace();
+        }
+
+        return ok(b).build();
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/rest/XranWebApplication.java b/src/main/java/org.onosproject.xran/rest/XranWebApplication.java
new file mode 100644
index 0000000..30f584b
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/XranWebApplication.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.rest;
+
+import org.onlab.rest.AbstractWebApplication;
+
+import java.util.Set;
+
+/**
+ * Sample REST API web application.
+ */
+public class XranWebApplication extends AbstractWebApplication {
+    @Override
+    public Set<Class<?>> getClasses() {
+        return getClasses(
+                LinkWebResource.class,
+                NodeWebResource.class,
+                CellWebResource.class,
+                SliceWebResource.class);
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/rest/package-info.java b/src/main/java/org.onosproject.xran/rest/package-info.java
new file mode 100644
index 0000000..16f0c2f
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/rest/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Created by dimitris on 7/20/17.
+ */
+package org.onosproject.xran.rest;
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/samplemessages/BearerEncoderDecoder.java b/src/main/java/org.onosproject.xran/samplemessages/BearerEncoderDecoder.java
new file mode 100644
index 0000000..0252451
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/BearerEncoderDecoder.java
@@ -0,0 +1,100 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.*;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class BearerEncoderDecoder {
+
+    public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, ERABParams erabParams, BerInteger numParams) {
+        ERABResponse erabResponse = new ERABResponse();
+
+        for (int i = 0; i < numParams.intValue(); i++) {
+            ERABParamsItem erabParamsItem = erabParams.getERABParamsItem().get(i);
+
+            ERABResponseItem responseItem = new ERABResponseItem();
+            responseItem.setId(erabParamsItem.getId());
+
+            // FIXME: add logic
+            responseItem.setDecision(new ERABDecision(0));
+
+            erabResponse.setERABResponse(responseItem);
+        }
+
+
+        BearerAdmissionResponse bearerAdmissionResponse = new BearerAdmissionResponse();
+        bearerAdmissionResponse.setCrnti(crnti);
+        bearerAdmissionResponse.setEcgi(ecgi);
+        bearerAdmissionResponse.setErabResponse(erabResponse);
+        bearerAdmissionResponse.setNumErabList(numParams);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setBearerAdmissionResponse(bearerAdmissionResponse);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("2.0");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        XrancApiID apiID = new XrancApiID(9);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+    }
+
+    public XrancPdu setPacketProperties(XrancPdu mainDecoder) {
+        CRNTI crnti = mainDecoder.getBody().getBearerAdmissionRequest().getCrnti();
+        ECGI ecgi = mainDecoder.getBody().getBearerAdmissionRequest().getEcgi();
+
+        //TODO: Verify mainDecoder.getBody().getBearerAdmissionRequest().getNumErabs() or
+        BerInteger numErabs = new BerInteger(5);
+
+        ERABResponseItem responseItem = new ERABResponseItem();
+        responseItem.setId(new ERABID(1));
+        responseItem.setDecision(new ERABDecision(0));
+
+        ERABResponseItem responseItem1 = new ERABResponseItem();
+        responseItem1.setId(new ERABID(2));
+        responseItem1.setDecision(new ERABDecision(0));
+
+        ERABResponse erabResponse = new ERABResponse();
+        erabResponse.setERABResponse(responseItem);
+        erabResponse.setERABResponse(responseItem1);
+
+        BearerAdmissionResponse bearerAdmissionResponse = new BearerAdmissionResponse();
+        bearerAdmissionResponse.setCrnti(crnti);
+        bearerAdmissionResponse.setEcgi(ecgi);
+        bearerAdmissionResponse.setErabResponse(erabResponse);
+        bearerAdmissionResponse.setNumErabList(numErabs);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setBearerAdmissionResponse(bearerAdmissionResponse);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("2.0");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        XrancApiID apiID = new XrancApiID(9);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/ConfigEncoderDecoder.java b/src/main/java/org.onosproject.xran/samplemessages/ConfigEncoderDecoder.java
new file mode 100644
index 0000000..ad74aab
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/ConfigEncoderDecoder.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.EUTRANCellIdentifier;
+import org.onosproject.xran.codecs.api.PLMNIdentity;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Created by dimitris on 7/25/17.
+ */
+public class ConfigEncoderDecoder {
+    private static final Logger log =
+            LoggerFactory.getLogger(ConfigEncoderDecoder.class);
+
+    /*public String decode(String s) throws IOException {
+        byte[] bytearray = DatatypeConverter.parseHexBinary(s);
+        InputStream inputStream = new ByteArrayInputStream(bytearray);
+        XrancPdu pdu_decoded = new XrancPdu();
+        pdu_decoded.decode(inputStream);
+        return pdu_decoded.toString();
+    }*/
+/*
+    public String encodeConfigRequest()
+            throws IOException {
+        pdu = setPacketProperties();
+        pdu.encode(os);
+        return DatatypeConverter.printHexBinary(os.getArray());
+    }*/
+
+    public static XrancPdu constructPacket(ECGI ecgi) throws UnsupportedEncodingException {
+        CellConfigRequest cellConfigRequest = new CellConfigRequest();
+        cellConfigRequest.setEcgi(ecgi);
+
+        BerUTF8String ver = new BerUTF8String("2a");
+
+        XrancApiID apiID = new XrancApiID(0);
+        XrancPduBody body = new XrancPduBody();
+        body.setCellConfigRequest(cellConfigRequest);
+
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setBody(body);
+        pdu.setHdr(hdr);
+
+        return pdu;
+    }
+
+    public XrancPdu setPacketProperties() throws UnsupportedEncodingException {
+        PLMNIdentity plmnIdentity = new PLMNIdentity(new byte[]{(byte) 0x22, (byte) 0x08, (byte) 0x41});
+        EUTRANCellIdentifier eutranCellIdentifier = new EUTRANCellIdentifier(new byte[]{
+                (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xF0
+        }, 28);
+
+        ECGI ecgi = new ECGI();
+
+        ecgi.setPLMNIdentity(plmnIdentity);
+        ecgi.setEUTRANcellIdentifier(eutranCellIdentifier);
+
+        CellConfigRequest cellConfigRequest = new CellConfigRequest();
+        cellConfigRequest.setEcgi(ecgi);
+
+        BerUTF8String ver = new BerUTF8String("2a");
+
+        XrancApiID apiID = new XrancApiID(0);
+        XrancPduBody body = new XrancPduBody();
+        body.setCellConfigRequest(cellConfigRequest);
+
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setBody(body);
+        pdu.setHdr(hdr);
+
+        return pdu;
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/ConfigReport.java b/src/main/java/org.onosproject.xran/samplemessages/ConfigReport.java
new file mode 100644
index 0000000..5ab504e
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/ConfigReport.java
@@ -0,0 +1,106 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.*;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.types.BerBoolean;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class ConfigReport {
+
+    BerByteArrayOutputStream os;
+
+    public ConfigReport() {
+        os = new BerByteArrayOutputStream(4096);
+    }
+
+    /*public String encodeResponse(XrancPdu decoder) {
+        pdu = setPacketProperties(decoder);
+        try {
+            pdu.encode(os);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return DatatypeConverter.printHexBinary(os.getArray());
+    }*/
+
+    public XrancPdu setPacketProperties(XrancPdu decoder) throws UnsupportedEncodingException {
+
+        ECGI ecgi = decoder.getBody().getCellConfigRequest().getEcgi();
+
+        PhysCellId physCellId = new PhysCellId(420);
+
+        PhysCellId physCellId1 = new PhysCellId(500);
+        ARFCNValue earfcn_dl = new ARFCNValue(2100);
+        CandScell candScell = new CandScell();
+        candScell.setPci(physCellId1);
+        candScell.setEarfcnDl(earfcn_dl);
+
+        PhysCellId physCellId2 = new PhysCellId(400);
+        ARFCNValue earfcn_dl1 = new ARFCNValue(2300);
+        CandScell candScell1 = new CandScell();
+        candScell1.setPci(physCellId2);
+        candScell1.setEarfcnDl(earfcn_dl1);
+
+        CellConfigReport.CandScells candScells = new CellConfigReport.CandScells();
+        candScells.setCandScells(candScell);
+        candScells.setCandScells(candScell1);
+
+        ARFCNValue earfcn_dl2 = new ARFCNValue(2000);
+
+        ARFCNValue earfcn_ul = new ARFCNValue(1900);
+
+        BerInteger rbs_per_tti_dl = new BerInteger(40);
+
+        BerInteger rbs_per_tti_ul = new BerInteger(30);
+
+        BerInteger num_tx_antenna = new BerInteger(2);
+
+        DuplexMode duplexMode = new DuplexMode(1);
+
+        BerInteger max_num_connected_ues = new BerInteger(1000);
+
+        BerInteger max_num_connected_bearers = new BerInteger(2000);
+
+        BerInteger max_num_ues_sched_per_tti_dl = new BerInteger(10);
+
+        BerInteger max_num_ues_sched_per_tti_ul = new BerInteger(10);
+
+        BerBoolean dlfs_sched_enable = new BerBoolean(true);
+
+        CellConfigReport cellConfigReport = new CellConfigReport();
+        cellConfigReport.setEcgi(ecgi);
+        cellConfigReport.setPci(physCellId);
+        cellConfigReport.setCandScells(candScells);
+        cellConfigReport.setEarfcnDl(earfcn_dl2);
+        cellConfigReport.setEarfcnUl(earfcn_ul);
+        cellConfigReport.setRbsPerTtiDl(rbs_per_tti_dl);
+        cellConfigReport.setRbsPerTtiUl(rbs_per_tti_ul);
+        cellConfigReport.setNumTxAntenna(num_tx_antenna);
+        cellConfigReport.setDuplexMode(duplexMode);
+        cellConfigReport.setMaxNumConnectedUes(max_num_connected_ues);
+        cellConfigReport.setMaxNumConnectedBearers(max_num_connected_bearers);
+        cellConfigReport.setMaxNumUesSchedPerTtiDl(max_num_ues_sched_per_tti_dl);
+        cellConfigReport.setMaxNumUesSchedPerTtiUl(max_num_ues_sched_per_tti_ul);
+        cellConfigReport.setDlfsSchedEnable(dlfs_sched_enable);
+
+        BerUTF8String ver = new BerUTF8String("2a");
+
+        XrancApiID apiID = new XrancApiID(1);
+        XrancPduBody body = new XrancPduBody();
+        body.setCellConfigReport(cellConfigReport);
+
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setBody(body);
+        pdu.setHdr(hdr);
+
+        return pdu;
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/L2MeasConf.java b/src/main/java/org.onosproject.xran/samplemessages/L2MeasConf.java
new file mode 100644
index 0000000..5fa3087
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/L2MeasConf.java
@@ -0,0 +1,81 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.EUTRANCellIdentifier;
+import org.onosproject.xran.codecs.api.PLMNIdentity;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class L2MeasConf {
+
+
+    public static XrancPdu constructPacket(ECGI ecgi, int l2MeasInterval) {
+
+        BerInteger reportIntervalMS = new BerInteger(l2MeasInterval);
+        L2MeasConfig measConfig = new L2MeasConfig();
+        measConfig.setEcgi(ecgi);
+        measConfig.setReportIntervalMs(reportIntervalMS);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("2a");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        XrancApiID apiID = new XrancApiID(19);
+        XrancPduBody body = new XrancPduBody();
+        body.setL2MeasConfig(measConfig);
+
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setBody(body);
+        pdu.setHdr(hdr);
+
+        return pdu;
+
+    }
+
+    public XrancPdu setPacketProperties() {
+        PLMNIdentity plmnIdentity = new PLMNIdentity(new byte[]{(byte) 0x22, (byte) 0x08, (byte) 0x41});
+        EUTRANCellIdentifier eutranCellIdentifier = new EUTRANCellIdentifier(new byte[]{
+                (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xF0
+        }, 28);
+
+        ECGI ecgi = new ECGI();
+        ecgi.setPLMNIdentity(plmnIdentity);
+        ecgi.setEUTRANcellIdentifier(eutranCellIdentifier);
+
+        BerInteger reportIntervalMS = new BerInteger(10);
+        L2MeasConfig measConfig = new L2MeasConfig();
+        measConfig.setEcgi(ecgi);
+        measConfig.setReportIntervalMs(reportIntervalMS);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("2a");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        XrancApiID apiID = new XrancApiID(19);
+        XrancPduBody body = new XrancPduBody();
+        body.setL2MeasConfig(measConfig);
+
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setBody(body);
+        pdu.setHdr(hdr);
+
+        return pdu;
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/PDCPReportPerUE.java b/src/main/java/org.onosproject.xran/samplemessages/PDCPReportPerUE.java
new file mode 100644
index 0000000..2400cde
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/PDCPReportPerUE.java
@@ -0,0 +1,96 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.QCI;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class PDCPReportPerUE {
+
+    public XrancPdu setPacketProperties(XrancPdu recv_pdu) {
+        ECGI ecgi = recv_pdu.getBody().getL2MeasConfig().getEcgi();
+
+        //Need to get this from UE.
+        CRNTI crnti = new CRNTI(new byte[]{(byte) 0x44, (byte) 0x44}, 16);
+
+        PDCPMeasReportPerUe.QciVals qciVals = new PDCPMeasReportPerUe.QciVals();
+        qciVals.setQCI(new QCI(1));
+        qciVals.setQCI(new QCI(2));
+
+        PDCPMeasReportPerUe.DataVolDl dataVolDl = new PDCPMeasReportPerUe.DataVolDl();
+        dataVolDl.setBerInteger(new BerInteger(500));
+        dataVolDl.setBerInteger(new BerInteger(500));
+
+        PDCPMeasReportPerUe.DataVolUl dataVolUl = new PDCPMeasReportPerUe.DataVolUl();
+        dataVolUl.setBerInteger(new BerInteger(500));
+        dataVolUl.setBerInteger(new BerInteger(500));
+
+        PDCPMeasReportPerUe.PktDelayDl pktDelayDl = new PDCPMeasReportPerUe.PktDelayDl();
+        pktDelayDl.setBerInteger(new BerInteger(314));
+        pktDelayDl.setBerInteger(new BerInteger(314));
+
+        PDCPMeasReportPerUe.PktDelayUl pktDelayUl = new PDCPMeasReportPerUe.PktDelayUl();
+        pktDelayUl.setBerInteger(new BerInteger(314));
+        pktDelayUl.setBerInteger(new BerInteger(314));
+
+        PDCPMeasReportPerUe.PktDiscardRateDl pktDiscardRateDl = new PDCPMeasReportPerUe.PktDiscardRateDl();
+        pktDiscardRateDl.setBerInteger(new BerInteger(10));
+        pktDiscardRateDl.setBerInteger(new BerInteger(5));
+
+        PDCPMeasReportPerUe.PktLossRateDl pktLossRateDl = new PDCPMeasReportPerUe.PktLossRateDl();
+        pktLossRateDl.setBerInteger(new BerInteger(5));
+        pktLossRateDl.setBerInteger(new BerInteger(10));
+
+        PDCPMeasReportPerUe.PktLossRateUl pktLossRateUl = new PDCPMeasReportPerUe.PktLossRateUl();
+        pktLossRateUl.setBerInteger(new BerInteger(8));
+        pktLossRateUl.setBerInteger(new BerInteger(2));
+
+        PDCPMeasReportPerUe.ThroughputDl throughputDl = new PDCPMeasReportPerUe.ThroughputDl();
+        throughputDl.setBerInteger(new BerInteger(500));
+        throughputDl.setBerInteger(new BerInteger(500));
+
+        PDCPMeasReportPerUe.ThroughputUl throughputUl = new PDCPMeasReportPerUe.ThroughputUl();
+        throughputUl.setBerInteger(new BerInteger(500));
+        throughputUl.setBerInteger(new BerInteger(500));
+
+        PDCPMeasReportPerUe pdcpMeasReportPerUe = new PDCPMeasReportPerUe();
+        pdcpMeasReportPerUe.setCrnti(crnti);
+        pdcpMeasReportPerUe.setEcgi(ecgi);
+        pdcpMeasReportPerUe.setQciVals(qciVals);
+        pdcpMeasReportPerUe.setDataVolDl(dataVolDl);
+        pdcpMeasReportPerUe.setDataVolUl(dataVolUl);
+        pdcpMeasReportPerUe.setPktDelayDl(pktDelayDl);
+        pdcpMeasReportPerUe.setPktDelayUl(pktDelayUl);
+        pdcpMeasReportPerUe.setPktDiscardRateDl(pktDiscardRateDl);
+        pdcpMeasReportPerUe.setPktLossRateDl(pktLossRateDl);
+        pdcpMeasReportPerUe.setPktLossRateUl(pktLossRateUl);
+        pdcpMeasReportPerUe.setThroughputDl(throughputDl);
+        pdcpMeasReportPerUe.setThroughputUl(throughputUl);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setPDCPMeasReportPerUe(pdcpMeasReportPerUe);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        XrancApiID apiID = new XrancApiID(24);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/RXSigMeasRep.java b/src/main/java/org.onosproject.xran/samplemessages/RXSigMeasRep.java
new file mode 100644
index 0000000..e59b399
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/RXSigMeasRep.java
@@ -0,0 +1,61 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.*;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class RXSigMeasRep {
+
+    public XrancPdu setPacketProperties(XrancPdu decoder) {
+        CRNTI crnti = decoder.getBody().getRXSigMeasConfig().getCrnti();
+        ECGI ecgi = decoder.getBody().getRXSigMeasConfig().getEcgi();
+
+        RXSigMeasReport.CellMeasReports cellMeasReports = new RXSigMeasReport.CellMeasReports();
+        RXSigReport rxSigReport = new RXSigReport();
+        PCIARFCN pciarfcn = new PCIARFCN();
+        pciarfcn.setPci(new PhysCellId(500));
+        pciarfcn.setEarfcnDl(new ARFCNValue(2100));
+        rxSigReport.setPciArfcn(pciarfcn);
+        rxSigReport.setRsrp(new RSRPRange(4));
+        rxSigReport.setRsrq(new RSRQRange(5));
+        cellMeasReports.setRXSigReport(rxSigReport);
+
+        RXSigReport rxSigReport1 = new RXSigReport();
+        PCIARFCN pciarfcn1 = new PCIARFCN();
+        pciarfcn1.setPci(new PhysCellId(500));
+        pciarfcn1.setEarfcnDl(new ARFCNValue(2100));
+        rxSigReport1.setPciArfcn(pciarfcn);
+        rxSigReport1.setRsrp(new RSRPRange(4));
+        rxSigReport1.setRsrq(new RSRQRange(5));
+        cellMeasReports.setRXSigReport(rxSigReport1);
+
+        RXSigMeasReport rxSigMeasReport = new RXSigMeasReport();
+        rxSigMeasReport.setCrnti(crnti);
+        rxSigMeasReport.setEcgi(ecgi);
+        rxSigMeasReport.setCellMeasReports(cellMeasReports);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setRXSigMeasReport(rxSigMeasReport);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        XrancApiID apiID = new XrancApiID(18);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/RadioReportPerCell.java b/src/main/java/org.onosproject.xran/samplemessages/RadioReportPerCell.java
new file mode 100644
index 0000000..9f6218b
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/RadioReportPerCell.java
@@ -0,0 +1,78 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class RadioReportPerCell {
+    public XrancPdu setPacketProperties(XrancPdu recv_pdu) {
+
+        ECGI ecgi = recv_pdu.getBody().getL2MeasConfig().getEcgi();
+        RadioMeasReportPerCell.PuschIntfPowerHist puschIntfPowerHist = new RadioMeasReportPerCell.PuschIntfPowerHist();
+        puschIntfPowerHist.setBerInteger(new BerInteger(1));
+        puschIntfPowerHist.setBerInteger(new BerInteger(2));
+        puschIntfPowerHist.setBerInteger(new BerInteger(3));
+        puschIntfPowerHist.setBerInteger(new BerInteger(4));
+        puschIntfPowerHist.setBerInteger(new BerInteger(5));
+        puschIntfPowerHist.setBerInteger(new BerInteger(6));
+        puschIntfPowerHist.setBerInteger(new BerInteger(7));
+        puschIntfPowerHist.setBerInteger(new BerInteger(8));
+        puschIntfPowerHist.setBerInteger(new BerInteger(9));
+        puschIntfPowerHist.setBerInteger(new BerInteger(10));
+        puschIntfPowerHist.setBerInteger(new BerInteger(11));
+        puschIntfPowerHist.setBerInteger(new BerInteger(12));
+        puschIntfPowerHist.setBerInteger(new BerInteger(13));
+        puschIntfPowerHist.setBerInteger(new BerInteger(14));
+        puschIntfPowerHist.setBerInteger(new BerInteger(15));
+        puschIntfPowerHist.setBerInteger(new BerInteger(16));
+        puschIntfPowerHist.setBerInteger(new BerInteger(17));
+
+        RadioMeasReportPerCell.PucchIntfPowerHist pucchIntfPowerHist = new RadioMeasReportPerCell.PucchIntfPowerHist();
+        pucchIntfPowerHist.setBerInteger(new BerInteger(1));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(2));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(3));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(4));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(5));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(6));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(7));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(8));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(9));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(10));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(11));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(12));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(13));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(14));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(15));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(16));
+        pucchIntfPowerHist.setBerInteger(new BerInteger(17));
+
+        RadioMeasReportPerCell radioMeasReportPerCell = new RadioMeasReportPerCell();
+        radioMeasReportPerCell.setEcgi(ecgi);
+        radioMeasReportPerCell.setPuschIntfPowerHist(puschIntfPowerHist);
+        radioMeasReportPerCell.setPucchIntfPowerHist(pucchIntfPowerHist);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setRadioMeasReportPerCell(radioMeasReportPerCell);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        XrancApiID apiID = new XrancApiID(21);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/RadioReportPerUE.java b/src/main/java/org.onosproject.xran/samplemessages/RadioReportPerUE.java
new file mode 100644
index 0000000..003d973
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/RadioReportPerUE.java
@@ -0,0 +1,112 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.*;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class RadioReportPerUE {
+
+    public XrancPdu setPacketProperties(XrancPdu recv_pdu) {
+        ECGI ecgi = recv_pdu.getBody().getL2MeasConfig().getEcgi();
+
+        //Need to get this from UE.
+        CRNTI crnti = new CRNTI(new byte[]{(byte) 0x44, (byte) 0x44}, 16);
+        RadioRepPerServCell radioRepPerServCell = new RadioRepPerServCell();
+        PCIARFCN pciarfcn = new PCIARFCN();
+        pciarfcn.setPci(new PhysCellId(500));
+        pciarfcn.setEarfcnDl(new ARFCNValue(2100));
+        radioRepPerServCell.setPciArfcn(pciarfcn);
+
+        RadioRepPerServCell.CqiHist cqiHist = new RadioRepPerServCell.CqiHist();
+        cqiHist.setBerInteger(new BerInteger(1));
+        cqiHist.setBerInteger(new BerInteger(2));
+        cqiHist.setBerInteger(new BerInteger(3));
+        cqiHist.setBerInteger(new BerInteger(4));
+        cqiHist.setBerInteger(new BerInteger(5));
+        cqiHist.setBerInteger(new BerInteger(6));
+        cqiHist.setBerInteger(new BerInteger(7));
+        cqiHist.setBerInteger(new BerInteger(8));
+        cqiHist.setBerInteger(new BerInteger(9));
+        cqiHist.setBerInteger(new BerInteger(10));
+        cqiHist.setBerInteger(new BerInteger(11));
+        cqiHist.setBerInteger(new BerInteger(12));
+        cqiHist.setBerInteger(new BerInteger(13));
+        cqiHist.setBerInteger(new BerInteger(14));
+        cqiHist.setBerInteger(new BerInteger(15));
+        cqiHist.setBerInteger(new BerInteger(16));
+        radioRepPerServCell.setCqiHist(cqiHist);
+
+        RadioRepPerServCell.RiHist riHist = new RadioRepPerServCell.RiHist();
+        riHist.setBerInteger(new BerInteger(1));
+        riHist.setBerInteger(new BerInteger(1));
+        radioRepPerServCell.setRiHist(riHist);
+
+        RadioRepPerServCell.PuschSinrHist puschSinrHist = new RadioRepPerServCell.PuschSinrHist();
+        puschSinrHist.setBerInteger(new BerInteger(1));
+        puschSinrHist.setBerInteger(new BerInteger(2));
+        puschSinrHist.setBerInteger(new BerInteger(3));
+        puschSinrHist.setBerInteger(new BerInteger(4));
+        puschSinrHist.setBerInteger(new BerInteger(5));
+        puschSinrHist.setBerInteger(new BerInteger(6));
+        puschSinrHist.setBerInteger(new BerInteger(7));
+        puschSinrHist.setBerInteger(new BerInteger(8));
+        puschSinrHist.setBerInteger(new BerInteger(9));
+        puschSinrHist.setBerInteger(new BerInteger(10));
+        puschSinrHist.setBerInteger(new BerInteger(11));
+        puschSinrHist.setBerInteger(new BerInteger(12));
+        puschSinrHist.setBerInteger(new BerInteger(13));
+        puschSinrHist.setBerInteger(new BerInteger(14));
+        radioRepPerServCell.setPuschSinrHist(puschSinrHist);
+
+        RadioRepPerServCell.PucchSinrHist pucchSinrHist = new RadioRepPerServCell.PucchSinrHist();
+        pucchSinrHist.setBerInteger(new BerInteger(1));
+        pucchSinrHist.setBerInteger(new BerInteger(2));
+        pucchSinrHist.setBerInteger(new BerInteger(3));
+        pucchSinrHist.setBerInteger(new BerInteger(4));
+        pucchSinrHist.setBerInteger(new BerInteger(5));
+        pucchSinrHist.setBerInteger(new BerInteger(6));
+        pucchSinrHist.setBerInteger(new BerInteger(7));
+        pucchSinrHist.setBerInteger(new BerInteger(8));
+        pucchSinrHist.setBerInteger(new BerInteger(9));
+        pucchSinrHist.setBerInteger(new BerInteger(10));
+        pucchSinrHist.setBerInteger(new BerInteger(11));
+        pucchSinrHist.setBerInteger(new BerInteger(12));
+        pucchSinrHist.setBerInteger(new BerInteger(13));
+        pucchSinrHist.setBerInteger(new BerInteger(14));
+        radioRepPerServCell.setPucchSinrHist(pucchSinrHist);
+
+
+        RadioMeasReportPerUE.RadioReportServCells radioReportServCells = new RadioMeasReportPerUE.RadioReportServCells();
+        radioReportServCells.setRadioRepPerServCell(radioRepPerServCell);
+
+        RadioMeasReportPerUE radioMeasReportPerUE = new RadioMeasReportPerUE();
+        radioMeasReportPerUE.setRadioReportServCells(radioReportServCells);
+        radioMeasReportPerUE.setCrnti(crnti);
+        radioMeasReportPerUE.setEcgi(ecgi);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setRadioMeasReportPerUE(radioMeasReportPerUE);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        XrancApiID apiID = new XrancApiID(20);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/SchedReportPerCell.java b/src/main/java/org.onosproject.xran/samplemessages/SchedReportPerCell.java
new file mode 100644
index 0000000..43ccecc
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/SchedReportPerCell.java
@@ -0,0 +1,69 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.PRBUsage;
+import org.onosproject.xran.codecs.api.QCI;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class SchedReportPerCell {
+
+    public XrancPdu setPacketProperties(XrancPdu recv_pdu) {
+        ECGI ecgi = recv_pdu.getBody().getL2MeasConfig().getEcgi();
+
+        SchedMeasReportPerCell.QciVals qciVals = new SchedMeasReportPerCell.QciVals();
+        qciVals.setQCI(new QCI(1));
+        qciVals.setQCI(new QCI(2));
+
+        PRBUsage pcell = new PRBUsage();
+        PRBUsage.PrbUsageDl prbUsageDl = new PRBUsage.PrbUsageDl();
+        prbUsageDl.setBerInteger(new BerInteger(50));
+        prbUsageDl.setBerInteger(new BerInteger(100));
+        pcell.setPrbUsageDl(prbUsageDl);
+
+        PRBUsage.PrbUsageUl prbUsageUl = new PRBUsage.PrbUsageUl();
+        prbUsageUl.setBerInteger(new BerInteger(50));
+        prbUsageUl.setBerInteger(new BerInteger(100));
+        pcell.setPrbUsageUl(prbUsageUl);
+
+        PRBUsage scell = new PRBUsage();
+        prbUsageDl.setBerInteger(new BerInteger(50));
+        prbUsageDl.setBerInteger(new BerInteger(100));
+        scell.setPrbUsageDl(prbUsageDl);
+
+        prbUsageUl.setBerInteger(new BerInteger(50));
+        prbUsageUl.setBerInteger(new BerInteger(100));
+        scell.setPrbUsageUl(prbUsageUl);
+
+        SchedMeasReportPerCell schedMeasReportPerCell = new SchedMeasReportPerCell();
+        schedMeasReportPerCell.setEcgi(ecgi);
+        schedMeasReportPerCell.setQciVals(qciVals);
+        schedMeasReportPerCell.setPrbUsagePcell(pcell);
+        schedMeasReportPerCell.setPrbUsageScell(scell);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setSchedMeasReportPerCell(schedMeasReportPerCell);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        XrancApiID apiID = new XrancApiID(23);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/SchedReportPerUE.java b/src/main/java/org.onosproject.xran/samplemessages/SchedReportPerUE.java
new file mode 100644
index 0000000..5e7676c
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/SchedReportPerUE.java
@@ -0,0 +1,103 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.*;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.BerInteger;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class SchedReportPerUE {
+
+    public XrancPdu setPacketProperties(XrancPdu recv_pdu) {
+        ECGI ecgi = recv_pdu.getBody().getL2MeasConfig().getEcgi();
+
+        //Need to get this from UE.
+        CRNTI crnti = new CRNTI(new byte[]{(byte) 0x44, (byte) 0x44}, 16);
+
+        SchedMeasRepPerServCell schedMeasRepPerServCell = new SchedMeasRepPerServCell();
+        PCIARFCN pciarfcn = new PCIARFCN();
+        pciarfcn.setPci(new PhysCellId(500));
+        pciarfcn.setEarfcnDl(new ARFCNValue(2100));
+
+        SchedMeasRepPerServCell.QciVals qciVals = new SchedMeasRepPerServCell.QciVals();
+        qciVals.setQCI(new QCI(1));
+        qciVals.setQCI(new QCI(2));
+
+        PRBUsage prbUsage = new PRBUsage();
+        PRBUsage.PrbUsageDl prbUsageDl = new PRBUsage.PrbUsageDl();
+        prbUsageDl.setBerInteger(new BerInteger(50));
+        prbUsageDl.setBerInteger(new BerInteger(100));
+        prbUsage.setPrbUsageDl(prbUsageDl);
+
+        PRBUsage.PrbUsageUl prbUsageUl = new PRBUsage.PrbUsageUl();
+        prbUsageUl.setBerInteger(new BerInteger(50));
+        prbUsageUl.setBerInteger(new BerInteger(100));
+        prbUsage.setPrbUsageUl(prbUsageUl);
+
+        SchedMeasRepPerServCell.McsDl mcsDl = new SchedMeasRepPerServCell.McsDl();
+        mcsDl.setBerInteger(new BerInteger(1));
+        mcsDl.setBerInteger(new BerInteger(4));
+
+        SchedMeasRepPerServCell.McsUl mcsUl = new SchedMeasRepPerServCell.McsUl();
+        mcsUl.setBerInteger(new BerInteger(5));
+        mcsUl.setBerInteger(new BerInteger(6));
+
+        SchedMeasRepPerServCell.NumSchedTtisDl numSchedTtisDl = new SchedMeasRepPerServCell.NumSchedTtisDl();
+        numSchedTtisDl.setBerInteger(new BerInteger(1000));
+        numSchedTtisDl.setBerInteger(new BerInteger(1000));
+
+        SchedMeasRepPerServCell.NumSchedTtisUl numSchedTtisUl = new SchedMeasRepPerServCell.NumSchedTtisUl();
+        numSchedTtisUl.setBerInteger(new BerInteger(1000));
+        numSchedTtisUl.setBerInteger(new BerInteger(1000));
+
+        SchedMeasRepPerServCell.RankDl1 rankDl1 = new SchedMeasRepPerServCell.RankDl1();
+        rankDl1.setBerInteger(new BerInteger(1));
+        rankDl1.setBerInteger(new BerInteger(1));
+
+        SchedMeasRepPerServCell.RankDl2 rankDl2 = new SchedMeasRepPerServCell.RankDl2();
+        rankDl2.setBerInteger(new BerInteger(1));
+        rankDl2.setBerInteger(new BerInteger(1));
+
+        schedMeasRepPerServCell.setPciArfcn(pciarfcn);
+        schedMeasRepPerServCell.setQciVals(qciVals);
+        schedMeasRepPerServCell.setPrbUsage(prbUsage);
+        schedMeasRepPerServCell.setMcsDl(mcsDl);
+        schedMeasRepPerServCell.setMcsUl(mcsUl);
+        schedMeasRepPerServCell.setNumSchedTtisDl(numSchedTtisDl);
+        schedMeasRepPerServCell.setNumSchedTtisUl(numSchedTtisUl);
+        schedMeasRepPerServCell.setRankDl1(rankDl1);
+        schedMeasRepPerServCell.setRankDl2(rankDl2);
+
+        SchedMeasReportPerUE.SchedReportServCells schedReportServCells = new SchedMeasReportPerUE.SchedReportServCells();
+        schedReportServCells.setSchedMeasRepPerServCell(schedMeasRepPerServCell);
+
+        SchedMeasReportPerUE schedMeasReportPerUE = new SchedMeasReportPerUE();
+        schedMeasReportPerUE.setCrnti(crnti);
+        schedMeasReportPerUE.setEcgi(ecgi);
+        schedMeasReportPerUE.setSchedReportServCells(schedReportServCells);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setSchedMeasReportPerUE(schedMeasReportPerUE);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        XrancApiID apiID = new XrancApiID(22);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+
+
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/SignalMeasConfig.java b/src/main/java/org.onosproject.xran/samplemessages/SignalMeasConfig.java
new file mode 100644
index 0000000..b7f5eaa
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/SignalMeasConfig.java
@@ -0,0 +1,93 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.*;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class SignalMeasConfig {
+    public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, RXSigMeasConfig.MeasCells measCells, int interval) {
+        RXSigRepQty rxSigRepQty = new RXSigRepQty(2);
+        RXSigMeasRepInterval repInterval = new RXSigMeasRepInterval(interval);
+
+        RXSigMeasConfig sigMeasConfig = new RXSigMeasConfig();
+        sigMeasConfig.setCrnti(crnti);
+        sigMeasConfig.setEcgi(ecgi);
+        sigMeasConfig.setReportQty(rxSigRepQty);
+        sigMeasConfig.setMeasCells(measCells);
+        sigMeasConfig.setReportInterval(repInterval);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setRXSigMeasConfig(sigMeasConfig);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        XrancApiID apiID = new XrancApiID(17);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+    }
+
+    public XrancPdu setPacketProperties() {
+        CRNTI crnti = new CRNTI(new byte[]{(byte) 0x44, (byte) 0x44});
+
+        PLMNIdentity plmnIdentity = new PLMNIdentity(new byte[]{(byte) 0xFC, (byte) 0xFF, (byte) 0x3F});
+        EUTRANCellIdentifier eutranCellIdentifier = new EUTRANCellIdentifier(new byte[]{
+                (byte) 0xCF, (byte) 0xFE, (byte) 0x7C, (byte) 0xF0
+        }, 28);
+
+        ECGI ecgi = new ECGI();
+        ecgi.setPLMNIdentity(plmnIdentity);
+        ecgi.setEUTRANcellIdentifier(eutranCellIdentifier);
+
+        RXSigRepQty rxSigRepQty = new RXSigRepQty(2);
+        PCIARFCN pciarfcn = new PCIARFCN();
+        pciarfcn.setPci(new PhysCellId(500));
+        pciarfcn.setEarfcnDl(new ARFCNValue(2100));
+        RXSigMeasConfig.MeasCells measCells = new RXSigMeasConfig.MeasCells();
+        measCells.setPCIARFCN(pciarfcn);
+        RXSigMeasRepInterval repInterval = new RXSigMeasRepInterval(1);
+
+
+        RXSigMeasConfig sigMeasConfig = new RXSigMeasConfig();
+        sigMeasConfig.setCrnti(crnti);
+        sigMeasConfig.setEcgi(ecgi);
+        sigMeasConfig.setReportQty(rxSigRepQty);
+        sigMeasConfig.setMeasCells(measCells);
+        sigMeasConfig.setReportInterval(repInterval);
+
+
+        XrancPduBody body = new XrancPduBody();
+        body.setRXSigMeasConfig(sigMeasConfig);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        XrancApiID apiID = new XrancApiID(17);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+    }
+
+
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/UEAdmEncoderDecoder.java b/src/main/java/org.onosproject.xran/samplemessages/UEAdmEncoderDecoder.java
new file mode 100644
index 0000000..0ec5ce6
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/UEAdmEncoderDecoder.java
@@ -0,0 +1,95 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.AdmEstResponse;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class UEAdmEncoderDecoder {
+
+    private int flag;
+    private BerByteArrayOutputStream os;
+    private XrancPdu pdu;
+
+    public UEAdmEncoderDecoder() {
+        os = new BerByteArrayOutputStream(4096);
+    }
+
+    public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti) {
+        AdmEstResponse response = new AdmEstResponse(1);
+
+        UEAdmissionResponse ueAdmissionResponse = new UEAdmissionResponse();
+        ueAdmissionResponse.setCrnti(crnti);
+        ueAdmissionResponse.setEcgi(ecgi);
+        ueAdmissionResponse.setAdmEstResponse(response);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setUEAdmissionResponse(ueAdmissionResponse);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        XrancApiID apiID = new XrancApiID(3);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+        return pdu;
+    }
+
+    public XrancPdu setPacketProperties(UEAdmissionRequest pdu_decoded) {
+        /*XrancPdu pdu_decoded = new XrancPdu();
+        byte[] bytearray = DatatypeConverter.parseHexBinary(decodedString);
+        InputStream inputStream = new ByteArrayInputStream(bytearray);
+        try {
+            pdu_decoded.decode(inputStream);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }*/
+        CRNTI crnti = pdu_decoded.getCrnti();
+        ECGI ecgi = pdu_decoded.getEcgi();
+
+        AdmEstResponse response = new AdmEstResponse(1);
+        /*if (flag == 1) {
+            response = new AdmEstResponse(0);
+        } else {
+            response = new AdmEstResponse(1);
+        }*/
+
+        UEAdmissionResponse ueAdmissionResponse = new UEAdmissionResponse();
+        ueAdmissionResponse.setCrnti(crnti);
+        ueAdmissionResponse.setEcgi(ecgi);
+        ueAdmissionResponse.setAdmEstResponse(response);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setUEAdmissionResponse(ueAdmissionResponse);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        XrancApiID apiID = new XrancApiID(3);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+        return pdu;
+
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/UEAdmRequest.java b/src/main/java/org.onosproject.xran/samplemessages/UEAdmRequest.java
new file mode 100644
index 0000000..e47f366
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/UEAdmRequest.java
@@ -0,0 +1,65 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.*;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class UEAdmRequest {
+
+    BerByteArrayOutputStream os;
+
+    public UEAdmRequest() {
+        os = new BerByteArrayOutputStream(4096);
+    }
+
+    /*public String encodeResponse() {
+        pdu = setPacketProperties();
+        try {
+            pdu.encode(os);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return DatatypeConverter.printHexBinary(os.getArray());
+    }*/
+
+    public XrancPdu setPacketProperties() throws UnsupportedEncodingException {
+        CRNTI crnti = new CRNTI(new byte[]{(byte) 0x44, (byte) 0x44}, 16);
+
+        PLMNIdentity plmnIdentity = new PLMNIdentity(new byte[]{(byte) 0x22, (byte) 0x08, (byte) 0x41});
+        EUTRANCellIdentifier eutranCellIdentifier = new EUTRANCellIdentifier(new byte[]{
+                (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xF0
+        }, 28);
+
+        ECGI ecgi = new ECGI();
+        ecgi.setPLMNIdentity(plmnIdentity);
+        ecgi.setEUTRANcellIdentifier(eutranCellIdentifier);
+
+        AdmEstCause admEstCause = new AdmEstCause(4);
+
+        UEAdmissionRequest admissionRequest = new UEAdmissionRequest();
+
+        admissionRequest.setCrnti(crnti);
+        admissionRequest.setEcgi(ecgi);
+        admissionRequest.setAdmEstCause(admEstCause);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setUEAdmissionRequest(admissionRequest);
+
+        BerUTF8String ver = new BerUTF8String("4");
+
+        XrancApiID apiID = new XrancApiID(2);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+    }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/samplemessages/UECapabilityEnq.java b/src/main/java/org.onosproject.xran/samplemessages/UECapabilityEnq.java
new file mode 100644
index 0000000..1ea246f
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/UECapabilityEnq.java
@@ -0,0 +1,68 @@
+package org.onosproject.xran.samplemessages;
+
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.pdu.*;
+import org.openmuc.jasn1.ber.types.string.BerUTF8String;
+
+import java.io.UnsupportedEncodingException;
+
+public class UECapabilityEnq {
+
+    public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti) {
+        UECapabilityEnquiry capabilityEnquiry = new UECapabilityEnquiry();
+        capabilityEnquiry.setCrnti(crnti);
+        capabilityEnquiry.setEcgi(ecgi);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setUECapabilityEnquiry(capabilityEnquiry);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        XrancApiID apiID = new XrancApiID(12);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+    }
+
+    public XrancPdu setPacketProperties(XrancPdu mainDecoder) {
+        CRNTI crnti = mainDecoder.getBody().getUECapabilityEnquiry().getCrnti();
+
+        //TODO: ECGI Value has to be read as CELL ID.
+        ECGI ecgi = mainDecoder.getBody().getUECapabilityEnquiry().getEcgi();
+
+        UECapabilityEnquiry capabilityEnquiry = new UECapabilityEnquiry();
+        capabilityEnquiry.setCrnti(crnti);
+        capabilityEnquiry.setEcgi(ecgi);
+
+        XrancPduBody body = new XrancPduBody();
+        body.setUECapabilityEnquiry(capabilityEnquiry);
+
+        BerUTF8String ver = null;
+        try {
+            ver = new BerUTF8String("4");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        XrancApiID apiID = new XrancApiID(12);
+        XrancPduHdr hdr = new XrancPduHdr();
+        hdr.setVer(ver);
+        hdr.setApiId(apiID);
+
+        XrancPdu pdu = new XrancPdu();
+        pdu.setHdr(hdr);
+        pdu.setBody(body);
+
+        return pdu;
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/samplemessages/package-info.java b/src/main/java/org.onosproject.xran/samplemessages/package-info.java
new file mode 100644
index 0000000..175bb66
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/samplemessages/package-info.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.samplemessages;
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/wrapper/CellMap.java b/src/main/java/org.onosproject.xran/wrapper/CellMap.java
new file mode 100644
index 0000000..ea4fc77
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/wrapper/CellMap.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.wrapper;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import io.netty.channel.ChannelHandlerContext;
+import org.onosproject.net.DeviceId;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.PCIARFCN;
+import org.onosproject.xran.entities.RnibCell;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+public class CellMap {
+    private ConcurrentMap<ECGI, ChannelHandlerContext> ecgiCtx = new ConcurrentHashMap<>();
+
+    private BiMap<PCIARFCN, ECGI> pciarfcnMap = HashBiMap.create();
+    private XranStore xranStore;
+
+    public CellMap(XranStore xranStore) {
+        this.xranStore = xranStore;
+    }
+
+    public void putPciArfcn(RnibCell value) {
+        PCIARFCN pciarfcn = new PCIARFCN();
+        pciarfcn.setPci(value.getConf().getPci());
+        pciarfcn.setEarfcnDl(value.getConf().getEarfcnDl());
+        pciarfcnMap.put(pciarfcn, value.getEcgi());
+    }
+
+    public void put(RnibCell value, ChannelHandlerContext ctx) {
+        if (value.getEcgi() != null) {
+            ecgiCtx.put(value.getEcgi(), ctx);
+            xranStore.storeCell(value);
+        }
+    }
+
+    public RnibCell get(PCIARFCN id) {
+        ECGI ecgi = null;
+        ecgi = pciarfcnMap.get(id);
+
+        if (ecgi != null) {
+            return xranStore.getCell(ecgi);
+        }
+        return null;
+    }
+
+    public RnibCell get(ECGI ecgi) {
+        if (ecgi != null) {
+            return xranStore.getCell(ecgi);
+        }
+        return null;
+    }
+
+    public boolean remove(Object key) {
+        ECGI ecgi = null;
+        if (key instanceof ECGI) {
+            ecgi = (ECGI) key;
+        } else if (key instanceof PCIARFCN) {
+            ecgi = pciarfcnMap.get(key);
+        }
+
+        if (ecgi != null) {
+            pciarfcnMap.inverse().remove(ecgi);
+            ecgiCtx.remove(ecgi);
+        }
+
+        return ecgi != null && xranStore.removeCell(ecgi);
+    }
+
+    public ChannelHandlerContext getCtx(ECGI id) {
+        return ecgiCtx.get(id);
+    }
+
+}
diff --git a/src/main/java/org.onosproject.xran/wrapper/LinkMap.java b/src/main/java/org.onosproject.xran/wrapper/LinkMap.java
new file mode 100644
index 0000000..827781f
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/wrapper/LinkMap.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.wrapper;
+
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ECGI;
+import org.onosproject.xran.codecs.api.MMEUES1APID;
+import org.onosproject.xran.entities.RnibCell;
+import org.onosproject.xran.entities.RnibLink;
+import org.onosproject.xran.entities.RnibUe;
+import org.onosproject.xran.identifiers.LinkId;
+import org.slf4j.Logger;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+public class LinkMap {
+    private static final Logger log = getLogger(LinkMap.class);
+
+    private ConcurrentMap<CRNTI, MMEUES1APID> crntiMme = new ConcurrentHashMap<>();
+
+    private XranStore xranStore;
+
+    public LinkMap(XranStore xranStore) {
+        this.xranStore = xranStore;
+    }
+
+    public void putPrimaryLink(RnibCell cell, RnibUe ue) {
+        RnibLink link = new RnibLink();
+        link.setLinkId(cell, ue);
+        link.setType(RnibLink.Type.SERVING_PRIMARY);
+        xranStore.getLinksByUeId(ue.getMmeS1apId().longValue())
+                .forEach(l -> l.setType(RnibLink.Type.SERVING_SECONDARY));
+        xranStore.storeLink(link);
+        crntiMme.put(ue.getRanId(), ue.getMmeS1apId());
+    }
+
+    public RnibLink putNonServingLink(RnibCell cell, CRNTI crnti) {
+        RnibLink link = null;
+        MMEUES1APID mmeues1APID = crntiMme.get(crnti);
+
+        if (mmeues1APID != null) {
+            link = new RnibLink();
+            RnibUe ue = xranStore.getUe(mmeues1APID);
+            link.setLinkId(cell, ue);
+            link.setType(RnibLink.Type.NON_SERVING);
+            xranStore.storeLink(link);
+        } else {
+            log.error("Could not find mapping for CRNTI to UE. Aborting creation of non-serving link");
+        }
+        return link;
+    }
+
+    public RnibLink get(ECGI src, MMEUES1APID dst) {
+        if (src != null && dst != null) {
+            return xranStore.getLink(src, dst);
+        }
+        return null;
+    }
+
+    public RnibLink get(ECGI src, CRNTI dst) {
+        MMEUES1APID mmeues1APID = crntiMme.get(dst);
+
+        if (mmeues1APID != null) {
+            return xranStore.getLink(src, mmeues1APID);
+        }
+        return null;
+    }
+
+    public boolean remove(ECGI src, MMEUES1APID dst) {
+        RnibLink link = xranStore.getLink(src, dst);
+
+        if (link != null) {
+            LinkId linkId = link.getLinkId();
+            if (linkId != null) {
+                return xranStore.removeLink(linkId);
+            }
+        }
+        return false;
+    }
+
+    public boolean remove(ECGI src, CRNTI dst) {
+        MMEUES1APID mmeues1APID = crntiMme.get(dst);
+
+        RnibLink link = xranStore.getLink(src, mmeues1APID);
+        if (link != null) {
+            LinkId linkId = link.getLinkId();
+            if (linkId != null) {
+                return xranStore.removeLink(linkId);
+            }
+        }
+        return false;
+    }
+
+    public ECGI getPrimaryCell(RnibUe ue) {
+        List<RnibLink> linksByUeId = xranStore.getLinksByUeId(ue.getMmeS1apId().longValue());
+        Optional<RnibLink> primary = linksByUeId.stream().filter(l -> l.getType().equals(RnibLink.Type.SERVING_PRIMARY)).findFirst();
+
+        if (primary.isPresent()) {
+            return primary.get().getLinkId().getSource();
+        }
+        return null;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/org.onosproject.xran/wrapper/UeMap.java b/src/main/java/org.onosproject.xran/wrapper/UeMap.java
new file mode 100644
index 0000000..a42ecbd
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/wrapper/UeMap.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.wrapper;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import io.netty.channel.ChannelHandlerContext;
+import org.onosproject.net.HostId;
+import org.onosproject.xran.XranStore;
+import org.onosproject.xran.codecs.api.CRNTI;
+import org.onosproject.xran.codecs.api.ENBUES1APID;
+import org.onosproject.xran.codecs.api.MMEUES1APID;
+import org.onosproject.xran.entities.RnibUe;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+public class UeMap {
+    private BiMap<CRNTI, MMEUES1APID> crntUe = HashBiMap.create();
+
+    private XranStore xranStore;
+
+    public UeMap(XranStore xranStore) {
+        this.xranStore = xranStore;
+    }
+
+    public void put(RnibUe ue) {
+
+        MMEUES1APID mmeS1apId = ue.getMmeS1apId();
+        if (mmeS1apId != null) {
+            xranStore.storeUe(ue);
+        }
+
+        CRNTI ranId = ue.getRanId();
+        if (ranId != null) {
+            crntUe.put(ranId, ue.getMmeS1apId());
+        }
+    }
+
+    public RnibUe get(CRNTI id) {
+        MMEUES1APID mme = crntUe.get(id);
+        if (mme != null) {
+            return xranStore.getUe(mme);
+        }
+        return null;
+    }
+
+    public RnibUe get(MMEUES1APID mme) {
+        if (mme != null) {
+            return xranStore.getUe(mme);
+        }
+        return null;
+    }
+
+    public boolean remove(MMEUES1APID id) {
+        crntUe.inverse().remove(id);
+        return xranStore.removeUe(id);
+    }
+}
diff --git a/src/main/java/org.onosproject.xran/wrapper/package-info.java b/src/main/java/org.onosproject.xran/wrapper/package-info.java
new file mode 100644
index 0000000..c724c32
--- /dev/null
+++ b/src/main/java/org.onosproject.xran/wrapper/package-info.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2015-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xran.wrapper;
\ No newline at end of file
