CSCE 515: Computer Network Programming

2y ago
87 Views
3 Downloads
255.28 KB
13 Pages
Last View : 8d ago
Last Download : 3m ago
Upload by : Kaleb Stephen
Transcription

OverviewWhat is a computer network? What is the Internet? What are the popular network referencemodel? CSCE 515:Computer NetworkProgramming-- Review (partial)Wenyuan XuOSI, TCP/IP Department of Computer Science andEngineeringUniversity of South CarolinaWhat is the main responsibilities and issuesfor each layer?CSCE515 – Computer Network ProgrammingTCP/IP Layering ArchitectureImportant SummaryData-Link: communication betweenmachines on the same network. Network: communication betweenmachines on possibly different networks. Transport: communication betweenprocesses (running on machines onpossibly different networks). OSI modelTCP/IP modelApplicationPresentation Application A simplified modelThe network layerHosts drop packetsinto this layer, layerroutes towardsdestination- onlypromise- try my bestSessionTransportTransportNetworkNetworkData linkHost to NetworkLayerPhysical The transport layerReliable/unreliablebyte oriented streamCSCE515 – Computer Network ProgrammingCSCE515 – Computer Network ProgrammingAddresses at Layers Physical Layer: no address necessary Data Link Layer – address must specify the hostMAC address Network Layer – address must identify thenetworkIP address Transport Layer - address must identify thedestination process.Port #CSCE515 – Computer Network ProgrammingData Link LayerProtocol

Date Link Layer Functionality What is the main Functionality of date link layer?Provides reliable transfer of information between two adjacent nodes What is the service provided by data link layer?Framing Frame creationFrame delineationEncoding: Convert bits to signals and recover bits from received signalsFraming: decide on a minimum unit for sending bits Error detection and /or correction of frames Parity, CRCUse starting and ending characters (tags) to markboundaries of frameProblem: what if tag characters occur in the date orcontrol portions of the frameFlow control A frame is a group of bits, typically in sequenceIssues:ARQ, Sliding WINDOW Use preamble packet lengthCSCE515 – Computer Network ProgrammingError Control No physical link is perfect, bits will be corruptedWe can either:Detect errors and request retransmissionOr correct errors without retransmission Ethernet - A Real Data-Link Layer What is header of a typical Ethernet frame?How is Ethernet connected?What is the address used in Ethernet? What is the basic protocol? -- CSMA/CD example: 08:00:e4:b1:20Multi-access (shared medium)Error Detection CSCE515 – Computer Network ProgrammingParity bitsPolynomial codes or checksumsCyclic Redundancy Check (CRC)Given a polynomial code and a message, what is thechecksummed messageGiven a checksummed message, can you determine whetherthere are errors. many hosts on 1 wireCarrier sense: can tell when another host is transmittingCollision detection: How can a device detect collision?How to avoid two device collide again?CSCE515 – Computer Network ProgrammingTransmit Algorithm CSCE515 – Computer Network ProgrammingCollisionsIf line is idle send immediatelyupper bound message size of 1500 bytesmust wait 9.6us between back-to-back frames If line is busy wait until idle and transmit immediatelyCSCE515 – Computer Network ProgrammingCSCE515 – Computer Network Programming

