1 / 40

Practical Session 10

Practical Session 10. IP (Internet Protocol) Address TCP/IP Model DNS Ports Sockets TCP UDP Client-Server Model Text Transfer HTTP Protocol. Internet Protocol. What is protocol? נוהל, רשימת כללים לביצועה של פעילות מסוימת What is internet protocol?

wray
Download Presentation

Practical Session 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Practical Session 10 IP (Internet Protocol) Address TCP/IP Model DNS Ports Sockets TCP UDP Client-Server Model Text Transfer HTTP Protocol

  2. Internet Protocol • What is protocol? • נוהל, רשימת כללים לביצועה של פעילות מסוימת • What is internet protocol? • A protocol that details how data is sent and received over the internet network. • What is Internet? • It is a global system of interconnected computer networks. • The internet is basically a network of networks. • How a machine is identified? • Every machine wishes to connect to the Internet, receives an IP address. • IP address is a unique identifier for the machine.

  3. What about Israel?

  4. Bezeq InternationalLine

  5. Tamares Internet Line

  6. IP Address • IPv4: • 32bit of size • Format: XXX.XXX.XXX.XXX • Where XXX is a number from 0 to 255 • Each block is 8bit. • Allows 232 unique addresses (≈ 4.3billion addresses). • Examples: • 192.115.80.66 – IP address of ynet • 209.85.147.147 – IP address of google • 132.72.41.239 – IP address of www.cs.bgu.ac.il • IPv6: • 128bit of size • Format: • XXXX.XXXX.XXXX.XXXX.XXXX.XXXX.XXXX.XXXX • Where each XXXX consist of a hexadecimal value. 0…9, A..F • Examples: • 2001:4860:0000:1001:0000:0000:0000:0068:– IPv6 of ipv6.google.com • 2620:0000:1CFE:FACE:B00C:0000:0000:0003 – IPv6 of www.v6.facebook.com • Allows 2128 unique addresses.

  7. IP Addresses Utilization

  8. Domain Name System • DNS: Domain Name System • DNS maps domain names to IPs. • Example: • Domain name: www.cs.bgu.ac.il • IP: 132.72.41.239 • Why DNS? • Machines understand numbers only. • Humans find it hard to remember numbers. • Thus, DNS was invented. • DNS Servers are found at: • Each ISP has its own DNS server. Normally two separate servers. (Primary DNS/Secondary DNS) • There are 13 root servers in the world.

  9. Root DNS Server Map

  10. Communication Model

  11. Tracing an Israeli Website • Tracing route to haaretz.co.il [192.118.72.27] • over a maximum of 30 hops: • 1 <1 ms <1 ms <1 ms BEZEQ [10.0.0.138] [My Router] • 2 20 ms 19 ms 19 ms 213.57.0.7 [Yakum – Israel] • 3 19 ms 19 ms 19 ms tbd.pt.mx-ipsla.con.hotnet.net.il [213.57.0.221] [Yakum – Israel] • 4 21 ms 20 ms 20 ms ae7.50.hfa.mx-mx.con.hotnet.net.il [213.57.0.250] [Yakum – Israel] • 5 91 ms 23 ms 23 ms 82.166.25.214.fix.netvision.net.il [82.166.25.214] [Haifa – Israel] • 6 23 ms 22 ms 23 ms core1-edge1-clr.nta.nv.net.il [212.143.203.57] [Haifa – Israel] • 7 23 ms 22 ms 23 ms coresw1-ptk-3-6-core1.nta.nv.net.il [212.143.203.85] [Haifa – Israel] • 8 25 ms 25 ms 25 ms212.143.29.193 [Haifa – Israel] • 9 25 ms 26 ms 26 ms212.143.29.196 [Haifa – Israel] • 10 * 33 ms 33 ms 192.118.72.66 [Ramat Gan – Israel] • 11 27 ms 27 ms 27 ms 192.118.72.27 [Ramat Gan – Israel] • Trace complete.

  12. Two Different ISPs– One Website • Will the tracing results be the same?

  13. Tracing heathcare.gov via HotNet • Tracing route to healthcare.gov [23.35.119.205] • over a maximum of 30 hops: • 1 <1 ms <1 ms <1 ms BEZEQ [10.0.0.138] [My Router] • 2 19 ms 19 ms 19 ms 213.57.0.7 [Tel Aviv - Israel] • 3 20 ms 19 ms 19 ms tbd.pt.mx-ipsla.con.hotnet.net.il [213.57.0.221] [Tel Aviv - Israel] • 4 21 ms 21 ms 21 ms ae0.hfa.mx-mx.con.hotnet.net.il [213.57.3.246] [Tel Aviv - Israel] • 5 71 ms 71 ms 71 ms core-213-57-3-186.ptr.hotnet.net.il [213.57.3.186] [Tel Aviv - Israel] • 6 102 ms 101 ms 99 ms r1fra1.core.init7.net [80.81.192.67] [Frankfurt - Germany] • 7 91 ms 229 ms 95 ms r1par1.core.init7.net [77.109.140.149] [Zurich - Switzerland] • 8 92 ms 85 ms 84 ms gw-akamai.par1.init7.net [77.109.134.254] [Thun - Switzerland] • 9 98 ms 90 ms 96 ms a23-35-119-205.deploy.static.akamaitechnologies.com [23.35.119.205] [Cambridge - USA] • Trace complete.

  14. Tracing heathcare.gov via Golan Telecom • Tracing route to healthcare.gov [172.229.199.205] • over a maximum of 30 hops: • 1 1 ms 1 ms 2 ms 192.168.43.1 [GT Internal Network] • 2 1477 ms 74 ms 100 ms 10.224.235.78 [GT Internal Network] • 3 1838 ms 528 ms 61 ms 10.224.224.101 [GT Internal Network] • 4 826 ms 75 ms 64 ms 10.224.224.102 [GT Internal Network] • 5 38 ms 37 ms 36 ms 37.26.146.1 [Tel Aviv - Israel • 6 34 ms 35 ms 38 ms bzq-218-111-9.red.bezeqint.net [81.218.111.9] [Tel Aviv - Israel • 7 40 ms 44 ms 42 ms bzq-179-162-69.static.bezeqint.net [212.179.162.69] [Tel Aviv - Israel] • 8 * 37 ms 39 ms bzq-219-189-94.cablep.bezeqint.net [62.219.189.94] [Tel Aviv - Israel] • 9 93 ms 99 ms 89 ms 213.242.116.129 [France] • 10 * * 163 ms ae-15-15.ebr1.Frankfurt1.Level3.net [4.69.143.246] [Frankfurt - Germany] • 11 124 ms 90 ms 318 ms ae-74-74.csw2.Frankfurt1.Level3.net [4.69.163.22] [Frankfurt - Germany] • 12 135 ms 89 ms 114 ms ae-2-70.edge5.Frankfurt1.Level3.net [4.69.154.73] [Frankfurt - Germany] • 13 284 ms 90 ms 317 ms xe-10-2-1.fra44.ip4.tinet.net [141.136.102.73] [France] • 14 98 ms 100 ms 98 ms xe-9-0-0.ams20.ip4.tinet.net [89.149.183.98] [Amsterdam - Netherlands] • 15 99 ms 109 ms 95 ms akamai-gw.ip4.tinet.net [141.136.99.6] [France] • 16 220 ms 108 ms 106 ms a172-229-199-205.deploy.static.akamaitechnologies.com [172.229.199.205] [Cambridge - USA] • Trace complete.

  15. Tracing an Australian address • Tracing route to neoaustralia.com.au [202.148.129.157] • 1 <1 ms <1 ms <1 ms BEZEQ [10.0.0.138] [My Router] • 2 19 ms 19 ms 19 ms 213.57.0.7 [Yakum - Israel] • 3 20 ms 19 ms 20 ms tbd.pt.mx-ipsla.con.hotnet.net.il [213.57.0.221] [Yakum - Israel] • 4 41 ms 41 ms 42 ms ge3-0.catania4.cat.seabone.net [93.186.129.130] [Catania - Italy] • 5 80 ms 80 ms 81 ms xe-11-1-0.franco31.fra.seabone.net [89.221.34.183] [Roma - Italy] • 6 94 ms 95 ms 94 ms ffm-b12-link.telia.net [213.248.68.189] [Frankfurt Am Main - Germany] • 7 95 ms 94 ms 94 ms ffm-bb1-link.telia.net [213.155.135.8] [Frankfurt Am Main - Germany] • 8 188 ms 186 ms 185 ms nyk-bb1-link.telia.net [213.155.131.145] [New York (New York) - USA] • 9 248 ms 251 ms 248 ms las-bb1-link.telia.net [80.91.251.252] [Las Vegas (Nevada)- USA] • 10 257 ms 254 ms 262 ms las-b3-link.telia.net [213.155.130.127] [Las Vegas (Nevada)- USA] • 11 250 ms 246 ms 250 ms singaporetelecom-ic-150846-las-b3.c.telia.net [80.239.167.194] [Los Angeles - California] • 12 246 ms 350 ms 255 ms 203.208.171.141 [Singapore - Singapore] • 13 409 ms 409 ms 400 ms 203.208.174.50 [Singapore - Singapore] • 14 * * * Request timed out. [Firewall] • 15 * * * Request timed out. [Firewall] • 16 * * * Request timed out. [Firewall] • 17 * * 423 ms 59.154.57.190 [Pennant Hills (New South Wales) - Australia] • 18 410 ms 418 ms 407 ms 59.154.57.188 [Pennant Hills (New South Wales) - Australia] • 19 419 ms 410 ms 414 ms 119.225.61.94 [Brisbane (Queensland) - Australia] • 20 420 ms 416 ms 420 ms po93.mls1.bne3.server-noc.com [203.147.255.189] [Wickham - Australia] • 21 425 ms 407 ms 418 ms po93.mls1.bne3.server-noc.com [203.147.255.189] [Wickham - Australia] • 22 409 ms 420 ms 421 ms www.bathurstmowerland.com [202.148.129.157] [Wickham - Australia] • Trace complete.

  16. TCP/IP Model • Application Layer • Communication between applications • Protocols: • FTP – File Transfer Protocol • SMTP – Simple Mail Transfer Protocol • HTTP – Hyper Text Transfer Protocol • BitTorrent– Peer-to-Peer file sharing protocol • Transport Layer • Communication between end-to-end machines. • Protocols: • TCP – Transmission Control Protocol • UDP – User Datagram Protocol • SCTP – Stream Control Transfer Protocol • Internet Layer • Routing: Handles the way packets are sent from end machine A to end machine B. • Decides which path the packet needs to take in order to be received at destination. • IP – Internet Protocol • Link Layer (Network Access Layer) • Move packets between the interfaces of two different hosts on the same link. • Protocol: • MAC – Media Access Control. • Physical Layer • The pure hardware in any network infrastructure through it we send our bits of data. • The Ethernet cables, communication satellites, copper lines, etc.

  17. TCP/IP – Internet Protocol Suite • TCP/IP stands for Transmission Control Protocol / Internet Protocol (the first networking protocols defined). • TCP/IP is the networking model and a set of communication protocols. • TCP/IP provides end-to-end connectivity specifying how data should be formatted, addressed, transmitted, routed, and received.

  18. Ports • What are ports? • Think of them as entry/exit points to/from a machine. • Why ports? • Allows more than one service to be accessible at the same time on one machine. • Each port has a unique number: • HTTP uses port 80. (as default) • FTP uses port 21. (as default) • There are 64K (65536) ports to use. (from 1 to 65536) • Example: • http://15.216.110.22:80/ • ftp://15.216.110.22:21/

  19. Sockets • What are Sockets? • A socket is an endpoint for communication between two machines. • An instance can be created by the application, and used in order transfer and receive data. • Socket Types: • Stream Sockets – TCP • Datagram Sockets – UDP • Raw Sockets – ICMP (access to a lower layer protocol like IP) • Java API: • http://docs.oracle.com/javase/1.4.2/docs/api/java/net/Socket.html

  20. Stream Sockets • Stream sockets are used by the Transmission Control Protocol (TCP). • Definition: • Client Socket: • Socket clientSocket = new Socket(InetAddress address, int port); • Address – server IP address. • Port – port of server. • Server Socket: • Socket serverSocket = new ServerSocket(int port); • Port – port of server. • Socket clientConnection = serverSocket.accept(); • Waits for a new connection. • Returns a Socket object once connected. • Using this new object, communication is done.

  21. Stream Sockets 2. Client connects to the server using a socket with the host/ip and the port of the server. - A local port is assigned that will be used to connect to the client. • Server listens at port 4444 • 3. the server gets a new socket bound to the same local port and also has its remote endpoint set to the address and port of the client. • It needs a new socket so that it can continue to listen to the original socket for connection requests while tending to the needs of the connected client.

  22. Notes on Sockets • Can create more than one client socket with the same host and port! • Can create only one ServerSocket with a certain port! • Cannot create a ServerSocket on a local port used by another socket.

  23. Transmission Control Protocol - TCP • TCP: • Connection oriented protocol; a connection must be established between two sockets before transferring data: • Socket A listens to a port. • Socket B connects to socket A using IP:PORT. • Data can be sent in either way. • Connection is closed. • TCP Properties: • Advantages: • Data sent is guaranteed to be correct. • Data sent is guaranteed to be sent in full. • Data sent is guaranteed to be received in same order sent. • Disadvantages: • Latency (lag) introduced by waiting for acknowledgements. • Overhead makes the transmission slower. • Overhead: All the extra data sent by the communication protocol, excluding the real data we wish to send.

  24. TCP Frame Structure

  25. TCP 3-Way Handshake Diagram • Host A sends a TCP SYNchronize packet to Host B • Host B receives A's SYN • Host B sends a SYNchronize-ACKnowledgement • Host A receives B's SYN-ACK • Host A sendsACKnowledge • Host B receives ACK. TCP socket connection is ESTABLISHED.

  26. TCP - Continued • After the handshake between the two applications, TCP will set up a full-duplex communication between the two applications. • Then both ends can send and receive data. • This communication stays until one of the application closes the connection. • Full-duplex communication: • A can send to B. • B can send to A. • Examples of TCP uses: • Web surfing using browsers. • File download using the browser. • Sending emails. • FTP Download

  27. User Datagram Protocol - UDP • UDP: • No connection between sockets required! • Application A can send any data at any time without prior notification. • UDP Properties: • No guarantee on packet order. • No guarantee if packet is received. • If a packet received is corrupt, then it is discarded. • UDP Advantages: • Great for streaming live media (video, music). • Faster transmission due to smaller overhead. • UDP is used by: • DNS • DHCP • Any Time-sensitive application.

  28. UDP Frame Structure

  29. The Client-Server Model • A widely used model consisting of: • Server • Clients • Server: • Provides a service of some kind. • Examples: Web Server, FTP Server, DNS Server • Clients: • Connect to the server requesting the service. • Establishing connection: • The Server awaits connections. (listens to a port) • The server reacts to clients requests. • Example: • SimpleLinePrinter (TCP server-client: server accepts one client receives msgs from it- “bye” for termination)

  30. Running netstat –p when both the client and server are on the same machine should show:

  31. Text Transfer In Java • Reading data from Socket: • Reader Object: • BufferedReaderbufferedReader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()), “UTF-8”); • Reading Line: • String line = bufferedReader.readLine(); • Writing data to socket: • Writer Object: • PrintWriterprintWriter = new PrintWriter(new OutputStreamWriter(clientSocket.getOutputStream(), "UTF-8"), true); • Writing Line: • printWriter.print(“my text message”); • printWriter.flush(); • http://docs.oracle.com/javase/tutorial/networking/sockets/readingWriting.html

  32. Text Encoding • Different computers may use different symbol representations. Text sent might be received and understood differently. • Example: • Sending text from Linux Windows operating systems. • New line in Linux: \n • New line in Windows: \r\n • In order to ensure that the text sent is received correctly, both clients and server need to agree on text format. • Encoding formats example: • UTF-8 • ANSI • UCS-2

  33. Examples • in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(),"UTF-8")); • out = new PrintWriter(new OutputStreamWriter(clientSocket.getOutputStream(), "UTF-8"), true); • Code Examples: • 02_Echo(server sends back the messages that the client sends – UTF-8 format)

  34. Protocol Interface • We don’t want to hold the implementation of a protocol inside the server’s code.  • Protocol: • How to send messages • How to end transmission etc. • define an interface ServerProtocol • process() - for processing the received message and construct a response message • isEnd() - identifies the end of a protocol • Example: • 03_ProtocolInterface (server sends messages and checks for end of transmission using a protocol- sends numbered messages).

  35. HTTP • Hypertext Transfer Protocol • HTTP is the protocol to exchange or transfer hypertext. • Hypertext is text with references (hyperlinks) to other text that the reader can immediately access. • Create a socket to the host with port 80 and sent the HTTP request through it.

  36. HTTP - Request • An HTTP request is defined as a header, followed by an empty line and an optional body. • The request includes the protocol version. • Example: • Get Request: GET /index.html HTTP/1.1 Host: www.example.com

  37. HTTP Response • An HTTP response is defined as a header, followed by an empty line and an optional body. • Example: • 04_http (send a get request using HTTP protocol)

  38. Network console tools • ipconfig (Microsoft Windows console application) – displays all current TCP/IP network configuration values. • ifconfig (Unix-like console application) - configure, control, and query TCP/IP network interface parameters. • ping (Unix-like & Windows) - utility used to test whether a particular host is reachable across an Internet Protocol (IP) network and to measure the round-trip time for packets sent from the local host to a destination computer. • Telnet client (Unix-like & Windows) - Telnet is a network protocol used to provide a bidirectional interactive communications facility. Typically, telnet provides access to a command-line interface on a remote host via a virtual terminal connection. Putty can be used on recent Windows-es which don't have telnet. • cURL is a computer software project providing a library and command-line tool for transferring data using various protocols.

More Related