栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

[计算机网络] 三次握手四次挥手

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

[计算机网络] 三次握手四次挥手

问题

主机A向主机B连续发送了两个TCP报文段,其序号分别是70和100。
试问:
(1)第一个报文段携带了多少字节的数据?
(2)主机B收到第一个报文段后发回的确认中的确认号应当是多少?
(3)如果B收到第二个报文段后发回的确认中的确认号是180,试问A发送 的第二个报文段中的数据有多少字节?
(4)如果A发送的第一个报文段丢失了,但第二个报文段到达了B。B在第二 个报文段到达后向A发送确认。试问这个确认号应为多少?

解析 :

  1. 第一个报文段的数据序号是 70 − 99 70-99 70−99,共 30 30 30字节数据

  2. B B B期望收到下一个报文段的第一个数据字节的序号是 100 100 100,则确认号是 100 100 100

  3. 如果第二个报文段中的数据中的字节数是 180 180 180,那么第二个报文段的数据有 180 − 100 = 80 180-100=80 180−100=80字节

  4. B在第二个报文段到达后向 A A A发送确认,其确认号为 70 70 70

    凑篇幅

// Problem: C - ±1 Operation 1
// Contest: AtCoder - Aising Programming Contest 2022(AtCoder Beginner Contest 255)
// URL: https://atcoder.jp/contests/abc255/tasks/abc255_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
#define IOS  ios::sync_with_stdio(false);
#define CIT  cin.tie(0);
#define COT  cout.tie(0);

#define ll long long
#define x first
#define y second
#define pb push_back
#define endl 'n'
#define all(x) (x).begin(),x.end()
#define Fup(i,a,b) for(int i=a;i<=b;i++)
#define Fde(i,a,b) for(int i=a;i>=b;i--)
#define cer(a) cerr<<#a<<'='<<(a)<<" @ line "<<__LINE__<<" "<,greater>  Pri_m;
typedef pair pii;
typedef vector VI;
map mp;
const int N = 2e5+10,INF = 0x3f3f3f3f;
const double eps = 1e-5;


struct node{
    int to,val;
};


ll x,a,d,n;

void solve(){
	cin>>x>>a>>d>>n;
	
	ll _an = a + (n-1) * d;
	
	if(d < 0 ){
		swap(_an,a);
		d = -d;
	}
	
	if(x > _an) cout<
		if(!d) cout<<0<
			ll t = (x - a)%d;
			cout<
    //int t;cin>>t;while(t--)
    solve();
    return 0 ;
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/991800.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号