Ethernet Backoff Algorithm If collision,How to detect collision?jam for 32 bits, then stop transmitting frameminimum frame is 64 bytes (header 46 bytes of data)WHY?IP- Network LayerChoose one slot randomly from 2k slots, where k is thenumber of collisions the frame has suffered.One contention slot length 2 x end-to-endpropagation delayIf 16 backoffs occur, the transmission of the frame isconsidered a failure.CSCE515 – Computer Network ProgrammingIP - Network Layer Provide delivery of packets fromone host in the Internet to anyother host in the Internet, even ifthe hosts are on differentnetworks Connectionless Delivery (eachdatagram is treated individually).Unreliable (delivery is notguaranteed).Fragmentation / Reassembly(based on hardware MTU).Routing.Error detectionIP AddressesRegional Network 1Backbones RegionalNetwork 2 IP addresses are not the same as the underlyingdata-link (MAC) addresses. WHY? IP addresses are logical addresses (not physical)32 bits.Includes a network ID and a host ID.When an organization applies for IP address,they get a network ID. RegionalNetwork 3CSCE515 – Computer Network ProgrammingCSCE515 – Computer Network ProgrammingThe four formats of IP Addresses 32 bits long: 129.252.138.8What is this IP address? class B?How many hostIDs possible?ClassA 0 NetIDB 10HostIDNetIDC 110D 11108 bitsHostIDHostIDNetIDMulticast Address8 bits8 bitsCSCE515 – Computer Network Programming8 bitsClassClass AAzz 128128 possiblepossible networknetwork IDsIDszz over4millionhostIDsover 4 million host IDs perper networknetwork IDIDClass Bz16K possible network IDsz64K host IDs per network IDClass Czover 2 million possible network IDszabout 256 host IDs per network IDCSCE515 – Computer Network Programming

Host and Network Addresses A single network interface is assigned a single IPaddress called the host address. A host may have multiple interfaces, andtherefore multiple host addresses. Hosts that share a network all have the same IPnetwork address (the network ID). Display all network interface on a hostIP RoutingActual routing table contains: destination IP address, IPaddress of next-hop router, network interface, Flagifconfig –anetstat -iCSCE515 – Computer Network ProgrammingCSCE515 – Computer Network ProgrammingMapping IP Addresses to/from HardwareAddressesIP Routing Forwarding:When each packet arrives, looking up the outgoing lineto use for it in the routing tableDone on a hop-by-hop basisIf destination is directly connected or on a sharednetwork, send IP datagram directly to destinationOtherwise send datagram to a default router How?Why?When? Address Resolution ProtocolRouting updatesReverse Address ResolutionHow?Why?When?filling in and updating the routing tablesCSCE515 – Computer Network ProgrammingCSCE515 – Computer Network ProgrammingIP Addresses Subnet MaskSubnet Addressing To make better use of class A and class Baddresses, divide host ID into subnet ID andhost ID1410Class BNetID1410NetIDHostIDSubnetIDCSCE515 – Computer Network ProgrammingB 101488NetIDSubnetIDHostID1 1 1 1 1 1 1 11 1 1 1 1 1 1 11 1 1 1 1 1 1 1 0 0 0 0 0 0 0 016832-bit value containing “1” bits for network ID andsubnet ID, and “0” bits for host ID8HostID255.255.255.00xFFFFFF00Example: A and B are class B addresses, using the same subnet mask.A 165.230.82.52B 165.230.24.93Same network?M 255.255.255.0Same subnet?CSCE515 – Computer Network Programming

Subnetting Variable length subnettingIt is possible to have a single wire networkwith multiple subnets? Subnet masks allow power of 2 subnetsUse a hierarchy of routers to allow subnets to bedivided with different subnet masksAnother approach:Variable length subnet masksAllow a subnet to be defined by more than two masksThe router applies the masks one after anothermask: 255.255.255.128mask: 255.255.255.128255.255.255.192subnet: 221.2.3.0subnet 1subnet: 221.2.3.128subnet 2,3subnet: 221.2.3.192mask: 255.255.255.192CSCE515 – Computer Network ProgrammingQuestion CSCE515 – Computer Network ProgrammingCIDR - (classless Inter domain routing)If an ISP has a 203.6.8.0 Network, he has5 customers who in turn has a network of60, 60, 60, 30, 30 hosts. If the ISP wants toassign a subnet to each customerWhat should the subnet mask be?What is the address range in each subnet?What should the routing table entries be? Original addressing schemes (class-based):32 bits divided into 2 parts:Class A0 NetIDClass BNetID10Class C110 HostIDHostIDHostIDNetIDClass C address has max of 254 hostsNot enough for many organizationsToo many class C addresses Æ huge routing tables Use CIDR address mask to aggregateCIDR introduced to solve 2 problems:exhaustion of IP address spacesize and growth rate of routing tableCSCE515 – Computer Network ProgrammingAddress Arithmetic: Address Blocks Address format IP address/prefix P .The prefix denotes the upper P bits of the IP address.Can be used to specify arbitrary blocks of addresses The address/prefix pair defines an address block:Examples:200.15.0.0/16 [ 200.15.0.0 - 200.15.255.255 ]192.24.0.0/13 [ 192.24.0.0 - 192.31.255.255 ]CSCE515 – Computer Network ProgrammingExample of CIDRCIDR Block Prefix/27/26/25/24/23 /15/14/13# Equivalent Class C1/8th of a Class C1/4th of a Class C1/2 of a Class C1 Class C2 Class C# of Host Addresses32 hosts64 hosts128 hosts256 hosts512 hosts512 Class C1,024 Class C2,048 Class C131,072 hosts262,144 hosts524,288 hosts192.00011000.0.013th bits fixedVariableCSCE515 – Computer Network ProgrammingCSCE515 – Computer Network Programming

