Presentation is loading. Please wait.

Presentation is loading. Please wait.

TA: Donghyun (David) Kim

Similar presentations


Presentation on theme: "TA: Donghyun (David) Kim"— Presentation transcript:

1 TA: Donghyun (David) Kim
Homework 1 Review TA: Donghyun (David) Kim

2 Overall Architecture Hybrid Peer-to-Peer System Server Client1 Client2

3 Server Description Server responsibility
Maintain the list of online-clients Server IP (IP-S) and Port Number (PORT-S) is known Get IP-S in running time Get PORT-S from input arguments Prepare a data structure to maintain a list of client information Client ID (ID-C), Client IP (IP-C), and Client Port Number (PORT-C)

4 Server Description – cont’
(IP-S, PORT-S) Server ID-C IP-C PORT-C 1 6000 2 UDP

5 Server Description – cont’
Waiting for messages from clients via UDP JOIN, ID-C, IP-C, PORT-C LEAVE, ID Assume no two messages arrives at the same time When membership is changed, send the updated list to the all of online-clients via UDP In practice, only change can be sent i.e. forward Join/leave message from a client to the other clients

6 Server Description – cont’
(IP-S, PORT-S) Server ID-C IP-C PORT-C 1 6000 2 UDP JOIN/LEAVE UPDATE on-line client list of

7 Client Architecture It is a peer (Client + Server)
Four user input arguments Client ID (ID-C), Port number of the client (PORT-C) ID-S, PORT-S Learn its own IP (IP-C) Two global variables Thread1 and Thread2 should share one Boolean flag which define their actions MODE: 1 or 2 A socket descriptor for the user to communicate with another client SOCKET: -1 (disconnected) or other value Assume no racing condition

8 Client Architecture – cont’
3 major threads (running at the same time) Thread1 Mode1: Handling user input and connecting to another client via TCP Mode2: Handling user input when connected Thread2 Mode1: Listening a connection request from another via TCP Mode2: Still, listening a connection request from another via TCP, but reject all other requests. Thread3 Send a JOIN message to the with (ID-C, IP-C, PORT-C) Listening a membership update from the server via UDP

9 Client Architecture – cont’
Thread1 Mode1: Handling user input and connecting to another client via TCP DISPLAY-LIST: display the up-to-date list of online-clients After a session is established, the connection can be terminated by typing “BYE” on any client CONNECT ID-C: try establishing a connect to the client with ID-C TERMINATE: terminate this client Mode2: Handling user input when connected Client Thread1 Thread2 Thread3

10 Example Server ID-C IP-C PORT-C (IP-S, PORT-S) UDP

11 Example Server Client1 ID-C IP-C PORT-C (IP-S, PORT-S) UDP
MODE: 1, SD: -1 Client1 JOIN (ID-C1, IP-C1, PORT-C1) Thread1 Thread2 TCP Thread3 UDP

12 Example Server Client1 Client2 ID-C IP-C PORT-C ID-C1 IP-C1 PORT-C1
(IP-S, PORT-S) UDP (IP-S, PORT-S ID-C2, IP-C2, PORT-C2) MODE: 1, SD: -1 MODE: 1, SD: -1 Client1 Client2 LIST{(ID-C1, IP-C1, PORT-C1)} Thread1 Thread1 Thread2 Thread2 TCP TCP Thread3 Thread3 UDP UDP

13 Example Server Client1 Client2 ID-C IP-C PORT-C ID-C1 IP-C1 PORT-C1
(IP-S, PORT-S) UDP (IP-S, PORT-S ID-C2, IP-C2, PORT-C2) MODE: 1, SD: -1 MODE: 1, SD: -1 Client1 Client2 JOIN (ID-C2, IP-C2, PORT-C2) Thread1 Thread1 Thread2 Thread2 TCP TCP Thread3 Thread3 UDP UDP

14 Example Server Client1 Client2 ID-C IP-C PORT-C ID-C1 IP-C1 PORT-C1
(IP-S, PORT-S) UDP LIST {(ID-C1, IP-C1, PORT-C1), (ID-C2, IP-C2, PORT-C2)} MODE: 1, SD: -1 MODE: 1, SD: -1 Client1 Client2 Thread1 Thread1 Thread2 Thread2 TCP TCP Thread3 Thread3 UDP UDP

15 Example Server Client1 Client2 ID-C IP-C PORT-C ID-C1 IP-C1 PORT-C1
(IP-S, PORT-S) UDP MODE: 1, SD: -1 MODE: 2, SD: 5 Client1 Client2 Thread1 CONNECT REQ(ID-C2) Thread1 TCP Thread2 Thread2 TCP TCP Thread3 Thread3 UDP UDP

16 Example Server Client1 Client2 ID-C IP-C PORT-C ID-C1 IP-C1 PORT-C1
(IP-S, PORT-S) UDP MODE: 2, SD: 3 MODE: 2, SD: 5 Client1 Client2 Thread1 Thread1 TCP TCP Thread2 Thread2 TCP TCP Thread3 Thread3 UDP UDP

17 Example Server Client1 Client2 ID-C IP-C PORT-C ID-C1 IP-C1 PORT-C1
(IP-S, PORT-S) UDP MODE: 2, SD: 3 MODE: 2, SD: 5 Client1 Client2 BYE Thread1 Thread1 TCP TCP Thread2 Thread2 TCP TCP Thread3 Thread3 UDP UDP

18 Example Server Client1 Client2 ID-C IP-C PORT-C ID-C1 IP-C1 PORT-C1
(IP-S, PORT-S) UDP MODE: 1, SD: -1 MODE: 1, SD: -1 Client1 Client2 Thread1 Thread1 Thread2 Thread2 TCP TCP Thread3 Thread3 UDP UDP

19 Example Server Client1 Client2 ID-C IP-C PORT-C ID-C1 IP-C1 PORT-C1
(IP-S, PORT-S) UDP MODE: 1, SD: -1 MODE: 1, SD: -1 LEAVE (ID-C1) Client1 Client2 Thread1 Thread1 Thread2 Thread2 TCP TCP Thread3 Thread3 UDP UDP

20 Example Server Client2 ID-C IP-C PORT-C ID-C2 IP-C2 PORT-C2
(IP-S, PORT-S) UDP LIST {(ID-C2, IP-C2, PORT-C2)} MODE: 1, SD: -1 Client2 Thread1 Thread2 TCP Thread3 UDP


Download ppt "TA: Donghyun (David) Kim"

Similar presentations


Ads by Google