Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

3 Way Handshake

Akihiro TAKASE edited this page Jun 23, 2021 · 3 revisions
  1. Receive SYN from 192.0.2.1:56988
  2. Send SYN+ACK to 192.0.2.1:56988
  3. Receive ACK from to 192.0.2.1:56988
[vagrant@ps app]$ ./bin/pstack server
12:50:30.777 [D] -------------------------------------------------------
                           I N I T I A L I Z E   D E V I C E S
                 -------------------------------------------------------
12:50:30.777 [D] device was registered
                 type: Loopback
                 name: net0 ()
                 addr: 00:00:00:00:00:00
12:50:30.777 [D] interface was attached
                 ip:     127.0.0.1
                 device: net0 ()
12:50:30.777 [D] route was registered
                 network:  127.0.0.0
                 netmask:  255.0.0.0
                 unicast:  127.0.0.1
                 next hop: 0.0.0.0
                 device:   net0 ()
12:50:30.777 [D] device was registered
                 type: Ethernet
                 name: net1 (tap0)
                 addr: 00:00:5e:00:53:01
12:50:30.777 [D] interface was attached
                 ip:     192.0.2.2
                 device: net1 (tap0)
12:50:30.777 [D] route was registered
                 network:  192.0.0.0
                 netmask:  255.255.255.0
                 unicast:  192.0.2.2
                 next hop: 0.0.0.0
                 device:   net1 (tap0)
12:50:30.777 [D] default gateway was registered
                 network:  0.0.0.0
                 netmask:  0.0.0.0
                 unicast:  192.0.2.2
                 next hop: 192.0.2.1
                 device:   net1 (tap0)
12:50:30.777 [D] -------------------------------------------------------
                               S T A R T   S E R V I C E S
                 -------------------------------------------------------
12:50:30.778 [D] arp service started
12:50:30.778 [D] ethernet service started
12:50:30.778 [D] icmp service started
12:50:30.778 [D] ip service started
12:50:30.778 [D] monitor service started
12:50:30.778 [D] device was opened
                 type: Loopback
                 name: net0 ()
12:50:30.778 [D] device was opened
                 type: Ethernet
                 name: net1 (tap0)
12:50:30.778 [D] tcp service started
12:50:30.781 [D] event occurred
                 events: 1
                 device: net1 (tap0)
12:50:30.878 [D] all service workers started
12:50:30.878 [D] ///////////////////////////////////////////////////////
                          A P P L I C A T I O N   S T A R T E D
                 ///////////////////////////////////////////////////////
12:50:30.878 [D] address and port assigned: addr = 192.0.2.2, port = 12345
12:50:31.574 [D] event occurred
                 events: 1
                 device: net1 (tap0)
12:50:40.548 [D] event occurred
                 events: 1
                 device: net1 (tap0)
12:50:40.548 [D] incoming ethernet frame (42 bytes)
                 type:    ARP (0x0806)
                 dst:     ff:ff:ff:ff:ff:ff
                 src:     e2:20:76:2d:5d:2d
                 payload: 00 01 08 00 06 04 00 01 e2 20 76 2d 5d 2d c0 00 02 01 00 00
                          00 00 00 00 c0 00 02 02
12:50:40.548 [D] incoming arp packet
                 hardware type:           Ethernet (10Mb)
                 protocol Type:           IPv4
                 hardware address length: 6
                 protocol address length: 4
                 opcode:                  REQUEST (1)
                 sender hardware address: e2:20:76:2d:5d:2d
                 sender protocol address: 192.0.2.1
                 target hardware address: 00:00:00:00:00:00
                 target protocol address: 192.0.2.2
12:50:40.548 [D] outgoing arp packet
                 hardware type:           Ethernet (10Mb)
                 protocol Type:           IPv4
                 hardware address length: 6
                 protocol address length: 4
                 opcode:                  REPLY (2)
                 sender hardware address: 00:00:5e:00:53:01
                 sender protocol address: 192.0.2.2
                 target hardware address: e2:20:76:2d:5d:2d
                 target protocol address: 192.0.2.1
12:50:40.548 [D] outgoing ethernet frame (42 bytes)
                 type:    ARP (0x0806)
                 dst:     e2:20:76:2d:5d:2d
                 src:     00:00:5e:00:53:01
                 payload: 00 01 08 00 06 04 00 02 00 00 5e 00 53 01 c0 00 02 02 e2 20
                          76 2d 5d 2d c0 00 02 01 00 00 00 00 00 00 00 00 00 00 00 00
                          00 00 00 00 00 00
12:50:40.549 [D] event occurred
                 events: 1
                 device: net1 (tap0)