Other Developments: NATCIDR: Classless Inter-Domain Routing NAT- Network address translationWhy NAT?How NAT work? Hosts need not have unique global IP address Q: Say an ISP has 192.5.48.0, 192,5.49.0, 192.5.50.0,192, 51.0, what should the IP address advertised be?A: 192.5.48.0/22 Q: Say an ISP has 200.8.4/24 address, how manyaddresses are included?A: 256 addressesHosts are assigned private addresses10.0, 172.16 to 172.31 and 192.168. Are allocated forprivate hosts (Hmmm, what if those addresses appearon the Internet themselves?)Q: If a customer needs only 4 addresses from 200.8.4.24,then what the address should be specified?A: 200.8.4.24/30 Packets from private hosts are replaced withsource address of NAT gateway, use port# touniquely do the reverse translation.CSCE515 – Computer Network ProgrammingCSCE515 – Computer Network ICMP, ARP&RARPProcess LayerTransport LayerNetwork LayerIPData-Link Layer802.3CSCE515 – Computer Network ProgrammingUDP vs. TCP What is the difference between UDP & TCP?Connection oriented VS. Connectionlessmany others .Q: Which protocol is better ?A: It depends on the application.TCP provides a connectionconnection-oriented, reliable, byte streamservice (lots of overhead).UDP offers minimal datagram delivery service (as littleoverhead as possible).CSCE515 – Computer Network ProgrammingUDPThe term datagram is also used todescribe the unit of transfer of UDP!Datagram Delivery Connectionless Unreliable Minimal UDP Datagram FormatSource PortDestination PortLengthChecksumDataCSCE515 – Computer Network Programming

Addressing in TCP/IPTCP TCP provides the end-to-end reliableconnection that IP alone cannot supportThe TCP protocolFrame formatConnection CreationFlow controlCongestion controlConnection termination Each TCP/IP address includes:Internet AddressProtocol (UDP or TCP)Port NumberNOTE: TCP/IP is a protocol suite that includes IP,TCP and UDP.CSCE515 – Computer Network ProgrammingHmmmmm. TCP or UDP ?CSCE515 – Computer Network ProgrammingTCP Segment FormatElectronic commerce? Video server? File transfer? Email ? Chat groups? Robotic surgery controlled remotely over anetwork? 015 16source port number There are a bunch of control flags:URG: urgent data included. ACK: this segment is (among other things) anacknowledgement. RST: error - abort the session. SYN: Used to establish connection; synchronizeSequence Numbers (setup) FIN: polite connection termination.20 bytesacknowledgment numberheaderlengthreservedU A P R S FR C S S Y IG K H T N NTCP checksumwindow sizeurgent pointeroption (if any)data (if any)CSCE515 – Computer Network ProgrammingTCP Connection Establishment– Three-way handshakeClient “I want to talk, andI’m starting withbyte number X 1”.timeCSCE515 – Computer Network Programmingdestination port numbersequence numberCSCE515 – Computer Network ProgrammingTCP segment31“Got it - you startat byte number Y 1”.ServerSYNSYNISN XISN X1SYNSYN 2ISN YISN YACK X 1ACK X 1ACK Y 1ACK Y 13CSCE515 – Computer Network Programming“OK, I’m here and I’lltalk. My first byte willbe called number Y 1,and I know your firstbyte will be number X 1”

