diff --git a/internal/pkg/adaptercore/device_handler.go b/internal/pkg/adaptercore/device_handler.go
new file mode 100644
index 0000000..628e2e5
--- /dev/null
+++ b/internal/pkg/adaptercore/device_handler.go
@@ -0,0 +1,335 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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 adaptercore
+
+import (
+	"context"
+	"fmt"
+	"github.com/gogo/protobuf/proto"
+	com "github.com/opencord/voltha-go/adapters/common"
+	"github.com/opencord/voltha-go/common/log"
+	ic "github.com/opencord/voltha-protos/go/inter_container"
+	of "github.com/opencord/voltha-protos/go/openflow_13"
+	"github.com/opencord/voltha-protos/go/voltha"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+// A set of pm names to create the initial pm config.  This is used only for testing in this simulated adapter
+var pmNames = []string{
+	"tx_64_pkts",
+	"tx_65_127_pkts",
+	"tx_128_255_pkts",
+	"tx_256_511_pkts",
+	"tx_512_1023_pkts",
+	"tx_1024_1518_pkts",
+	"tx_1519_9k_pkts",
+	"rx_64_pkts",
+	"rx_65_127_pkts",
+	"rx_128_255_pkts",
+	"rx_256_511_pkts",
+	"rx_512_1023_pkts",
+	"rx_1024_1518_pkts",
+	"rx_1519_9k_pkts",
+}
+
+//DeviceHandler follows the same patterns as ponsim_olt.  The only difference is that it does not
+// interact with an OLT device.
+type DeviceHandler struct {
+	deviceId     string
+	deviceType   string
+	device       *voltha.Device
+	coreProxy    *com.CoreProxy
+	simulatedOLT *SimulatedOLT
+	nniPort      *voltha.Port
+	ponPort      *voltha.Port
+	exitChannel  chan int
+	lockDevice   sync.RWMutex
+	metrics      *com.PmMetrics
+}
+
+//NewDeviceHandler creates a new device handler
+func NewDeviceHandler(cp *com.CoreProxy, device *voltha.Device, adapter *SimulatedOLT) *DeviceHandler {
+	var dh DeviceHandler
+	dh.coreProxy = cp
+	cloned := (proto.Clone(device)).(*voltha.Device)
+	dh.deviceId = cloned.Id
+	dh.deviceType = cloned.Type
+	dh.device = cloned
+	dh.simulatedOLT = adapter
+	dh.exitChannel = make(chan int, 1)
+	dh.lockDevice = sync.RWMutex{}
+	// Set up PON metrics
+	dh.metrics = com.NewPmMetrics(
+		cloned.Id,
+		com.Frequency(150),
+		com.Grouped(false),
+		com.FrequencyOverride(false),
+		com.Metrics(pmNames),
+	)
+	return &dh
+}
+
+// start save the device to the data model
+func (dh *DeviceHandler) start(ctx context.Context) {
+	dh.lockDevice.Lock()
+	defer dh.lockDevice.Unlock()
+	log.Debugw("starting-device-agent", log.Fields{"device": dh.device})
+	// Add the initial device to the local model
+	log.Debug("device-agent-started")
+}
+
+// stop stops the device dh.  Not much to do for now
+func (dh *DeviceHandler) stop(ctx context.Context) {
+	dh.lockDevice.Lock()
+	defer dh.lockDevice.Unlock()
+	log.Debug("stopping-device-agent")
+	dh.exitChannel <- 1
+	log.Debug("device-agent-stopped")
+}
+
+func macAddressToUint32Array(mac string) []uint32 {
+	slist := strings.Split(mac, ":")
+	result := make([]uint32, len(slist))
+	var err error
+	var tmp int64
+	for index, val := range slist {
+		if tmp, err = strconv.ParseInt(val, 16, 32); err != nil {
+			return []uint32{1, 2, 3, 4, 5, 6}
+		}
+		result[index] = uint32(tmp)
+	}
+	return result
+}
+
+func (dh *DeviceHandler) AdoptDevice(device *voltha.Device) {
+	log.Debugw("AdoptDevice", log.Fields{"deviceId": device.Id})
+
+	//	Update the device info
+	cloned := proto.Clone(device).(*voltha.Device)
+	cloned.Root = true
+	cloned.Vendor = "simulators"
+	cloned.Model = "go-simulators"
+	cloned.SerialNumber = com.GetRandomSerialNumber()
+	cloned.MacAddress = strings.ToUpper(com.GetRandomMacAddress())
+
+	// Synchronous call to update device - this method is run in its own go routine
+	if err := dh.coreProxy.DeviceUpdate(nil, cloned); err != nil {
+		log.Errorw("error-updating-device", log.Fields{"deviceId": device.Id, "error": err})
+	}
+
+	// Now, set the initial PM configuration for that device
+	if err := dh.coreProxy.DevicePMConfigUpdate(nil, dh.metrics.ToPmConfigs()); err != nil {
+		log.Errorw("error-updating-PMs", log.Fields{"deviceId": device.Id, "error": err})
+	}
+
+	//	Now create the NNI Port
+	dh.nniPort = &voltha.Port{
+		PortNo:     2,
+		Label:      fmt.Sprintf("nni-%d", 2),
+		Type:       voltha.Port_ETHERNET_NNI,
+		OperStatus: voltha.OperStatus_ACTIVE,
+	}
+
+	// Synchronous call to update device - this method is run in its own go routine
+	if err := dh.coreProxy.PortCreated(nil, cloned.Id, dh.nniPort); err != nil {
+		log.Errorw("error-creating-nni-port", log.Fields{"deviceId": device.Id, "error": err})
+	}
+
+	//	Now create the PON Port
+	dh.ponPort = &voltha.Port{
+		PortNo:     1,
+		Label:      fmt.Sprintf("pon-%d", 1),
+		Type:       voltha.Port_PON_OLT,
+		OperStatus: voltha.OperStatus_ACTIVE,
+	}
+
+	// Synchronous call to update device - this method is run in its own go routine
+	if err := dh.coreProxy.PortCreated(nil, cloned.Id, dh.ponPort); err != nil {
+		log.Errorw("error-creating-nni-port", log.Fields{"deviceId": device.Id, "error": err})
+	}
+
+	cloned.ConnectStatus = voltha.ConnectStatus_REACHABLE
+	cloned.OperStatus = voltha.OperStatus_ACTIVE
+
+	dh.device = cloned
+	//dh.device.SerialNumber = cloned.SerialNumber
+
+	//	Update the device state
+	if err := dh.coreProxy.DeviceStateUpdate(nil, cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+		log.Errorw("error-creating-nni-port", log.Fields{"deviceId": device.Id, "error": err})
+	}
+
+	//	Register Child device
+	initialUniPortNo := 100
+	log.Debugw("registering-onus", log.Fields{"total": dh.simulatedOLT.numOnus})
+	for i := 0; i < dh.simulatedOLT.numOnus; i++ {
+		go dh.coreProxy.ChildDeviceDetected(
+			nil,
+			cloned.Id,
+			1,
+			"simulated_onu",
+			initialUniPortNo+i,
+			"simulated_onu",
+			com.GetRandomSerialNumber(),
+			int64(i))
+	}
+}
+
+func (dh *DeviceHandler) GetOfpDeviceInfo(device *voltha.Device) (*ic.SwitchCapability, error) {
+	return &ic.SwitchCapability{
+		Desc: &of.OfpDesc{
+			HwDesc:    "simulated_pon",
+			SwDesc:    "simulated_pon",
+			SerialNum: dh.device.SerialNumber,
+		},
+		SwitchFeatures: &of.OfpSwitchFeatures{
+			NBuffers: 256,
+			NTables:  2,
+			Capabilities: uint32(of.OfpCapabilities_OFPC_FLOW_STATS |
+				of.OfpCapabilities_OFPC_TABLE_STATS |
+				of.OfpCapabilities_OFPC_PORT_STATS |
+				of.OfpCapabilities_OFPC_GROUP_STATS),
+		},
+	}, nil
+}
+
+func (dh *DeviceHandler) GetOfpPortInfo(device *voltha.Device, portNo int64) (*ic.PortCapability, error) {
+	cap := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
+	return &ic.PortCapability{
+		Port: &voltha.LogicalPort{
+			OfpPort: &of.OfpPort{
+				HwAddr:     macAddressToUint32Array(dh.device.MacAddress),
+				Config:     0,
+				State:      uint32(of.OfpPortState_OFPPS_LIVE),
+				Curr:       cap,
+				Advertised: cap,
+				Peer:       cap,
+				CurrSpeed:  uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
+				MaxSpeed:   uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
+			},
+			DeviceId:     dh.device.Id,
+			DevicePortNo: uint32(portNo),
+		},
+	}, nil
+}
+
+func (dh *DeviceHandler) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
+	log.Debugw("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id})
+	return nil
+}
+
+func (dh *DeviceHandler) DisableDevice(device *voltha.Device) {
+	cloned := proto.Clone(device).(*voltha.Device)
+	// Update the all ports state on that device to disable
+	if err := dh.coreProxy.PortsStateUpdate(nil, cloned.Id, voltha.OperStatus_UNKNOWN); err != nil {
+		log.Errorw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+		return
+	}
+
+	//Update the device state
+	cloned.ConnectStatus = voltha.ConnectStatus_UNREACHABLE
+	cloned.OperStatus = voltha.OperStatus_UNKNOWN
+	dh.device = cloned
+
+	if err := dh.coreProxy.DeviceStateUpdate(nil, cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+		log.Errorw("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+		return
+	}
+
+	// Tell the Core that all child devices have been disabled (by default it's an action already taken by the Core
+	if err := dh.coreProxy.ChildDevicesLost(nil, cloned.Id); err != nil {
+		log.Errorw("lost-notif-of-child-devices-failed", log.Fields{"deviceId": device.Id, "error": err})
+		return
+	}
+
+	log.Debugw("DisableDevice-end", log.Fields{"deviceId": device.Id})
+}
+
+func (dh *DeviceHandler) ReEnableDevice(device *voltha.Device) {
+
+	cloned := proto.Clone(device).(*voltha.Device)
+	// Update the all ports state on that device to enable
+	if err := dh.coreProxy.PortsStateUpdate(nil, cloned.Id, voltha.OperStatus_ACTIVE); err != nil {
+		log.Errorw("updating-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+		return
+	}
+
+	//Update the device state
+	cloned.ConnectStatus = voltha.ConnectStatus_REACHABLE
+	cloned.OperStatus = voltha.OperStatus_ACTIVE
+	dh.device = cloned
+
+	if err := dh.coreProxy.DeviceStateUpdate(nil, cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+		log.Errorw("device-state-update-failed", log.Fields{"deviceId": device.Id, "error": err})
+		return
+	}
+
+	// Tell the Core that all child devices have been enabled
+	if err := dh.coreProxy.ChildDevicesDetected(nil, cloned.Id); err != nil {
+		log.Errorw("detection-notif-of-child-devices-failed", log.Fields{"deviceId": device.Id, "error": err})
+		return
+	}
+
+	log.Debugw("ReEnableDevice-end", log.Fields{"deviceId": device.Id})
+}
+
+func (dh *DeviceHandler) DeleteDevice(device *voltha.Device) {
+	cloned := proto.Clone(device).(*voltha.Device)
+	// Update the all ports state on that device to disable
+	if err := dh.coreProxy.DeleteAllPorts(nil, cloned.Id); err != nil {
+		log.Errorw("delete-ports-failed", log.Fields{"deviceId": device.Id, "error": err})
+		return
+	}
+
+	log.Debugw("DeleteDevice-end", log.Fields{"deviceId": device.Id})
+}
+
+func (dh *DeviceHandler) UpdateFlowsBulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, metadata *voltha.FlowMetadata) {
+	log.Debugw("UpdateFlowsBulk", log.Fields{"deviceId": device.Id, "flows": flows, "groups": groups})
+	// For now we do nothing with it
+	return
+}
+
+func (dh *DeviceHandler) UpdateFlowsIncremental(device *voltha.Device, flowChanges *of.FlowChanges, groupChanges *of.FlowGroupChanges, metadata *voltha.FlowMetadata) {
+	log.Debugw("UpdateFlowsIncremental", log.Fields{"deviceId": device.Id, "flowChanges": flowChanges, "groupChanges": groupChanges})
+	// For now we do nothing with it
+	return
+}
+
+func (dh *DeviceHandler) UpdatePmConfigs(device *voltha.Device, pmConfigs *voltha.PmConfigs) {
+	log.Debugw("UpdatePmConfigs", log.Fields{"deviceId": device.Id, "pmConfigs": pmConfigs})
+	// For now we do nothing with it
+	return
+}
+
+func (dh *DeviceHandler) ReconcileDevice(device *voltha.Device) {
+	// Update the device info
+	cloned := proto.Clone(device).(*voltha.Device)
+	cloned.ConnectStatus = voltha.ConnectStatus_REACHABLE
+	cloned.OperStatus = voltha.OperStatus_ACTIVE
+
+	dh.device = cloned
+
+	// Update the device state
+	if err := dh.coreProxy.DeviceStateUpdate(nil, cloned.Id, cloned.ConnectStatus, cloned.OperStatus); err != nil {
+		log.Errorw("error-creating-nni-port", log.Fields{"deviceId": device.Id, "error": err})
+	}
+
+	// Since we don't know how long we were down, let's reconcile the child devices
+	go dh.coreProxy.ReconcileChildDevices(nil, cloned.Id)
+}
diff --git a/internal/pkg/adaptercore/device_handler_test.go b/internal/pkg/adaptercore/device_handler_test.go
new file mode 100755
index 0000000..712a1ad
--- /dev/null
+++ b/internal/pkg/adaptercore/device_handler_test.go
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * 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 adaptercore
+
+import (
+	"github.com/stretchr/testify/assert"
+	"testing"
+)
+
+func TestMacAddressToUint32Array(t *testing.T) {
+	macArray := macAddressToUint32Array("12:34:56:78:90:AB")
+	assert.Equal(t, []uint32{0x12, 0x34, 0x56, 0x78, 0x90, 0xAB}, macArray)
+}
diff --git a/internal/pkg/adaptercore/simulated_olt.go b/internal/pkg/adaptercore/simulated_olt.go
new file mode 100644
index 0000000..29785c4
--- /dev/null
+++ b/internal/pkg/adaptercore/simulated_olt.go
@@ -0,0 +1,300 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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 adaptercore
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	com "github.com/opencord/voltha-go/adapters/common"
+	"github.com/opencord/voltha-go/common/log"
+	"github.com/opencord/voltha-go/kafka"
+	ic "github.com/opencord/voltha-protos/go/inter_container"
+	"github.com/opencord/voltha-protos/go/openflow_13"
+	"github.com/opencord/voltha-protos/go/voltha"
+	"sync"
+)
+
+type SimulatedOLT struct {
+	deviceHandlers        map[string]*DeviceHandler
+	coreProxy             *com.CoreProxy
+	kafkaICProxy          *kafka.InterContainerProxy
+	numOnus               int
+	exitChannel           chan int
+	lockDeviceHandlersMap sync.RWMutex
+}
+
+func NewSimulatedOLT(ctx context.Context, kafkaICProxy *kafka.InterContainerProxy, coreProxy *com.CoreProxy, onuNumber int) *SimulatedOLT {
+	var simulatedOLT SimulatedOLT
+	simulatedOLT.exitChannel = make(chan int, 1)
+	simulatedOLT.deviceHandlers = make(map[string]*DeviceHandler)
+	simulatedOLT.kafkaICProxy = kafkaICProxy
+	simulatedOLT.numOnus = onuNumber
+	simulatedOLT.coreProxy = coreProxy
+	simulatedOLT.lockDeviceHandlersMap = sync.RWMutex{}
+	return &simulatedOLT
+}
+
+func (so *SimulatedOLT) Start(ctx context.Context) error {
+	log.Info("starting-device-manager")
+	log.Info("device-manager-started")
+	return nil
+}
+
+func (so *SimulatedOLT) Stop(ctx context.Context) error {
+	log.Info("stopping-device-manager")
+	so.exitChannel <- 1
+	log.Info("device-manager-stopped")
+	return nil
+}
+
+func sendResponse(ctx context.Context, ch chan interface{}, result interface{}) {
+	if ctx.Err() == nil {
+		// Returned response only of the ctx has not been cancelled/timeout/etc
+		// Channel is automatically closed when a context is Done
+		ch <- result
+		log.Debugw("sendResponse", log.Fields{"result": result})
+	} else {
+		// Should the transaction be reverted back?
+		log.Debugw("sendResponse-context-error", log.Fields{"context-error": ctx.Err()})
+	}
+}
+
+func (so *SimulatedOLT) addDeviceHandlerToMap(agent *DeviceHandler) {
+	so.lockDeviceHandlersMap.Lock()
+	defer so.lockDeviceHandlersMap.Unlock()
+	if _, exist := so.deviceHandlers[agent.deviceId]; !exist {
+		so.deviceHandlers[agent.deviceId] = agent
+	}
+}
+
+func (so *SimulatedOLT) deleteDeviceHandlerToMap(agent *DeviceHandler) {
+	so.lockDeviceHandlersMap.Lock()
+	defer so.lockDeviceHandlersMap.Unlock()
+	delete(so.deviceHandlers, agent.deviceId)
+}
+
+func (so *SimulatedOLT) getDeviceHandler(deviceId string) *DeviceHandler {
+	so.lockDeviceHandlersMap.Lock()
+	defer so.lockDeviceHandlersMap.Unlock()
+	if agent, ok := so.deviceHandlers[deviceId]; ok {
+		return agent
+	}
+	return nil
+}
+
+func (so *SimulatedOLT) Adopt_device(device *voltha.Device) error {
+	if device == nil {
+		log.Warn("device-is-nil")
+		return errors.New("nil-device")
+	}
+	log.Infow("adopt-device", log.Fields{"deviceId": device.Id})
+	var handler *DeviceHandler
+	if handler = so.getDeviceHandler(device.Id); handler == nil {
+		handler := NewDeviceHandler(so.coreProxy, device, so)
+		so.addDeviceHandlerToMap(handler)
+		go handler.AdoptDevice(device)
+	}
+	return nil
+}
+
+func (so *SimulatedOLT) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
+	log.Infow("Get_ofp_device_info", log.Fields{"deviceId": device.Id})
+	if handler := so.getDeviceHandler(device.Id); handler != nil {
+		info, err := handler.GetOfpDeviceInfo(device)
+		log.Infow("Get_ofp_device_info-resp", log.Fields{"switch": info})
+		return info, err
+	}
+	log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id})
+	return nil, errors.New("device-handler-not-set")
+}
+
+func (so *SimulatedOLT) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+	log.Infow("Get_ofp_port_info", log.Fields{"deviceId": device.Id})
+	if handler := so.getDeviceHandler(device.Id); handler != nil {
+		return handler.GetOfpPortInfo(device, port_no)
+	}
+	log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id})
+	return nil, errors.New("device-handler-not-set")
+}
+
+func (so *SimulatedOLT) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
+	log.Infow("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id})
+	targetDevice := msg.Header.ProxyDeviceId // Request?
+	if targetDevice == "" && msg.Header.ToDeviceId != "" {
+		// Typical response
+		targetDevice = msg.Header.ToDeviceId
+	}
+	if handler := so.getDeviceHandler(targetDevice); handler != nil {
+		return handler.Process_inter_adapter_message(msg)
+	}
+	return errors.New(fmt.Sprintf("handler-not-found-%s", targetDevice))
+}
+
+func (so *SimulatedOLT) Adapter_descriptor() error {
+	return errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Device_types() (*voltha.DeviceTypes, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Health() (*voltha.HealthStatus, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Reconcile_device(device *voltha.Device) error {
+	if device == nil {
+		log.Warn("device-is-nil")
+		return errors.New("nil-device")
+	}
+	log.Infow("reconcile-device", log.Fields{"deviceId": device.Id})
+	var handler *DeviceHandler
+	handler = so.getDeviceHandler(device.Id)
+	if handler == nil {
+		//	Adapter has restarted
+		handler = NewDeviceHandler(so.coreProxy, device, so)
+		so.addDeviceHandlerToMap(handler)
+	}
+	go handler.ReconcileDevice(device)
+	return nil
+}
+
+func (so *SimulatedOLT) Abandon_device(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Disable_device(device *voltha.Device) error {
+	if device == nil {
+		log.Warn("device-is-nil")
+		return errors.New("nil-device")
+	}
+	log.Infow("disable-device", log.Fields{"deviceId": device.Id})
+	var handler *DeviceHandler
+	if handler = so.getDeviceHandler(device.Id); handler != nil {
+		go handler.DisableDevice(device)
+	}
+	return nil
+}
+
+func (so *SimulatedOLT) Reenable_device(device *voltha.Device) error {
+	if device == nil {
+		log.Warn("device-is-nil")
+		return errors.New("nil-device")
+	}
+	log.Infow("reenable-device", log.Fields{"deviceId": device.Id})
+	var handler *DeviceHandler
+	if handler = so.getDeviceHandler(device.Id); handler != nil {
+		go handler.ReEnableDevice(device)
+	}
+	return nil
+}
+
+func (so *SimulatedOLT) Reboot_device(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Self_test_device(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Delete_device(device *voltha.Device) error {
+	if device == nil {
+		log.Warn("device-is-nil")
+		return errors.New("nil-device")
+	}
+	log.Infow("delete-device", log.Fields{"deviceId": device.Id})
+	var handler *DeviceHandler
+	if handler = so.getDeviceHandler(device.Id); handler != nil {
+		go handler.DeleteDevice(device)
+	}
+	return nil
+}
+
+func (so *SimulatedOLT) Get_device_details(device *voltha.Device) error {
+	return errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, metadata *voltha.FlowMetadata) error {
+	if device == nil {
+		log.Warn("device-is-nil")
+		return errors.New("nil-device")
+	}
+	log.Debugw("bulk-flow-updates", log.Fields{"deviceId": device.Id, "flows": flows, "groups": groups})
+	var handler *DeviceHandler
+	if handler = so.getDeviceHandler(device.Id); handler != nil {
+		go handler.UpdateFlowsBulk(device, flows, groups, metadata)
+	}
+	return nil
+}
+
+func (so *SimulatedOLT) Update_flows_incrementally(device *voltha.Device, flowChanges *openflow_13.FlowChanges, groupChanges *openflow_13.FlowGroupChanges, metadata *voltha.FlowMetadata) error {
+	if device == nil {
+		log.Warn("device-is-nil")
+		return errors.New("nil-device")
+	}
+	log.Debugw("incremental-flow-update", log.Fields{"deviceId": device.Id, "flowChanges": flowChanges, "groupChanges": groupChanges})
+	var handler *DeviceHandler
+	if handler = so.getDeviceHandler(device.Id); handler != nil {
+		go handler.UpdateFlowsIncremental(device, flowChanges, groupChanges, metadata)
+	}
+	return nil
+}
+
+func (so *SimulatedOLT) Update_pm_config(device *voltha.Device, pmConfigs *voltha.PmConfigs) error {
+	if device == nil {
+		log.Warn("device-is-nil")
+		return errors.New("nil-device")
+	}
+	log.Debugw("update_pm_config", log.Fields{"deviceId": device.Id, "pmConfigs": pmConfigs})
+	var handler *DeviceHandler
+	if handler = so.getDeviceHandler(device.Id); handler != nil {
+		go handler.UpdatePmConfigs(device, pmConfigs)
+	}
+	return nil
+}
+
+func (so *SimulatedOLT) Receive_packet_out(deviceId string, egress_port_no int, msg *openflow_13.OfpPacketOut) error {
+	return errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Suppress_alarm(filter *voltha.AlarmFilter) error {
+	return errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Unsuppress_alarm(filter *voltha.AlarmFilter) error {
+	return errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, errors.New("UnImplemented")
+}
+
+func (so *SimulatedOLT) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+	return nil, errors.New("UnImplemented")
+}
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
new file mode 100644
index 0000000..5cf0dc0
--- /dev/null
+++ b/internal/pkg/config/config.go
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * 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 config
+
+import (
+	"flag"
+	"fmt"
+	"github.com/opencord/voltha-go/common/log"
+	"os"
+)
+
+// Simulated OLT default constants
+const (
+	EtcdStoreName            = "etcd"
+	default_InstanceID       = "simulatedOlt001"
+	default_KafkaAdapterHost = "127.0.0.1"
+	default_KafkaAdapterPort = 9092
+	default_KafkaClusterHost = "127.0.0.1"
+	default_KafkaClusterPort = 9094
+	default_KVStoreType      = EtcdStoreName
+	default_KVStoreTimeout   = 5 //in seconds
+	default_KVStoreHost      = "127.0.0.1"
+	default_KVStorePort      = 2379 // Consul = 8500; Etcd = 2379
+	default_LogLevel         = 0
+	default_Banner           = false
+	default_Topic            = "simulated_olt"
+	default_CoreTopic        = "rwcore"
+	default_OnuNumber        = 1
+)
+
+// AdapterFlags represents the set of configurations used by the read-write adaptercore service
+type AdapterFlags struct {
+	// Command line parameters
+	InstanceID       string
+	KafkaAdapterHost string
+	KafkaAdapterPort int
+	KafkaClusterHost string
+	KafkaClusterPort int
+	KVStoreType      string
+	KVStoreTimeout   int // in seconds
+	KVStoreHost      string
+	KVStorePort      int
+	Topic            string
+	CoreTopic        string
+	LogLevel         int
+	OnuNumber        int
+	Banner           bool
+}
+
+func init() {
+	log.AddPackage(log.JSON, log.WarnLevel, nil)
+}
+
+// NewRWCoreFlags returns a new RWCore config
+func NewAdapterFlags() *AdapterFlags {
+	var adapterFlags = AdapterFlags{ // Default values
+		InstanceID:       default_InstanceID,
+		KafkaAdapterHost: default_KafkaAdapterHost,
+		KafkaAdapterPort: default_KafkaAdapterPort,
+		KafkaClusterHost: default_KafkaClusterHost,
+		KafkaClusterPort: default_KafkaClusterPort,
+		KVStoreType:      default_KVStoreType,
+		KVStoreTimeout:   default_KVStoreTimeout,
+		KVStoreHost:      default_KVStoreHost,
+		KVStorePort:      default_KVStorePort,
+		Topic:            default_Topic,
+		CoreTopic:        default_CoreTopic,
+		LogLevel:         default_LogLevel,
+		OnuNumber:        default_OnuNumber,
+		Banner:           default_Banner,
+	}
+	return &adapterFlags
+}
+
+// ParseCommandArguments parses the arguments when running read-write adaptercore service
+func (so *AdapterFlags) ParseCommandArguments() {
+
+	var help string
+
+	help = fmt.Sprintf("Kafka - Adapter messaging host")
+	flag.StringVar(&(so.KafkaAdapterHost), "kafka_adapter_host", default_KafkaAdapterHost, help)
+
+	help = fmt.Sprintf("Kafka - Adapter messaging port")
+	flag.IntVar(&(so.KafkaAdapterPort), "kafka_adapter_port", default_KafkaAdapterPort, help)
+
+	help = fmt.Sprintf("Kafka - Cluster messaging host")
+	flag.StringVar(&(so.KafkaClusterHost), "kafka_cluster_host", default_KafkaClusterHost, help)
+
+	help = fmt.Sprintf("Kafka - Cluster messaging port")
+	flag.IntVar(&(so.KafkaClusterPort), "kafka_cluster_port", default_KafkaClusterPort, help)
+
+	help = fmt.Sprintf("Simulated OLT topic")
+	flag.StringVar(&(so.Topic), "simulator_topic", default_Topic, help)
+
+	help = fmt.Sprintf("Core topic")
+	flag.StringVar(&(so.CoreTopic), "core_topic", default_CoreTopic, help)
+
+	help = fmt.Sprintf("KV store type")
+	flag.StringVar(&(so.KVStoreType), "kv_store_type", default_KVStoreType, help)
+
+	help = fmt.Sprintf("The default timeout when making a kv store request")
+	flag.IntVar(&(so.KVStoreTimeout), "kv_store_request_timeout", default_KVStoreTimeout, help)
+
+	help = fmt.Sprintf("KV store host")
+	flag.StringVar(&(so.KVStoreHost), "kv_store_host", default_KVStoreHost, help)
+
+	help = fmt.Sprintf("KV store port")
+	flag.IntVar(&(so.KVStorePort), "kv_store_port", default_KVStorePort, help)
+
+	help = fmt.Sprintf("Log level")
+	flag.IntVar(&(so.LogLevel), "log_level", default_LogLevel, help)
+
+	help = fmt.Sprintf("Number of ONUs")
+	flag.IntVar(&(so.OnuNumber), "onu_number", default_OnuNumber, help)
+
+	help = fmt.Sprintf("Show startup banner log lines")
+	flag.BoolVar(&so.Banner, "banner", default_Banner, help)
+
+	flag.Parse()
+
+	containerName := getContainerInfo()
+	if len(containerName) > 0 {
+		so.InstanceID = containerName
+	}
+
+}
+
+func getContainerInfo() string {
+	return os.Getenv("HOSTNAME")
+}
