Skip to content

Commit

Permalink
PDU Session Establishment improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
aligungr committed Sep 7, 2020
1 parent 4612702 commit 24588b3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,27 @@
import tr.havelsan.ueransim.app.api.sys.Simulation;
import tr.havelsan.ueransim.app.core.GnbSimContext;
import tr.havelsan.ueransim.app.events.ue.UeDownlinkNasEvent;
import tr.havelsan.ueransim.app.structs.PduSessionResource;
import tr.havelsan.ueransim.app.utils.Debugging;
import tr.havelsan.ueransim.ngap0.NgapDataUnitType;
import tr.havelsan.ueransim.ngap0.NgapEncoding;
import tr.havelsan.ueransim.ngap0.core.NGAP_OctetString;
import tr.havelsan.ueransim.ngap0.ies.bit_strings.NGAP_TransportLayerAddress;
import tr.havelsan.ueransim.ngap0.ies.choices.NGAP_Cause;
import tr.havelsan.ueransim.ngap0.ies.choices.NGAP_UPTransportLayerInformation;
import tr.havelsan.ueransim.ngap0.ies.choices.NGAP_UP_TNLInformation;
import tr.havelsan.ueransim.ngap0.ies.enumerations.NGAP_CauseMisc;
import tr.havelsan.ueransim.ngap0.ies.enumerations.NGAP_DataForwardingNotPossible;
import tr.havelsan.ueransim.ngap0.ies.enumerations.NGAP_PDUSessionType;
import tr.havelsan.ueransim.ngap0.ies.integers.NGAP_NetworkInstance;
import tr.havelsan.ueransim.ngap0.ies.octet_strings.NGAP_GTP_TEID;
import tr.havelsan.ueransim.ngap0.ies.octet_strings.NGAP_NAS_PDU;
import tr.havelsan.ueransim.ngap0.ies.sequence_ofs.NGAP_PDUSessionResourceFailedToSetupListSURes;
import tr.havelsan.ueransim.ngap0.ies.sequence_ofs.NGAP_PDUSessionResourceSetupListSUReq;
import tr.havelsan.ueransim.ngap0.ies.sequence_ofs.NGAP_PDUSessionResourceSetupListSURes;
import tr.havelsan.ueransim.ngap0.ies.sequence_ofs.NGAP_QosFlowSetupRequestList;
import tr.havelsan.ueransim.ngap0.ies.sequence_ofs.*;
import tr.havelsan.ueransim.ngap0.ies.sequences.*;
import tr.havelsan.ueransim.ngap0.msg.NGAP_PDUSessionResourceSetupRequest;
import tr.havelsan.ueransim.ngap0.msg.NGAP_PDUSessionResourceSetupResponse;
import tr.havelsan.ueransim.app.structs.PduSessionResource;
import tr.havelsan.ueransim.app.utils.Debugging;
import tr.havelsan.ueransim.utils.Tag;
import tr.havelsan.ueransim.utils.Utils;
import tr.havelsan.ueransim.utils.console.Logging;

public class NgapPduSessionManagement {
Expand Down Expand Up @@ -105,11 +107,24 @@ public static void receiveResourceSetupRequest(GnbSimContext ctx, NGAP_PDUSessio
}

var tr = new NGAP_PDUSessionResourceSetupResponseTransfer();
tr.qosFlowPerTNLInformation = new NGAP_QosFlowPerTNLInformation();
tr.qosFlowPerTNLInformation.associatedQosFlowList = new NGAP_AssociatedQosFlowList();

for (var qosFlow : resource.qosFlows) {
var associatedQosFlowItem = new NGAP_AssociatedQosFlowItem();
associatedQosFlowItem.qosFlowIdentifier = qosFlow.qosFlowIdentifier;

tr.qosFlowPerTNLInformation.associatedQosFlowList.list.add(associatedQosFlowItem);
}

tr.qosFlowPerTNLInformation.uPTransportLayerInformation = new NGAP_UPTransportLayerInformation();
tr.qosFlowPerTNLInformation.uPTransportLayerInformation.gTPTunnel = new NGAP_GTPTunnel();
tr.qosFlowPerTNLInformation.uPTransportLayerInformation.gTPTunnel.gTP_TEID = new NGAP_GTP_TEID("00000001"); // TODO
tr.qosFlowPerTNLInformation.uPTransportLayerInformation.gTPTunnel.transportLayerAddress = new NGAP_TransportLayerAddress(Utils.getLocalAddress());

var res = new NGAP_PDUSessionResourceSetupItemSURes();
res.pDUSessionID = item.pDUSessionID;
res.pDUSessionResourceSetupResponseTransfer = new NGAP_OctetString(NgapEncoding.encodeAper(tr, NgapDataUnitType.PDUSessionResourceSetupRequestTransfer));
res.pDUSessionResourceSetupResponseTransfer = new NGAP_OctetString(NgapEncoding.encodeAper(tr, NgapDataUnitType.PDUSessionResourceSetupResponseTransfer));
successList.list.add(res);
} else {
var tr = new NGAP_PDUSessionResourceSetupUnsuccessfulTransfer();
Expand Down Expand Up @@ -139,6 +154,8 @@ public static void receiveResourceSetupRequest(GnbSimContext ctx, NGAP_PDUSessio

GNodeB.sendNgapUeAssociated(ctx, associatedUe.ueCtxId, response);

Logging.success(Tag.PROCEDURE_RESULT, "PDU Session Establishment is successful");

Logging.funcOut();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public class RrcPduSessionManagement {

// todo
public static boolean pduResourceSetup(GnbSimContext ctx, GnbUeContext ueCtx, PduSessionResource resource) {
return false;
return true;
}
}
13 changes: 13 additions & 0 deletions utils/src/main/java/tr/havelsan/ueransim/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import java.io.*;
import java.lang.reflect.Array;
import java.lang.reflect.Modifier;
import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.Function;
Expand Down Expand Up @@ -510,4 +512,15 @@ public static OctetString insertLeadingLength4(OctetString octetString, boolean
res[3] = new Octet(length & 0xFF);
return new OctetString(res);
}

/**
* Returns the IPv4 address of the local host
*/
public static byte[] getLocalAddress() {
try {
return Inet4Address.getLocalHost().getAddress();
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
}
}

0 comments on commit 24588b3

Please sign in to comment.