Why 3-Way? TCP Flow ControlApplication doesa 2K write receiver recv’s buffer4K0emptySenderWhy is the third message necessary?2KSEQ 02KHINTS:ACK 2048 WIN 2048Application doesa 3K writeTCP is a reliable service.IP delivers each TCP segment.IP is not reliable.2KSender isblockedSEQ 2048FullACK 4096 WINACK 4096 WINSender maysend up to 2k1k 0Application reads 2k 20482KSEQ 40961KCSCE515 – Computer Network ProgrammingCSCE515 – Computer Network ProgrammingTCP TerminationTest QuestionsApp2App1“I have no moredata for you”FIN WAIT 1FINFINSN XSN XACK X 1ACK X 1Why is a 3-way handshake necessary? Who sends the first FIN - the server or theclient? Once the connection is established, whatis the difference between the operation ofthe server’s TCP layer and the client’sTCP layer? What happens if a bad guy can guessISNs? 12“OK, I understand youare done sending.”CLOSE WAIT.FIN WAIT 2FINFINSN YSN Y“Over and Out,Goodbye”TIME WAITACK Y 1ACK Y 12K3“OK - Now I’m alsodone sending data”.LAST ACK4CLOSEDCSCE515 – Computer Network ProgrammingCSCE515 – Computer Network ProgrammingSocket? What is Socket?Network API, developed by BerkeleySocketProgramming Between which two layers do the socket sit? What is the wish list of a socket? What functions should the socket provide? What are the elements of a Socket? What is a socket descriptor? What are the two typical socket types?Stream socketsDatagram socketsCSCE515 – Computer Network Programming

Network APISocket Descriptor Data StructureInternetprotocol suiteOSI Pv4, IPv6Data linkData linkPhysicalPhysicalkernelDescriptor TableFamily:Family: PF INETPF INETService:Service: SOCK STREAMSOCK STREAMLocalLocalIP:IP: 111.22.3.4111.22.3.4RemoteRemoteIP:IP: 123.45.6.78123.45.6.78LocalLocalPort:Port: 22492249RemoteRemotePort:Port: 3726372601234Communicationsdetailsint s, family, type, protocol;s socket(family, type, protocol);etc.cc read(s, buf, nbytes);CSCE515 – Computer Network ProgrammingSocket system calls General Use ConnectionConnection-oriented (TCP)– socket()– connect()– listen()– accept()read()write()close()CSCE515 – Computer Network ProgrammingYou should know What does each system call do?Can each system call be used in TCP/UDPsocket?I do not expect you to remember thesequence of each parameter, but you shouldknow:How to set each parameter?What is the typical return value? Can you understand and explain: Practical issues Connectionless )recvfrom()recvfrom()- connect()- bind()- socket()myaddr.sin addr.s addr htonl(INADDR ANY);How is endpoint address specified?and CSCE515 – Computer Network ProgrammingNetwork Byte Order What is network byte order? Why do we need Network Byte Order?CSCE515 – Computer Network ProgrammingTCP Sockets Programming sock socket(PF INET, SOCK STREAM, 0); When and how should we use the network byte functions? What are network byte order functions:‘h’ : host byte order‘s’ : short (16bit) Tell the kernel to accept incoming connection requests directed at thesocket address. 3-way handshakeTell the kernel to queue incoming connections for us.How to send/receive data.How to terminate a connection.uint16 t htons(uint16 t);uint16 t ntohs(uint 16 t);CSCE515 – Computer Network ProgrammingWhat the typical work flow for a server?How to establish an passive mode TCP socket?In which function is the following procedure implemented?‘n’ : network byte order‘l’ : long (32bit)uint32 t htonl(uint32 t);uint32 t ntohl(uint32 t);How to create a TCP socket close() reading EOFWhat the typical work flow for a client?Where is 3-way handshake done?CSCE515 – Computer Network Programming