12:50:40.549 [D] incoming ethernet frame (74 bytes)
                 type:    IPv4 (0x0800)
                 dst:     00:00:5e:00:53:01
                 src:     e2:20:76:2d:5d:2d
                 payload: 45 00 00 3c e7 cc 40 00 40 06 ce eb c0 00 02 01 c0 00 02 02
                          de 9c 30 39 40 89 4c 6c 00 00 00 00 a0 02 fa f0 13 bf 00 00
                          02 04 05 b4 04 02 08 0a 54 08 c5 78 00 00 00 00 01 03 03 07
12:50:40.550 [D] incoming ip packet
                 version:             4
                 ihl:                 5
                 precedence:          Routine (0x0)
                 delay:               Normal (0x0)
                 throughput:          Normal (0x0)
                 relibility:          Normal (0x0)
                 total length:        60 bytes (data: 40 bytes)
                 id:                  59340
                 flag (df):           Don't Fragment (0x1)
                 flag (mf):           Last Fragment (0x0)
                 fragment offset:     0
                 ttl:                 64
                 protocol:            TCP (6)
                 checksum:            0xceeb
                 source address:      192.0.2.1
                 destination address: 192.0.2.2
                 data:                de 9c 30 39 40 89 4c 6c 00 00 00 00 a0 02 fa f0 13 bf 00 00
                                      02 04 05 b4 04 02 08 0a 54 08 c5 78 00 00 00 00 01 03 03 07
12:50:40.550 [D] incoming tcp segment
                 src port: 56988
                 dst port: 12345
                 Seq:      1082739820
                 ack:      0
                 offset:   10
                 flag:     -------S- (0x002)
                 window:   64240
                 checksum: 0x13bf
                 urg:      0
                 data:     -
12:50:40.550 [D] outgoing tcp segment
                 src port: 12345
                 dst port: 56988
                 Seq:      787382753
                 ack:      1082739821
                 offset:   5
                 flag:     ----A--S- (0x012)
                 window:   65535
                 checksum: 0xdf32
                 urg:      0
                 data:     -
12:50:40.550 [D] outgoing ip packet
                 version:             4
                 ihl:                 5
                 precedence:          Routine (0x0)
                 delay:               Normal (0x0)
                 throughput:          Normal (0x0)
                 relibility:          Normal (0x0)
                 total length:        40 bytes (data: 20 bytes)
                 id:                  0
                 flag (df):           May Fragment (0x0)
                 flag (mf):           Last Fragment (0x0)
                 fragment offset:     0
                 ttl:                 255
                 protocol:            TCP (6)
                 checksum:            0x37cc
                 source address:      192.0.2.2
                 destination address: 192.0.2.1
                 data:                30 39 de 9c 2e ee 81 e1 40 89 4c 6d 50 12 ff ff df 32 00 00
12:50:40.550 [D] outgoing ethernet frame (54 bytes)
                 type:    IPv4 (0x0800)
                 dst:     e2:20:76:2d:5d:2d
                 src:     00:00:5e:00:53:01
                 payload: 45 00 00 28 00 00 00 00 ff 06 37 cc c0 00 02 02 c0 00 02 01
                          30 39 de 9c 2e ee 81 e1 40 89 4c 6d 50 12 ff ff df 32 00 00
                          00 00 00 00 00 00
12:50:40.551 [D] event occurred
                 events: 1
                 device: net1 (tap0)
12:50:40.551 [D] incoming ethernet frame (54 bytes)
                 type:    IPv4 (0x0800)
                 dst:     00:00:5e:00:53:01
                 src:     e2:20:76:2d:5d:2d
                 payload: 45 00 00 28 e7 cd 40 00 40 06 ce fe c0 00 02 01 c0 00 02 02
                          de 9c 30 39 40 89 4c 6d 2e ee 81 e2 50 10 fa f0 e4 42 00 00
12:50:40.551 [D] incoming ip packet
                 version:             4
                 ihl:                 5
                 precedence:          Routine (0x0)
                 delay:               Normal (0x0)
                 throughput:          Normal (0x0)
                 relibility:          Normal (0x0)
                 total length:        40 bytes (data: 20 bytes)
                 id:                  59341
                 flag (df):           Don't Fragment (0x1)
                 flag (mf):           Last Fragment (0x0)
                 fragment offset:     0
                 ttl:                 64
                 protocol:            TCP (6)
                 checksum:            0xcefe
                 source address:      192.0.2.1
                 destination address: 192.0.2.2
                 data:                de 9c 30 39 40 89 4c 6d 2e ee 81 e2 50 10 fa f0 e4 42 00 00
12:50:40.551 [D] incoming tcp segment
                 src port: 56988
                 dst port: 12345
                 Seq:      1082739821
                 ack:      787382754
                 offset:   5
                 flag:     ----A---- (0x010)
                 window:   64240
                 checksum: 0xe442
                 urg:      0
                 data:     -
12:50:40.560 [I] connection accepted
                 Host: 192.0.2.1
                 Port: 56988
Clone this wiki locally