用wireshark截取的TCP 数据包,大神给分析一些原因

AOAO 2012-12-06 05:11:46
如下图:


图中蓝色标记的包与之后一个包延迟很大,到了1.8s,并且其长度为0。
有大神给分一下什么原因吧?
给跪了!
...全文
777 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
oyljerry 2012-12-06
  • 打赏
  • 举报
回复
是否有防火墙,杀毒软件等干扰
AOAO 2012-12-06
  • 打赏
  • 举报
回复
我把主要代码贴一下: 发送端: 接收端:
UINT SendRecvProc(LPVOID lparam)
{

	RECVPARAM *pRecvData=(RECVPARAM *)lparam;
	CClientApp* pThis = (CClientApp*)pRecvData->pVoid;
	
	//AfxSocketInit(NULL);
	CSocket *sockClient = new CSocket;
	sockClient->Create();
	// if socket error
	if( sockClient->m_hSocket==INVALID_SOCKET)
	{
		return 0;
	}
	sockClient->Connect( pThis->m_strName, pThis->m_port+10 );	
	// if error
	if( sockClient->m_hSocket==INVALID_SOCKET)
	{
		return 0;
	}

	CSocketFile *m_socketFile=new CSocketFile(sockClient);
	CArchive *m_Write=new CArchive(m_socketFile,CArchive::store); // write the data into the string
	CString sendContent;
	
	
	// send the command that capture the image from the screen.
	pThis->m_pMainWnd->SendMessage(WM_COMMAND, ID_CAPTURE_FROM_SCREEN, 0);


	// Process the original image with none white area
	// pThis->pD1->CutWhiteArea();

	// if zoom
	if(pThis->Ratio!=1) pThis->pD1->RatioZoomin( pThis->Ratio );

	// 
	int nWidth = pThis->pD1->Img_ori[0].size();     //pThis->bm.bmWidth;
	int nHeight = pThis->pD1->Img_ori.size();       //pThis->bm.bmHeight;
	fprintf(pThis->fin,"nWidth:%d nHeight:%d\n",nWidth,nHeight);
	CString str;
	str.Format("宽:%d,高:%d",nWidth,nHeight);
//	AfxMessageBox(str);
	
	sendContent = "";
	sendContent += '1';
	sendContent += 'I';
	sendContent += (char)(nWidth/256-128);
	sendContent += (char)(nWidth%256-128);
	sendContent += (char)(nHeight/256-128);
	sendContent += (char)(nHeight%256-128);
	
	// if error
	if( sockClient->m_hSocket==INVALID_SOCKET)
	{
		pThis->lock = false;
		return 0;
	}
	*m_Write<<sendContent;
	m_Write->Flush();
	
	
	if(0 == sizeofdata)
	{
		delete [] lpvBits;  
		lpvBits = NULL;
	}
*/

	for(int i=0;(i+0)<nHeight;i+=1)
	{
		sendContent = "";
		sendContent += '1';
		sendContent += 'P';
		sendContent += (char)(i/256-128);
		sendContent += (char)(i%256-128);
		sendContent += (char)1;
		int j;

		for( j=0;j<nWidth;j++)
		{
			sendContent +=  (char)(pThis->pD1->Img_ori[i][j]-128); //(char)(pD1->lpvBits[(i*nWidth+j)*4+0]-128);
		}
/

		// if error
		if( sockClient->m_hSocket==INVALID_SOCKET)
		{
			pThis->lock = false;
			return 0;
		}
		*m_Write<<sendContent;
		m_Write->Flush();		
	}

	pThis->Iscompute = 0; 


	pThis->pD1->PreImage = pThis->pD1->Img_ori;


	switch(pThis->Iscompute)
	{
		case 0:
			sendContent = "1E0";
			break;
		case 1:
			sendContent = "1E1";
			break;
		case 2:
			sendContent = "1E2";
			break;
		default:
			break;
	}
	// if error
//	AfxMessageBox(sendContent);
	if( sockClient->m_hSocket==INVALID_SOCKET)
	{
		pThis->lock = false;
		return 0;
	}
	*m_Write<<sendContent; 
	m_Write->Flush(); 

	//sockClient->AsyncSelect(0);
	//sockClient->Close();
	m_Write->Close();
	m_socketFile->Close();
	sockClient->Close();	

	delete m_Write;
	delete m_socketFile;
	delete sockClient;
	delete pRecvData;

	
	return 0;
	
}
接收端:
UINT SendRecvProc1(LPVOID lparam)
{
	RECVPARAM *pRecvData=(RECVPARAM *)lparam;
	CServerApp* pThis = (CServerApp*)pRecvData->pVoid;
	pThis->lock = true;
	CSocket sockSrvr; 
	sockSrvr.Create(pThis->m_port+10);  
	sockSrvr.Listen();  
	CSocket *sockConnection = new CSocket;
	sockSrvr.Accept(*sockConnection);  

	// 判断异常
	if( sockConnection->m_hSocket==INVALID_SOCKET)
	{
		pThis->lock = false;
		return 0;
	}

	CString data;

	CSocketFile *m_socketFile=new CSocketFile(sockConnection);
	CArchive *m_Read=new CArchive(m_socketFile,CArchive::load);//从套接字中读数据
	

// 第一部分,接收图像信息头
	do
	{
		*m_Read>>data;//从套接字中接收内容写入到content中
		if(data.GetLength()>=2 && data[0]=='1' && data[1]=='I')
		{
			break;
		}
	}while(1);
	
	// 获取宽和高
	pThis->pD->nWidth =  (data[2]+128)*256L+data[3]+128;
	pThis->pD->nHeight =  (data[4]+128)*256L+data[5]+128;
	
	//fprintf(fout,"[%d %d]\n",pThis->pD1->nWidth,pThis->pD1->nHeight);

	// BGR
	//BYTE* tmpBits = new BYTE[pThis->pD1->nWidth*pThis->pD1->nHeight*4];
	//pThis->pD1->Bits = new BYTE[pThis->pD1->nWidth*pThis->pD1->nHeight*4];
	

// 第二部分,接收图像矩阵信息
	for(int i=0;i<pThis->pD->nHeight;i++)
	{
		data = "";
		do
		{
			*m_Read>>data;
			if(data.GetLength()>=2 && data[0]=='1' && data[1]=='P')
			{
				break;
			}
		}while(1);

		int row = (data[2]+128)*256+data[3]+128;
		
	data = "";
// 第三部分,收尾
	do{
		*m_Read>>data;
		if(data.GetLength()>= 2&& data[0]=='1' && data[1]=='E')
		{
			break;
		}
	}while(1);	

	if (data[2]=='0') 
	{
		pThis->pD->stat = "有效图像";
		pThis->pD->Iscompute = true;
	}
	else if(data[2]=='1')
	{
		pThis->pD->stat = "重复图像,检测";
//		if (true==pThis->pD->Iscompute)
//		{
			pThis->pD->Iscompute = true;
//		}
	}
	else if(data[2]=='2')
	{
		pThis->pD->stat = "无效图像,不检测";
//		if (true==pThis->pD->Iscompute)
//		{
			pThis->pD->Iscompute = false;
//		}
	}

	
	//sockConnection->AsyncSelect(0);
	//sockConnection->Close();
	m_Read->Close();
	m_socketFile->Close();
	sockConnection->Close();
	sockSrvr.Close();

	delete m_Read;
	delete m_socketFile;
	delete sockConnection;
	delete pRecvData;
	

	pThis->m_pMainWnd->SendMessage(WM_COMMAND, WM_MY_MESSAGE1, 0);//Doc->Resultis()


	// pThis->lock = false;
	// AfxEndThread(0);
	return 0;	
}
AOAO 2012-12-06
  • 打赏
  • 举报
回复
引用 2 楼 tiger9991 的回复:
1.网络问题,网络不通畅。 2.网线松动。 光抓包只能看流程。其他内因看不出来的。
局域网网络还不通常吗?
oyljerry 2012-12-06
  • 打赏
  • 举报
回复
网络程序有阻塞延时? 或网络环境,都需要分析一下
看不见的裂痕 2012-12-06
  • 打赏
  • 举报
回复
1.网络问题,网络不通畅。 2.网线松动。 光抓包只能看流程。其他内因看不出来的。
AOAO 2012-12-06
  • 打赏
  • 举报
回复

18,363

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