Client-Server Communication (TCP)socket()bind()TCP Clientlisten()TCP ServerSum of both queuescannot exceed backlogwell-known onnection establishmentwrite()data(request)blocks until connection from clientCompleted connection queue3-wayhandshakecompleteTCPread()Incomplete connection queueprocess requestread()close()data(reply)end-of-file notificationwrite()arrivingSYNread()close()CSCE515 – Computer Network ProgrammingCSCE515 – Computer Network ProgrammingUDP Sockets Programming How to create UDP sockets?sock socket(PF INET, SOCK DGRAM,0); What is the typical workflow for:ClientServerUDP Socket How to send data? How to receive data?sendto()recvfrom() If buff is not large enough, any extra data is lost forever.Timeout for recvfrom()Connected mode?Why?How?Who can?CSCE515 – Computer Network ProgrammingClient-Server Communication (UDP)UDP Serversocket()UDP Clientwell-known locks until datagramreceived from clientprocess requestrecvfrom()data(reply)sendto()close()CSCE515 – Computer Network Programmingrecvfrom()and alarm()signal(SIGALRM, sig alrm);static voidalarm(max time to wait);sig alrm(int signo){if (recvfrom( ) 0)return;if (errno EINTR)}/* timed out */else/* some other error */else/* no error or time out- turn off alarm */alarm(0); There are some other (better) ways todo this - check out section 14.2CSCE515 – Computer Network Programming

Connected mode Connected UDP sockets for TFTP ConcurrencyA UDP socket can be used in a call to.What will OS do after connect()is called?TFTPServerRegister the address of the peer in OSNo handshakeNo data is sentUDP Client 2Client 1UDP(9001)UDP(69)UDP(9000)UDPOnce a UDP socket is connected:can use write() and send()can use read() and recv() UDP datagramUDP datagramonly datagrams from the peer will be returned.CSCE515 – Computer Network ProgrammingCSCE515 – Computer Network ProgrammingQuestions Can UDP socket connected to a broadcastaddress?A: yes, a connected UDP socket exchangesdatagrams with only one IP address IO MultiplexingServer A is connected to a broadcastaddress, so .Can this UDP socket send?Can this UDP socket Receive?CSCE515 – Computer Network ProgrammingI/O Multiplexing Why do we need I/O Multiplexing?Using select() need to be able to monitor multiple descriptors What are the options to achieve IO Multiplexing?What are the cons and pros for each option?Use nonblocking I/O. use fcntl() to set O NONBLOCKUse alarm and signal handler to interrupt slow systemcalls.Use multiple processes/threads.Use functions that support checking of multiple inputsources at the same time.CSCE515 – Computer Network ProgrammingWhat does select() do?system call allows us to use blocking I/O on a set ofdescriptors (file, socket, ). How to use select()Create fd setClear the whole thing with FD ZEROAdd each descriptor you want to watch usingFD SET.Call selectwhen select returns, use FD ISSET to see if I/Ois possible on each descriptor.CSCE515 – Computer Network Programming

Advanced programmingJAVA RMI Daemons Applicationsdaemon initiationsystem message output mechanisminetd Multicast socket programmingCSCE515 – Computer Network ProgrammingApplication list TELNETRLOGINFTPTFTPHTTPDNSSMTP, POP3 Q: What are their usage? TELNET Client and llkernelRemote login? File transfer? Q: which transportation protocol used?user at aterminalTCP, UDP? Q: How is data being transferred between a server and a client?Q: What are the challenges/design issues for each application? Howhave those issues been solved?terminaldriverOnly ONE TCP connection !!!Q: How to distinguish control informationvs. data?kerneluser at aterminalCSCE515 – Computer Network ProgrammingTFTP -- Sorcerer’s Apprentice SyndromeCSCE515 – Computer Network ProgrammingThe Fixsend DATA[n](time out)retransmit DATA[n]receive ACK[n]send DATA[n 1]receive ACK[n] (dup)send DATA[n 1](dup).receive DATA[n]send ACK[n] Sender should not resend a data packet inresponse to a duplicate ACK.receive DATA[n] (dup)send ACK[n] (dup) If sender receives ACK[n] - don’t sendDATA[n 1] if the ACK was a duplicate.receive DATA[n 1]send ACK[n 1]receive DATA[n 1] (dup)send ACK[n 1] (dup)CSCE515 – Computer Network ProgrammingCSCE515 – Computer Network Programming

