/// <summary> /// 建立网元连接。 /// TODO LMT-B还会连接基站,这两个连接不一样,需要协调 /// </summary> /// <param name="ip"></param> /// <param name="neConfig"></param> public bool ConnectNetElement(string ip, NetElementConfig neConfig) { if (string.IsNullOrWhiteSpace(ip) || string.IsNullOrEmpty(ip) || null == neConfig) { throw new ArgumentNullException("ip is null or empty, or neConfig is null"); } if (HasLinkWithSameIp(ip)) { return(false); } NetElementLinkBase link = LinkFactory.CreateLink(neConfig.conType); _mapNetElementLinks[ip] = link; //此处只有udp协议的数据处理,后面增加其他类型的协议 SubscribeHelper.AddSubscribe($"udp-recv://{ip}:{CommonPort.AtpLinkPort}", OnLinkMsgFromBoard); link.Connect(neConfig); return(true); //TODO 启动定时器,超时后启动取消还是让前台手动取消?或者设定时间间隔,一直重试? }
public override bool SendTSwitchs(byte[] switchBytes, NetElementConfig netElementAddress) { MsgGtsm2GtsaDspTraceCtrlReq dspReq = new MsgGtsm2GtsaDspTraceCtrlReq() { header = { u8RemoteMode = GtsMsgType.CONNECT_DIRECT_MSG, u16SourceID = GtsMsgType.DEST_GTSM, u16Opcode = GtsMsgType.O_GTSMGTSA_DSPTRACE_CTRL_REQ, u16DestID = netElementAddress.Index }, u8Switch = 1 }; dspReq.header.u16Length = dspReq.ContentLen; SendPackets(SerializeHelper.SerializeStructToBytes(dspReq)); MsgGtsm2GtsaTraceCtrlReq req = new MsgGtsm2GtsaTraceCtrlReq() { header = { u8RemoteMode = GtsMsgType.CONNECT_DIRECT_MSG, u16SourceID = GtsMsgType.DEST_GTSM, u16Opcode = GtsMsgType.O_GTSMGTSA_TRACE_CTRL_REQ, u16DestID = netElementAddress.Index }, u8TraceControl = switchBytes }; req.header.u16Length = req.ContentLen; SendPackets(SerializeHelper.SerializeStructToBytes(req)); return(true); }
public override void Logon(NetElementConfig netElementAddress) { MsgGtsm2GtsaLogonReq logonReq = new MsgGtsm2GtsaLogonReq() { u16LinkId = NbLinkType.NB_DSAP_NO_OSP_DSP_PC_GTSA, u16Port = NbLinkType.NB_IP_PORT_NO_OSP_DSP_PC_GTSA, u32TraceDspIpAddr = NetActHelper.inet_addr(netElementAddress.TraceIp), u8MacAddr = NetActHelper.GetMacAddrByIp(netElementAddress.TraceIp), u8AgentSlot = netElementAddress.AgentSlot, header = { u8RemoteMode = GtsMsgType.CONNECT_DIRECT_MSG, u16SourceID = GtsMsgType.DEST_GTSM, u16Opcode = GtsMsgType.O_GTSMGTSA_LOGON_REQ, u16DestID = netElementAddress.Index } }; logonReq.header.u16Length = logonReq.ContentLen; SendPackets(SerializeHelper.SerializeStructToBytes(logonReq), true); base.Logon(netElementAddress); }
public override void Logon(NetElementConfig netElementAddress) { //登录请求 MsgGtsm2GtsaLogonReq logonReq = new MsgGtsm2GtsaLogonReq() { u16LinkId = NbLinkType.NB_DSAP_NO_OSP_DSP_PC_GTSA, u16Port = NbLinkType.NB_IP_PORT_NO_OSP_DSP_PC_GTSA, }; //建链请求 MsgGtsm2GtsaAddFlowReq addFlowReq = new MsgGtsm2GtsaAddFlowReq() { u32IpType = GtsMsgType.OM_GTS_IPV4, u16RackNo = 0xff, u16ProcId = 0xff, u16FrameNo = netElementAddress.FrameNo, u16SlotNo = netElementAddress.SlotNo, header = { u16Opcode = GtsMsgType.O_GTSMGTSA_ADDFLOW_REQ, } }; //TODO 只有建链通过后才能发送登录请求。这里需要同步处理。 //SendPackets(SerializeHelper.SerializeStructToBytes(addFlowReq)); }
/// <summary> /// 断开ATP的连接。虚函数,直连和非直连操作不一样 /// </summary> public virtual void Logoff(NetElementConfig netElementAddress) { State = LinkState.Disconnected; //取消保活定时器 _kaTimer?.Stop(); _kaTimer?.Dispose(); }
/// <summary> /// 连接网元。此处仅考虑ATP的连接 /// </summary> /// <param name="netElementAddress">网元配置信息</param> /// <param name="isRepeatConnect">是否重复连接</param> public void Connect(NetElementConfig netElementAddress, bool isRepeatConnect = true) { if (null == netElementAddress) { throw new ArgumentNullException("netElementAddress is null"); } //如果已经连接或者连接中,就不再处理 if (IsBreak) { _netElementConfig = netElementAddress; Logon(_netElementConfig); } }
public override void Logoff(NetElementConfig netElementAddress) { MsgGtsm2GtsaQuitInd logoffReq = new MsgGtsm2GtsaQuitInd() { header = { u8RemoteMode = GtsMsgType.CONNECT_DIRECT_MSG, u16SourceID = GtsMsgType.DEST_GTSM, u16Opcode = GtsMsgType.O_GTSMGTSA_QUIT_IND, u16DestID = netElementAddress.Index } }; logoffReq.header.u16Length = logoffReq.ContentLen; SendPackets(SerializeHelper.SerializeStructToBytes(logoffReq), false); base.Logoff(netElementAddress); }
/// <summary> /// 登录板卡。分为直连板卡登录和非直连板卡登录 /// 直连板卡很简单,只要构造报文即可 /// 非直连还需要通知建链等操作 /// </summary> public virtual void Logon(NetElementConfig netElementAddress) { State = LinkState.Connecting; }
/// <summary> /// 虚函数,发送消息跟踪控制开关。不同的链接方式有不同的处理,子类重载该函数 /// </summary> /// <param name="switchBytes">开关数组</param> /// <param name="netElementAddress">要处理的网元信息</param> /// <returns></returns> public virtual bool SendTSwitchs(byte[] switchBytes, NetElementConfig netElementAddress) { return(true); }