saamonumai / yds202011

The presentation reference of YDS 2020/11.
0 stars 0 forks source link

Markdown and PlantUML #1

Open saamonumai opened 3 years ago

saamonumai commented 3 years ago

What is Three way hand shake

3ウェイ・ハンドシェイク (スリーウェイハンドシェイク, three-way handshaking) とは、TCP などにおいて使用されている、接続(コネクション)を確立するための手順。

Overview

次の 3 ステップによって構成される。

  1. 通信の要求者が相手に対して SYN パケットを送信する。
  2. SYN パケットを受けとった通信相手は、その要求者の接続を許可する SYN ACK パケットを送信する。同時に通信相手は接続を準備するために、その要求者との 接続用の情報を記憶する領域を割り当てる。要求者へ回答する際の確認応答番号(ACK番号)は、受信したシーケンス番号(順序番号)に1を加えた値になる。
  3. SYN ACK パケットを受けとった要求者は、接続開始をあらわす ACK パケットを送信し、通信相手との通信を開始する。通信相手に送信する確認応答番号(ACK番号)は受信した確認応答番号(ACK番号)に1を加えた値になる。

TCP が 3 ウェイ・ハンドシェイクを行うので TCP を使用する通信においては 3 ウェイ・ハンドシェイクを行う必要はない。 しかし、UDP においては 3 ウェイ・ハンドシェイクがおこなわれないため、UDP を使用する上位のプロトコルである SIP などにおいても 3 ウェイ・ハンドシェイクが行われる。 SIP において上記の SYN、SYN ACK、ACK に対応するメッセージが INVITE、200 OK、ACK である。 SYNはSynchronizeの略であり、ACKはAcknowledgeの略である。

Diagram of Three way hand shake

@startuml
Client -> Server: 1. 接続してもいい? / Can I connect?
Server --> Client: 2. OK!こちらからも接続するよ!
Client -> Server: 3. OK!
@enduml
saamonumai commented 3 years ago

ユーザー情報管理API設計

[POST] Create user API

URI

/api/users/

Request information

Data

Key Type Require Example Description
name String * Taro Yamagata ユーザーの名前
note String Employee of HogeHoge 説明。任意。
mail String * taro.yamagata@example.com メールアドレス
birthday String (date time) * 1990/01/01 誕生日

Data example

{
    "name": "Taro Yamagata",
    "note": "Employee of HogeHoge.inc",
    "mail": "taro.yamagata@example.com",
    "birthday": "1990/01/01"
}

Response

Status code

201

Body example

{
    "id": 1,
    "name": "Taro Yamagata",
    "note": "Employee of HogeHoge.inc",
    "mail": "taro.yamagata@example.com",
    "birthday": "1990/01/01"
}

Error code

502

Backend authentication server may be down.

[GET] Get user list API

URI

/api/users/

Request information

None

Response

Body example

[

    {
        "id": 1,
        "name": "Taro Yamagata"
    },
    {
        "id": 2,
        "name": "Mieko Yoshimura"
    }
]

[GET] Get user detail API

URI

/api/users/{id}/

Request information

URI parameter

id: ID of target user

Response

Body example

{
    "name": "Taro Yamagata",
    "note": "Employee of HogeHoge.inc",
    "mail": "taro.yamagata@example.com",
    "birthday": "1990/01/01"
}