Sample question 1 Show the execution of Dijkstra’s algorithm on thefollowing graph, with vertex A as the source vertex. Ateach step, show the value of the chosen vertex (w) andthe updates to the distance and parent vectors.CSCE515 – Computer Network ProgrammingSample question 3 Please explain the packet captured in wireshark.CSCE515 – Computer Network ProgrammingSample question 2 Java port scanner. Write a port scanprogram. In particular, you are asked towrite a program that will find out (print out)which of the first 1024 ports seem to behosting TCP servers on a host“broad.cse.sc.edu”CSCE515 – Computer Network Programming

CSCE515 – Computer Network Programming Host and Network Addresses A single network interface is assigned a single IP address called the host address. A host may have multiple interfaces, and therefore multiple host addresses. Hosts that share a network all have the same IP network address (the network ID). Dis

Related Documents:

separate pump room and transporting hydraulic fluid across the test facility. Model 515.180 Model 515.150/120 Model 515.90 Model 515.60 Model 515.30/20 Model 515.11/07 The SilentFlo 515 Family. Fits Your Needs Today and Tomorrow The SilentFlo series supports a wide range of flow demands, with the largest HPU

Warm Regards, David R. Chapman, P.E. M. ASCE Connecticut Society of Civil Engineers, President 2018-2019 A Message from your 2018—2019 CSCE President February 20, 2019 INSIDE THIS ISSUE: February 2019 Student Awards 3 Upcoming CSCE Events 5 Younger Members Event 7 CSCE Notice 12

What is Machine Learning? Basic concepts 2. Welcome to CSCE 633! About this class Introduction to Machine Learning What is Machine Learning? Basic concepts 3. Welcome to CSCE 633! Instructor Theodora Chaspari chaspari@tamu.edu (but use Piazza for quickest reply)

CSCE 5730: Digital CMOS VLSI Design 29 IC Categories Functions Analog ICs Amplifiers Filters Digital ICs Boolean Gates Encoders/Decoders Multiplexers / Demultiplexers Flip-flops Counters . Digital IC Design Flow CSCE 5730: Digital CMOS VLSI Design 36. Technology Growth and Moore's Law CSCE 5730: Digital CMOS VLSI Design 37.

Basic Computer Architecture CSCE 496/896: Embedded Systems Witawas Srisa-an Review of Computer Architecture Credit: Most of the slides are made by Prof. Wayne Wolf who is the author of the textbook. I made some modifications to the note for clarity. Assume some background information from CSCE 430 or equivalent

–“Computer Systems -a Programmer’s Perspective”, 3rd edition, Bryant & O’Hallaron, Pearson, 2016. // Highly recommended; 2nd edition is OK –“The Linux Programming Interface: A Linux and UNIX System Programming Handbook”, Michael Kerrisk, No Starch Press, 2011. // You can find it online CSCE 311 –Operating Systems 14

5/21/2016 Department of Computer Science and Engineering Dwight Look College of Engineering Texas A&M University Computer Science (CPSC) Catalog 138, 2015-16 FRESHMAN YEAR First Semester (Th-Pr) Cr Second Semester (Th-Pr) Cr CSCE 121 Intro. Prog. Design and Concepts (3-2) 4 CSCE 221 Data Struct. and Algo. (3-2) 4

A Business Plan will help you collate and clarify your business ideas, plan for the future of your business, and will help to show whether your idea is realistic and workable. Your Business Plan will play a key role in attracting funding to get your business started, so you should make sure you have one prepared before applying for lending. You may want to complete this and bring a copy when .